Files
XCharts/Examples/Example13_LineSimple.cs

62 lines
1.7 KiB
C#
Raw Normal View History

using UnityEngine;
#if INPUT_SYSTEM_ENABLED
using Input = XCharts.Runtime.InputHelper;
#endif
2022-02-19 22:37:57 +08:00
using XCharts.Runtime;
2021-12-24 13:33:09 +08:00
namespace XCharts.Example
{
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Example13_LineSimple : MonoBehaviour
{
2022-05-22 22:17:38 +08:00
void Awake()
{
AddData();
}
2022-04-26 08:24:45 +08:00
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
AddData();
}
}
void AddData()
{
2022-05-22 22:17:38 +08:00
var chart = gameObject.GetComponent<SimplifiedLineChart>();
if (chart == null)
{
2022-05-22 22:17:38 +08:00
chart = gameObject.AddComponent<SimplifiedLineChart>();
2022-03-20 18:52:50 +08:00
chart.Init();
chart.SetSize(580, 300);
}
chart.EnsureChartComponent<Title>().show = true;
chart.EnsureChartComponent<Title>().text = "Line Simple";
chart.EnsureChartComponent<Tooltip>().show = true;
chart.EnsureChartComponent<Legend>().show = false;
var xAxis = chart.EnsureChartComponent<XAxis>();
var yAxis = chart.EnsureChartComponent<YAxis>();
2021-11-23 13:20:07 +08:00
xAxis.show = true;
yAxis.show = true;
xAxis.type = Axis.AxisType.Category;
yAxis.type = Axis.AxisType.Value;
2021-11-23 13:20:07 +08:00
xAxis.splitNumber = 10;
xAxis.boundaryGap = true;
chart.RemoveData();
2022-05-22 22:17:38 +08:00
chart.AddSerie<SimplifiedLine>();
chart.AddSerie<SimplifiedLine>();
2022-03-20 18:52:50 +08:00
for (int i = 0; i < 200; i++)
{
chart.AddXAxisData("x" + i);
chart.AddData(0, Random.Range(10, 20));
chart.AddData(1, Random.Range(10, 20));
}
}
}
}