暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Example_AddChart.cs 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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_AddChart : MonoBehaviour
  11. {
  12. BaseChart chart;
  13. void Awake()
  14. {
  15. //AddChart();
  16. }
  17. void Update()
  18. {
  19. if (Input.GetKeyDown(KeyCode.Space))
  20. {
  21. AddChart();
  22. }
  23. }
  24. void AddChart()
  25. {
  26. chart = gameObject.GetComponent<BaseChart>();
  27. if (chart == null)
  28. {
  29. chart = gameObject.AddComponent<LineChart>();
  30. chart.Init();
  31. chart.SetSize(1200, 600);
  32. }
  33. var title = chart.GetOrAddChartComponent<Title>();
  34. title.text = "Simple LineChart";
  35. title.subText = "normal line";
  36. var tooltip = chart.GetOrAddChartComponent<Tooltip>();
  37. tooltip.show = true;
  38. var legend = chart.GetOrAddChartComponent<Legend>();
  39. legend.show = false;
  40. var xAxis = chart.GetOrAddChartComponent<XAxis>();
  41. xAxis.splitNumber = 10;
  42. xAxis.boundaryGap = true;
  43. xAxis.type = Axis.AxisType.Category;
  44. var yAxis = chart.GetOrAddChartComponent<YAxis>();
  45. yAxis.type = Axis.AxisType.Value;
  46. chart.RemoveData();
  47. chart.AddSerie<Line>("line");
  48. for (int i = 0; i < 5; i++)
  49. {
  50. chart.AddXAxisData("x" + i);
  51. chart.AddData(0, Random.Range(10, 20));
  52. }
  53. }
  54. void ModifyComponent()
  55. {
  56. }
  57. }
  58. }