No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Example_TestTime.cs 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using UnityEngine;
  2. using XCharts.Runtime;
  3. #if INPUT_SYSTEM_ENABLED
  4. using Input = XCharts.Runtime.InputHelper;
  5. #endif
  6. namespace XCharts.Example
  7. {
  8. [DisallowMultipleComponent]
  9. [ExecuteInEditMode]
  10. public class Example_TestTime : MonoBehaviour
  11. {
  12. public int maxCache = 100;
  13. LineChart chart;
  14. int timestamp;
  15. void Awake()
  16. {
  17. chart = gameObject.GetComponent<LineChart>();
  18. AddData();
  19. chart.SetMaxCache(maxCache);
  20. }
  21. float m_LastTime = 0;
  22. double m_Value = 100;
  23. void Update()
  24. {
  25. if (Input.GetKeyDown(KeyCode.Space))
  26. {
  27. //AddData();
  28. }
  29. if (Time.time - m_LastTime > 0.1f)
  30. {
  31. timestamp += 3600;
  32. m_Value += 10;
  33. chart.AddData(0, timestamp, m_Value);
  34. m_LastTime = Time.time;
  35. }
  36. }
  37. void AddData()
  38. {
  39. chart.ClearData();
  40. timestamp = DateTimeUtil.GetTimestamp() - 10;
  41. for (int i = 0; i < 10; i++)
  42. {
  43. timestamp += i * 3600;
  44. double value = Random.Range(50, 200);
  45. chart.AddData(0, timestamp, value);
  46. }
  47. }
  48. }
  49. }