mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-16 13:30:10 +00:00
3.0 - unitypackage
This commit is contained in:
51
Examples/Runtime/Example_TestTime.cs
Normal file
51
Examples/Runtime/Example_TestTime.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example_TestTime : MonoBehaviour
|
||||
{
|
||||
public int maxCache = 100;
|
||||
LineChart chart;
|
||||
int timestamp;
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<LineChart>();
|
||||
AddData();
|
||||
chart.SetMaxCache(maxCache);
|
||||
}
|
||||
|
||||
float m_LastTime = 0;
|
||||
double m_Value = 100;
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
//AddData();
|
||||
}
|
||||
if (Time.time - m_LastTime > 0.1f)
|
||||
{
|
||||
timestamp += 3600;
|
||||
m_Value += 10;
|
||||
chart.AddData(0, timestamp, m_Value);
|
||||
m_LastTime = Time.time;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void AddData()
|
||||
{
|
||||
chart.ClearData();
|
||||
timestamp = DateTimeUtil.GetTimestamp() - 10;
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
timestamp += i * 3600;
|
||||
double value = Random.Range(50, 200);
|
||||
chart.AddData(0, timestamp, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user