Files
XCharts/Runtime/Serie/Pie/Pie.cs

44 lines
1.7 KiB
C#
Raw Normal View History

using UnityEngine;
2022-02-19 22:37:57 +08:00
namespace XCharts.Runtime
2021-11-23 13:20:07 +08:00
{
[System.Serializable]
2021-12-09 21:35:23 +08:00
[SerieConvert(typeof(Line), typeof(Bar))]
2021-11-23 13:20:07 +08:00
[SerieHandler(typeof(PieHandler), true)]
2021-12-12 18:05:26 +08:00
[DefaultAnimation(AnimationType.Clockwise)]
[SerieComponent(typeof(LabelStyle), typeof(LabelLine), typeof(TitleStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
[SerieDataComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(LabelLine), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
2022-05-22 22:17:38 +08:00
[SerieDataExtraField("m_Ignore", "m_Selected", "m_Radius")]
2021-11-23 13:20:07 +08:00
public class Pie : Serie
{
[SerializeField][Since("v3.8.1")] private bool m_RadiusGradient = false;
public override SerieColorBy defaultColorBy { get { return SerieColorBy.Data; } }
2022-05-22 22:17:38 +08:00
public override bool titleJustForSerie { get { return true; } }
2021-12-09 21:35:23 +08:00
/// <summary>
/// Whether to use gradient color in pie chart.
2023-11-11 23:32:24 +08:00
/// || 是否开启半径方向的渐变效果。
/// </summary>
public bool radiusGradient
{
get { return m_RadiusGradient; }
set { if (PropertyUtil.SetStruct(ref m_RadiusGradient, value)) { SetVerticesDirty(); } }
}
2022-01-26 20:47:14 +08:00
public static Serie AddDefaultSerie(BaseChart chart, string serieName)
2021-11-23 13:20:07 +08:00
{
var serie = chart.AddSerie<Pie>(serieName);
2024-01-13 22:11:01 +08:00
chart.AddData(serie.index, Random.Range(10, 100), "pie1");
chart.AddData(serie.index, Random.Range(10, 100), "pie2");
chart.AddData(serie.index, Random.Range(10, 100), "pie3");
2022-01-26 20:47:14 +08:00
return serie;
2021-11-23 13:20:07 +08:00
}
2022-12-22 22:26:10 +08:00
public static Pie ConvertSerie(Serie serie)
2021-12-09 21:35:23 +08:00
{
var newSerie = SerieHelper.CloneSerie<Pie>(serie);
return newSerie;
}
2021-11-23 13:20:07 +08:00
}
}