Aucune description
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Example21_BarRace.cs 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System.Collections;
  2. using UnityEngine;
  3. using XCharts.Runtime;
  4. namespace XCharts.Example
  5. {
  6. [DisallowMultipleComponent]
  7. public class Example21_BarRace : MonoBehaviour
  8. {
  9. private BarChart chart;
  10. private float lastTime;
  11. void Awake()
  12. {
  13. chart = gameObject.GetComponent<BarChart>();
  14. chart.ClearData();
  15. for (int i = 0; i < 5; i++)
  16. {
  17. chart.AddYAxisData("y" + i);
  18. chart.AddData(0, Random.Range(0, 200));
  19. }
  20. }
  21. void Update()
  22. {
  23. if (Time.time - lastTime >= 3f)
  24. {
  25. lastTime = Time.time;
  26. UpdateData();
  27. }
  28. }
  29. void UpdateData()
  30. {
  31. var serie = chart.GetSerie(0);
  32. for (int i = 0; i < serie.dataCount; i++)
  33. {
  34. if (Random.Range(0, 1f) > 0.9f)
  35. chart.UpdateData(0, i, chart.GetData(0, i) + Mathf.Round(Random.Range(0, 2000)));
  36. else
  37. chart.UpdateData(0, i, chart.GetData(0, i) + Mathf.Round(Random.Range(0, 200)));
  38. }
  39. }
  40. }
  41. }