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.

Example13_LineSimple.cs 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using UnityEngine;
  2. #if INPUT_SYSTEM_ENABLED
  3. using Input = XCharts.Runtime.InputHelper;
  4. #endif
  5. using XCharts.Runtime;
  6. namespace XCharts.Example
  7. {
  8. [DisallowMultipleComponent]
  9. [ExecuteInEditMode]
  10. public class Example13_LineSimple : MonoBehaviour
  11. {
  12. void Awake()
  13. {
  14. AddData();
  15. }
  16. void Update()
  17. {
  18. if (Input.GetKeyDown(KeyCode.Space))
  19. {
  20. AddData();
  21. }
  22. }
  23. void AddData()
  24. {
  25. var chart = gameObject.GetComponent<SimplifiedLineChart>();
  26. if (chart == null)
  27. {
  28. chart = gameObject.AddComponent<SimplifiedLineChart>();
  29. chart.Init();
  30. chart.SetSize(580, 300);
  31. }
  32. chart.GetOrAddChartComponent<Title>().show = true;
  33. chart.GetOrAddChartComponent<Title>().text = "Line Simple";
  34. chart.GetOrAddChartComponent<Tooltip>().show = true;
  35. chart.GetOrAddChartComponent<Legend>().show = false;
  36. var xAxis = chart.GetOrAddChartComponent<XAxis>();
  37. var yAxis = chart.GetOrAddChartComponent<YAxis>();
  38. xAxis.show = true;
  39. yAxis.show = true;
  40. xAxis.type = Axis.AxisType.Category;
  41. yAxis.type = Axis.AxisType.Value;
  42. xAxis.splitNumber = 10;
  43. xAxis.boundaryGap = true;
  44. chart.RemoveData();
  45. chart.AddSerie<SimplifiedLine>();
  46. chart.AddSerie<SimplifiedLine>();
  47. for (int i = 0; i < 200; i++)
  48. {
  49. chart.AddXAxisData("x" + i);
  50. chart.AddData(0, Random.Range(10, 20));
  51. chart.AddData(1, Random.Range(10, 20));
  52. }
  53. }
  54. }
  55. }