AirControl  1.3.0
Open Source, Modular, and Extensible Flight Simulator For Deep Learning Research
Example_Test.cs
1 /************************************************/
2 /* */
3 /* Copyright (c) 2018 - 2021 monitor1394 */
4 /* https://github.com/monitor1394 */
5 /* */
6 /************************************************/
7 
8 using UnityEngine;
9 using UnityEngine.UI;
10 
11 namespace XCharts.Examples
12 {
13  [DisallowMultipleComponent]
14  [ExecuteInEditMode]
15  public class Example_Test : MonoBehaviour
16  {
17  LineChart chart;
18  void Awake()
19  {
20  chart = gameObject.GetComponent<LineChart>();
21  var btnTrans = transform.parent.Find("Button");
22  if (btnTrans)
23  {
24  btnTrans.gameObject.GetComponent<Button>().onClick.AddListener(OnTestBtn);
25  }
26  }
27 
28  void Update()
29  {
30  if (Input.GetKeyDown(KeyCode.Space))
31  {
32  //AddData();
33  OnTestBtn();
34  }
35  }
36 
37  void OnTestBtn()
38  {
39  int index = Random.Range(0, chart.series.Count);
40  var serie = chart.series.GetSerie(index);
41  chart.UpdateData(index, Random.Range(0, serie.dataCount), Random.Range(50, 100));
42  }
43 
44  void AddData()
45  {
46  chart.ClearData();
47  int count = Random.Range(5, 100);
48  for (int i = 0; i < count; i++)
49  {
50  (chart as CoordinateChart).AddXAxisData("x" + i);
51  if (Random.Range(1, 3) == 2)
52  chart.AddData(0, Random.Range(-110, 200));
53  else
54  chart.AddData(0, Random.Range(-100, 100));
55  }
56  }
57  }
58 }
XCharts.CoordinateChart.ClearData
override void ClearData()
Remove all data from series,legend and axis. It just emptying all of serie's data without emptying th...
Definition: CoordinateChart_API.cs:60
XCharts.LineChart
Definition: LineChart.cs:17
XCharts.Examples
Definition: RewardChart.cs:14
XCharts.Examples.Example_Test
Definition: Example_Test.cs:15
XCharts.CoordinateChart
The basic class of rectangular coordinate chart,such as LineChart,BarChart and ScatterChart....
Definition: CoordinateChart_API.cs:18