mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-15 04:20:09 +00:00
3.0
This commit is contained in:
59
Examples/Example13_LineSimple.cs
Normal file
59
Examples/Example13_LineSimple.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example13_LineSimple : MonoBehaviour
|
||||
{
|
||||
void Awake()
|
||||
{
|
||||
AddData();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
AddData();
|
||||
}
|
||||
}
|
||||
|
||||
void AddData()
|
||||
{
|
||||
var chart = gameObject.GetComponent<SimplifiedLineChart>();
|
||||
if (chart == null)
|
||||
{
|
||||
chart = gameObject.AddComponent<SimplifiedLineChart>();
|
||||
chart.Init();
|
||||
chart.SetSize(580, 300);
|
||||
}
|
||||
chart.GetOrAddChartComponent<Title>().show = true;
|
||||
chart.GetOrAddChartComponent<Title>().text = "Line Simple";
|
||||
|
||||
chart.GetOrAddChartComponent<Tooltip>().show = true;
|
||||
chart.GetOrAddChartComponent<Legend>().show = false;
|
||||
|
||||
var xAxis = chart.GetOrAddChartComponent<XAxis>();
|
||||
var yAxis = chart.GetOrAddChartComponent<YAxis>();
|
||||
xAxis.show = true;
|
||||
yAxis.show = true;
|
||||
xAxis.type = Axis.AxisType.Category;
|
||||
yAxis.type = Axis.AxisType.Value;
|
||||
|
||||
xAxis.splitNumber = 10;
|
||||
xAxis.boundaryGap = true;
|
||||
|
||||
chart.RemoveData();
|
||||
chart.AddSerie<SimplifiedLine>();
|
||||
chart.AddSerie<SimplifiedLine>();
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user