mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 17:30:10 +00:00
整理代码结构,支持Package Manager添加
This commit is contained in:
41
Demo/Runtime/Demo_Test.cs
Normal file
41
Demo/Runtime/Demo_Test.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace 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