增加Demo首页,展示代码控制效果

This commit is contained in:
monitor1394
2019-10-16 18:46:31 +08:00
parent 620cdf78c7
commit 6b66b5a129
7 changed files with 210686 additions and 19467 deletions

32
Demo/Scripts/Demo_Test.cs Normal file
View File

@@ -0,0 +1,32 @@
using UnityEngine;
using UnityEngine.UI;
using XCharts;
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Demo_Test : MonoBehaviour
{
LineChart chart;
void Awake()
{
chart = gameObject.GetComponent<LineChart>();
if (chart == null)
{
chart = gameObject.AddComponent<LineChart>();
}
var buttom = transform.parent.gameObject.GetComponentInChildren<Button>();
buttom.onClick.AddListener(AddData);
}
void AddData()
{
chart.series.list[0].ClearData();
chart.series.list[1].ClearData();
for (int i = 0; i < 5; i++)
{
chart.AddData(0, Random.Range(20, 100));
chart.AddData(1, Random.Range(1, 10));
}
}
}