AirControl  1.3.0
Open Source, Modular, and Extensible Flight Simulator For Deep Learning Research
Example_PieChart.cs
1 /************************************************/
2 /* */
3 /* Copyright (c) 2018 - 2021 monitor1394 */
4 /* https://github.com/monitor1394 */
5 /* */
6 /************************************************/
7 
8 using UnityEngine;
9 
10 namespace XCharts.Examples
11 {
12  [DisallowMultipleComponent]
13  [ExecuteInEditMode]
14  [RequireComponent(typeof(PieChart))]
15  public class Example_PieChart : MonoBehaviour
16  {
17  private PieChart chart;
18  private float time;
19  private int count = 0;
20 
21  private void Awake()
22  {
23  chart = transform.GetComponent<PieChart>();
24  chart.ClearData();
25  }
26 
27  private void Update()
28  {
29  time += Time.deltaTime;
30  if (time > 1)
31  {
32  time = 0;
33  if (count < 5)
34  {
35  chart.AddData(0, Random.Range(10, 100), "time" + count);
36  }
37  else
38  {
39  int index = count % 5;
40  chart.UpdateData(0, Random.Range(10, 100), index);
41  }
42  count++;
43  }
44  }
45  }
46 }
XCharts.BaseChart.ClearData
virtual void ClearData()
Remove all series and legend data. It just emptying all of serie's data without emptying the list of ...
Definition: BaseChart_API.cs:151
XCharts.BaseChart.AddData
virtual SerieData AddData(string serieName, double data, string dataName=null)
Add a data to serie. If serieName doesn't exist in legend,will be add to legend. 添加一个数据到指定的系列中。
Definition: BaseChart_API.cs:237
XCharts.BaseChart.UpdateData
virtual bool UpdateData(string serieName, int dataIndex, double value)
Update serie data by serie name. 更新指定系列中的指定索引数据。
Definition: BaseChart_API.cs:390
XCharts.PieChart
Definition: PieChart.cs:16
XCharts.Examples
Definition: RewardChart.cs:14
XCharts.Examples.Example_PieChart
Definition: Example_PieChart.cs:15