2019-10-22 04:09:04 +08:00
|
|
|
using UnityEngine;
|
2023-01-30 10:41:41 +08:00
|
|
|
#if INPUT_SYSTEM_ENABLED
|
|
|
|
|
using Input = XCharts.Runtime.InputHelper;
|
|
|
|
|
#endif
|
2022-02-19 22:37:57 +08:00
|
|
|
using XCharts.Runtime;
|
2019-10-22 04:09:04 +08:00
|
|
|
|
2021-12-24 13:33:09 +08:00
|
|
|
namespace XCharts.Example
|
2019-10-22 04:09:04 +08:00
|
|
|
{
|
|
|
|
|
[DisallowMultipleComponent]
|
|
|
|
|
[ExecuteInEditMode]
|
2020-05-15 06:52:40 +08:00
|
|
|
public class Example13_LineSimple : MonoBehaviour
|
2019-10-22 04:09:04 +08:00
|
|
|
{
|
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()
|
2019-10-22 04:09:04 +08:00
|
|
|
{
|
2022-05-22 22:17:38 +08:00
|
|
|
var chart = gameObject.GetComponent<SimplifiedLineChart>();
|
2019-10-22 04:09:04 +08:00
|
|
|
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);
|
2019-10-22 04:09:04 +08:00
|
|
|
}
|
2022-03-20 18:52:50 +08:00
|
|
|
chart.GetOrAddChartComponent<Title>().show = true;
|
|
|
|
|
chart.GetOrAddChartComponent<Title>().text = "Line Simple";
|
2019-10-22 04:09:04 +08:00
|
|
|
|
2022-03-20 18:52:50 +08:00
|
|
|
chart.GetOrAddChartComponent<Tooltip>().show = true;
|
|
|
|
|
chart.GetOrAddChartComponent<Legend>().show = false;
|
2019-10-22 04:09:04 +08:00
|
|
|
|
2022-03-20 18:52:50 +08:00
|
|
|
var xAxis = chart.GetOrAddChartComponent<XAxis>();
|
|
|
|
|
var yAxis = chart.GetOrAddChartComponent<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;
|
2019-10-22 04:09:04 +08:00
|
|
|
|
2021-11-23 13:20:07 +08:00
|
|
|
xAxis.splitNumber = 10;
|
|
|
|
|
xAxis.boundaryGap = true;
|
2019-10-22 04:09:04 +08:00
|
|
|
|
|
|
|
|
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++)
|
2019-10-22 04:09:04 +08:00
|
|
|
{
|
|
|
|
|
chart.AddXAxisData("x" + i);
|
|
|
|
|
chart.AddData(0, Random.Range(10, 20));
|
2020-03-05 20:25:19 +08:00
|
|
|
chart.AddData(1, Random.Range(10, 20));
|
2019-10-22 04:09:04 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|