2019-05-11 04:33:54 +08:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
2022-02-19 22:37:57 +08:00
|
|
|
namespace XCharts.Runtime
|
2019-05-11 04:33:54 +08:00
|
|
|
{
|
2024-01-13 22:37:13 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// The pie chart is mainly used for showing proportion of different categories. Each arc length represents the proportion of data quantity.
|
|
|
|
|
/// || 饼图主要用于显示不同类目占比的情况,通过弧长来反映数据的大小占比。
|
|
|
|
|
/// </summary>
|
2019-07-15 00:24:04 +08:00
|
|
|
[AddComponentMenu("XCharts/PieChart", 15)]
|
|
|
|
|
[ExecuteInEditMode]
|
|
|
|
|
[RequireComponent(typeof(RectTransform))]
|
|
|
|
|
[DisallowMultipleComponent]
|
2023-06-04 21:52:23 +08:00
|
|
|
[HelpURL("https://xcharts-team.github.io/docs/configuration")]
|
2021-11-23 13:20:07 +08:00
|
|
|
public class PieChart : BaseChart
|
2019-05-11 04:33:54 +08:00
|
|
|
{
|
2022-03-20 18:52:50 +08:00
|
|
|
protected override void DefaultChart()
|
2019-07-15 00:24:04 +08:00
|
|
|
{
|
2023-02-12 21:22:53 +08:00
|
|
|
var legend = EnsureChartComponent<Legend>();
|
2021-11-23 13:20:07 +08:00
|
|
|
legend.show = true;
|
|
|
|
|
|
2019-07-15 00:24:04 +08:00
|
|
|
RemoveData();
|
2021-11-23 13:20:07 +08:00
|
|
|
Pie.AddDefaultSerie(this, GenerateDefaultSerieName());
|
2019-07-15 00:24:04 +08:00
|
|
|
}
|
2024-01-13 22:37:13 +08:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// default label pie chart.
|
|
|
|
|
/// || 默认带标签饼图。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void DefaultLabelPieChart()
|
|
|
|
|
{
|
|
|
|
|
CheckChartInit();
|
|
|
|
|
var serie = GetSerie(0);
|
|
|
|
|
serie.EnsureComponent<LabelStyle>();
|
|
|
|
|
serie.EnsureComponent<LabelLine>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// default donut pie chart.
|
|
|
|
|
/// || 默认甜甜圈饼图。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void DefaultDonutPieChart()
|
|
|
|
|
{
|
|
|
|
|
CheckChartInit();
|
|
|
|
|
var serie = GetSerie(0);
|
|
|
|
|
serie.radius[0] = 0.20f;
|
|
|
|
|
serie.radius[1] = 0.28f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// default label donut pie chart.
|
|
|
|
|
/// || 默认带标签甜甜圈饼图。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void DefaultLabelDonutPieChart()
|
|
|
|
|
{
|
|
|
|
|
CheckChartInit();
|
|
|
|
|
var serie = GetSerie(0);
|
|
|
|
|
serie.radius[0] = 0.20f;
|
|
|
|
|
serie.radius[1] = 0.28f;
|
|
|
|
|
serie.EnsureComponent<LabelStyle>();
|
|
|
|
|
serie.EnsureComponent<LabelLine>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// default rose pie chart.
|
|
|
|
|
/// || 默认玫瑰饼图。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void DefaultRadiusRosePieChart()
|
|
|
|
|
{
|
|
|
|
|
CheckChartInit();
|
|
|
|
|
var serie = GetSerie(0);
|
|
|
|
|
serie.pieRoseType = RoseType.Radius;
|
|
|
|
|
serie.EnsureComponent<LabelStyle>();
|
|
|
|
|
serie.EnsureComponent<LabelLine>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// default area rose pie chart.
|
|
|
|
|
/// || 默认面积玫瑰饼图。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void DefaultAreaRosePieChart()
|
|
|
|
|
{
|
|
|
|
|
CheckChartInit();
|
|
|
|
|
var serie = GetSerie(0);
|
|
|
|
|
serie.pieRoseType = RoseType.Area;
|
|
|
|
|
serie.EnsureComponent<LabelStyle>();
|
|
|
|
|
serie.EnsureComponent<LabelLine>();
|
|
|
|
|
}
|
2019-05-11 04:33:54 +08:00
|
|
|
}
|
2022-05-22 22:17:38 +08:00
|
|
|
}
|