Files
XCharts/Demo/Scripts/Demo_LargeData.cs

46 lines
1.3 KiB
C#
Raw Normal View History

using UnityEngine;
using XCharts;
2019-05-17 04:57:46 +08:00
[DisallowMultipleComponent]
[ExecuteInEditMode]
[RequireComponent(typeof(CoordinateChart))]
public class Demo_LargeData : MonoBehaviour
{
public int maxCacheDataNumber = 3000;
public float initDataTime = 5;
private CoordinateChart chart;
private float initTime;
2019-05-24 09:51:45 +08:00
private int initCount = 0;
private System.DateTime timeNow;
void Awake()
{
chart = gameObject.GetComponentInChildren<CoordinateChart>();
timeNow = System.DateTime.Now;
2019-07-13 16:38:38 +08:00
chart.ClearAxisData();
chart.series.ClearData();
2019-08-04 23:39:50 +08:00
chart.maxCacheDataNumber = 0;
chart.title.text = maxCacheDataNumber + "数据";
}
2019-08-04 23:39:50 +08:00
private void Update()
{
2019-06-21 09:34:33 +08:00
if (initCount < maxCacheDataNumber)
{
2019-08-04 23:39:50 +08:00
for (int i = 0; i < 10; i++)
{
2019-05-24 09:51:45 +08:00
initCount++;
if (initCount > maxCacheDataNumber) break;
2019-08-04 23:39:50 +08:00
chart.title.text = initCount+"数据";
timeNow = timeNow.AddSeconds(1);
float xvalue = Mathf.PI / 180 * initCount;
float yvalue = Mathf.Sin(xvalue);
2019-08-04 23:39:50 +08:00
chart.AddData(0, 15 + yvalue * 2);
chart.AddXAxisData(timeNow.ToString("hh:mm:ss"));
}
}
}
}