增加Chart的更多快捷创建图表菜单

This commit is contained in:
monitor1394
2024-01-13 22:37:13 +08:00
parent fff04347fa
commit 9a56985b3a
16 changed files with 722 additions and 13 deletions

View File

@@ -2,6 +2,12 @@ using UnityEngine;
namespace XCharts.Runtime
{
/// <summary>
/// Line chart relates all the data points symbol by broken lines, which is used to show the trend of data changing.
/// It could be used in both rectangular coordinate andpolar coordinate.
/// ||折线图是用折线将各个数据点标志连接起来的图表,用于展现数据的变化趋势。可用于直角坐标系和极坐标系上。
/// 设置 areaStyle 后可以绘制面积图。
/// </summary>
[AddComponentMenu("XCharts/LineChart", 13)]
[ExecuteInEditMode]
[RequireComponent(typeof(RectTransform))]
@@ -22,5 +28,108 @@ namespace XCharts.Runtime
AddXAxisData("x" + (i + 1));
}
}
/// <summary>
/// default area line chart.
/// || 默认面积折线图。
/// </summary>
public void DefaultAreaLineChart()
{
CheckChartInit();
var serie = GetSerie(0);
if (serie == null) return;
serie.EnsureComponent<AreaStyle>();
}
/// <summary>
/// default smooth line chart.
/// || 默认平滑折线图。
/// </summary>
public void DefaultSmoothLineChart()
{
CheckChartInit();
var serie = GetSerie(0);
if (serie == null) return;
serie.lineType = LineType.Smooth;
}
/// <summary>
/// default smooth area line chart.
/// || 默认平滑面积折线图。
/// </summary>
public void DefaultSmoothAreaLineChart()
{
CheckChartInit();
var serie = GetSerie(0);
if (serie == null) return;
serie.EnsureComponent<AreaStyle>();
serie.lineType = LineType.Smooth;
}
/// <summary>
/// default stack line chart.
/// || 默认堆叠折线图。
/// </summary>
public void DefaultStackLineChart()
{
CheckChartInit();
var serie1 = GetSerie(0);
if (serie1 == null) return;
serie1.stack = "stack1";
var serie2 = Line.AddDefaultSerie(this, GenerateDefaultSerieName());
serie2.stack = "stack1";
}
/// <summary>
/// default stack area line chart.
/// || 默认堆叠面积折线图。
/// </summary>
public void DefaultStackAreaLineChart()
{
CheckChartInit();
var serie1 = GetSerie(0);
if (serie1 == null) return;
serie1.EnsureComponent<AreaStyle>();
serie1.stack = "stack1";
var serie2 = Line.AddDefaultSerie(this, GenerateDefaultSerieName());
serie2.EnsureComponent<AreaStyle>();
serie2.stack = "stack1";
}
/// <summary>
/// default step line chart.
/// || 默认阶梯折线图。
/// </summary>
public void DefaultStepLineChart()
{
CheckChartInit();
var serie = GetSerie(0);
if (serie == null) return;
serie.lineType = LineType.StepMiddle;
}
/// <summary>
/// default dash line chart.
/// || 默认虚线折线图。
/// </summary>
public void DefaultDashLineChart()
{
CheckChartInit();
var serie = GetSerie(0);
if (serie == null) return;
serie.lineType = LineType.Normal;
serie.lineStyle.type = LineStyle.Type.Dashed;
}
/// <summary>
/// default time line chart.
/// || 默认时间折线图。
/// </summary>
public void DefaultTimeLineChart()
{
CheckChartInit();
var xAxis = GetChartComponent<XAxis>();
xAxis.type = Axis.AxisType.Time;
}
}
}