AirControl  1.3.0
Open Source, Modular, and Extensible Flight Simulator For Deep Learning Research
Example11_AddSinCurve.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  public class Example11_AddSinCurve : MonoBehaviour
15  {
16  private float time;
17  public int angle;
18  private LineChart chart;
19 
20  void Awake()
21  {
22  chart = gameObject.GetComponent<LineChart>();
23  if (chart == null)
24  {
25  chart = gameObject.AddComponent<LineChart>();
26  }
27  chart.title.show = true;
28  chart.title.text = "Sin Curve";
29 
30  chart.tooltip.show = true;
31  chart.legend.show = false;
32 
33  chart.xAxes[0].show = true;
34  chart.xAxes[1].show = false;
35  chart.yAxes[0].show = true;
36  chart.yAxes[1].show = false;
37 
38  chart.xAxes[0].type = Axis.AxisType.Value;
39  chart.yAxes[0].type = Axis.AxisType.Value;
40 
41  chart.xAxes[0].boundaryGap = false;
42  chart.xAxes[0].maxCache = 0;
43  chart.series.list[0].maxCache = 0;
44 
45  chart.RemoveData();
46 
47  var serie = chart.AddSerie(SerieType.Line);
48  serie.symbol.show = false;
49  serie.lineType = LineType.Normal;
50  for (angle = 0; angle < 1080; angle++)
51  {
52  float xvalue = Mathf.PI / 180 * angle;
53  float yvalue = Mathf.Sin(xvalue);
54  chart.AddData(0, xvalue, yvalue);
55  }
56  }
57 
58  void Update()
59  {
60  if (angle > 3000) return;
61  angle++;
62  float xvalue = Mathf.PI / 180 * angle;
63  float yvalue = Mathf.Sin(xvalue);
64  chart.AddData(0, xvalue, yvalue);
65  }
66  }
67 }
XCharts.CoordinateChart.RemoveData
override void RemoveData()
Remove all data from series,legend and axis. The series list is also cleared. 清空所有图例,系列和坐标轴类目数据。系列的列表...
Definition: CoordinateChart_API.cs:71
XCharts.SerieType
SerieType
the type of serie. 系列类型。
Definition: Serie.cs:19
XCharts.Examples.Example11_AddSinCurve
Definition: Example11_AddSinCurve.cs:14
XCharts.LineType
LineType
the type of line chart. 折线图样式类型
Definition: Serie.cs:99
XCharts.Axis
The axis in rectangular coordinate. 直角坐标系的坐标轴组件。
Definition: Axis.cs:20
XCharts.LineChart
Definition: LineChart.cs:17
XCharts.CoordinateChart.yAxes
List< YAxis > yAxes
the y Axes, yAxes[0] is the first y axis, yAxes[1] is the second y axis. 两个y轴。
Definition: CoordinateChart_API.cs:35
XCharts.Examples
Definition: RewardChart.cs:14
XCharts.CoordinateChart.xAxes
List< XAxis > xAxes
the x Axes,xAxes[0] is the first x axis, xAxes[1] is the second x axis. 两个x轴。
Definition: CoordinateChart_API.cs:30
XCharts.Axis.AxisType
AxisType
the type of axis. 坐标轴类型。
Definition: Axis.cs:26