Files
XCharts/Demo/Scripts/Demo10_LineSimple.cs

40 lines
1.0 KiB
C#
Raw Normal View History

2019-07-15 00:24:04 +08:00
using UnityEngine;
using XCharts;
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Demo10_LineSimple : MonoBehaviour
{
2019-10-09 09:59:44 +08:00
void Awake()
2019-07-15 00:24:04 +08:00
{
var chart = gameObject.GetComponent<LineChart>();
2019-10-09 09:59:44 +08:00
if (chart == null)
{
chart = gameObject.AddComponent<LineChart>();
}
2019-07-15 00:24:04 +08:00
chart.title.show = true;
chart.title.text = "Line Simple";
chart.tooltip.show = true;
chart.legend.show = false;
chart.xAxises[0].show = true;
chart.xAxises[1].show = false;
chart.yAxises[0].show = true;
chart.yAxises[1].show = false;
chart.xAxises[0].type = Axis.AxisType.Category;
chart.yAxises[0].type = Axis.AxisType.Value;
2019-10-09 09:59:44 +08:00
chart.xAxises[0].splitNumber = 10;
2019-07-15 00:24:04 +08:00
chart.xAxises[0].boundaryGap = true;
chart.RemoveData();
2019-09-29 09:16:15 +08:00
chart.AddSerie(SerieType.Line);
2019-10-09 09:59:44 +08:00
for (int i = 0; i < 10; i++)
2019-07-15 00:24:04 +08:00
{
chart.AddXAxisData("x" + i);
chart.AddData(0, Random.Range(10, 20));
}
}
}