mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-18 06:20:15 +00:00
增加Demo首页,展示代码控制效果
This commit is contained in:
32
Demo/Scripts/Demo_Test.cs
Normal file
32
Demo/Scripts/Demo_Test.cs
Normal 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user