AirControl  1.3.0
Open Source, Modular, and Extensible Flight Simulator For Deep Learning Research
Example40_Radar.cs
1 /************************************************/
2 /* */
3 /* Copyright (c) 2018 - 2021 monitor1394 */
4 /* https://github.com/monitor1394 */
5 /* */
6 /************************************************/
7 
8 using System.Collections;
9 using System.Collections.Generic;
10 using UnityEngine;
11 
12 namespace XCharts.Examples
13 {
14  [DisallowMultipleComponent]
15  public class Example40_Radar : MonoBehaviour
16  {
17  private RadarChart chart;
18  private Serie serie, serie1;
19  void Awake()
20  {
21  LoopDemo();
22  }
23 
24  private void OnEnable()
25  {
26  LoopDemo();
27  }
28 
29  void LoopDemo()
30  {
31  StopAllCoroutines();
32  StartCoroutine(RadarDemo());
33  }
34 
35  IEnumerator RadarDemo()
36  {
37  StartCoroutine(RadarAdd());
38  yield return new WaitForSeconds(2);
39  StartCoroutine(RadarUpdate());
40  yield return new WaitForSeconds(2);
41  StartCoroutine(RadarAddMultiple());
42  yield return new WaitForSeconds(2);
43  LoopDemo();
44  }
45 
46  IEnumerator RadarAdd()
47  {
48  chart = gameObject.GetComponent<RadarChart>();
49  if (chart == null) chart = gameObject.AddComponent<RadarChart>();
50  chart.RemoveRadar();
51  chart.RemoveData();
52 
53  chart.title.text = "RadarChart - 雷达图";
54  chart.title.subText = "";
55 
56  chart.legend.show = true;
57  chart.legend.location.align = Location.Align.TopLeft;
58  chart.legend.location.top = 60;
59  chart.legend.location.left = 2;
60  chart.legend.itemWidth = 70;
61  chart.legend.itemHeight = 20;
62  chart.legend.orient = Orient.Vertical;
63 
64  chart.AddRadar(Radar.Shape.Polygon, new Vector2(0.5f, 0.4f), 0.4f);
65  chart.AddIndicator(0, "indicator1", 0, 100);
66  chart.AddIndicator(0, "indicator2", 0, 100);
67  chart.AddIndicator(0, "indicator3", 0, 100);
68  chart.AddIndicator(0, "indicator4", 0, 100);
69  chart.AddIndicator(0, "indicator5", 0, 100);
70 
71  serie = chart.AddSerie(SerieType.Radar, "test");
72  serie.radarIndex = 0;
73  chart.AddData(0, new List<double> { 10, 20, 60, 40, 20 }, "data1");
74  chart.AddData(0, new List<double> { 40, 60, 90, 80, 70 }, "data2");
75  yield return new WaitForSeconds(1);
76  }
77 
78  IEnumerator RadarUpdate()
79  {
80  chart.UpdateIndicator(0, 0, "new1", 0, 100);
81  chart.UpdateData(0, 0, new List<double> { 15, 30, 50, 60, 50 });
82  chart.UpdateDataName(0, 0, "new1");
83  yield return new WaitForSeconds(1);
84  }
85 
86  IEnumerator RadarAddMultiple()
87  {
88  chart.RemoveRadar();
89  chart.RemoveData();
90 
91  chart.title.text = "RadarChart - 多雷达图";
92  chart.title.subText = "";
93 
94  chart.legend.show = true;
95  chart.legend.location.align = Location.Align.TopLeft;
96  chart.legend.location.top = 60;
97  chart.legend.location.left = 2;
98  chart.legend.itemWidth = 70;
99  chart.legend.itemHeight = 20;
100  chart.legend.orient = Orient.Vertical;
101 
102  chart.AddRadar(Radar.Shape.Polygon, new Vector2(0.25f, 0.4f), 0.25f);
103  for (int i = 1; i <= 5; i++)
104  {
105  chart.AddIndicator(0, "radar1" + i, 0, 100);
106  }
107 
108  chart.AddRadar(Radar.Shape.Circle, new Vector2(0.75f, 0.4f), 0.25f);
109  for (int i = 1; i <= 5; i++)
110  {
111  chart.AddIndicator(1, "radar2" + i, 0, 100);
112  }
113 
114  serie = chart.AddSerie(SerieType.Radar, "test1");
115  serie.radarIndex = 0;
116  chart.AddData(0, new List<double> { 10, 20, 60, 40, 20 }, "data1");
117 
118  serie1 = chart.AddSerie(SerieType.Radar, "test2");
119  serie1.radarIndex = 1;
120  chart.AddData(1, new List<double> { 10, 20, 60, 40, 20 }, "data2");
121  yield return new WaitForSeconds(1);
122  }
123  }
124 }
XCharts.Orient
Orient
the layout is horizontal or vertical. 垂直还是水平布局方式。
Definition: BaseChart.cs:22
XCharts.Examples.Example40_Radar
Definition: Example40_Radar.cs:15
XCharts.Title.text
string text
The main title text, supporting for newlines. 主标题文本,支持使用 换行。
Definition: Title.cs:38
XCharts.Serie.radarIndex
int radarIndex
Index of radar component that radar chart uses. 雷达图所使用的 radar 组件的 index。
Definition: Serie.cs:436
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.Location.Align
Align
对齐方式
Definition: Location.cs:26
XCharts.Location
Location type. Quick to set the general location. 位置类型。通过Align快速设置大体位置,再通过left,right,top,bottom微调具体位置...
Definition: Location.cs:21
XCharts.SerieType
SerieType
the type of serie. 系列类型。
Definition: Serie.cs:19
XCharts.BaseChart.UpdateDataName
virtual bool UpdateDataName(string serieName, int dataIndex, string dataName)
Update serie data name. 更新指定系列中的指定索引数据名称。
Definition: BaseChart_API.cs:490
XCharts.BaseChart.UpdateIndicator
bool UpdateIndicator(int radarIndex, int indicatorIndex, string name, float min, float max)
更新指示器。
Definition: RadarChart_API.cs:107
XCharts.Radar.Shape
Shape
Radar render type, in which 'Polygon' and 'Circle' are supported. 雷达图绘制类型,支持 'Polygon' 和 'Circle'。
Definition: Radar.cs:27
XCharts.Radar
Radar coordinate conponnet for radar charts. 雷达图坐标系组件,只适用于雷达图。
Definition: Radar.cs:21
XCharts.Legend.show
bool show
Whether to show legend component. 是否显示图例组件。
Definition: Legend.cs:95
XCharts.Legend.location
Location location
The location of legend. 图例显示的位置。 [default:Location.defaultTop]
Definition: Legend.cs:135
XCharts.BaseChart.UpdateData
virtual bool UpdateData(string serieName, int dataIndex, double value)
Update serie data by serie name. 更新指定系列中的指定索引数据。
Definition: BaseChart_API.cs:390
XCharts.Location.top
float top
Distance between component and the left side of the container. 离容器上侧的距离。
Definition: Location.cs:84
XCharts.Title.subText
string subText
Subtitle text, supporting for for newlines. 副标题文本,支持使用 换行。
Definition: Title.cs:53
XCharts.Legend.orient
Orient orient
Specify whether the layout of legend component is horizontal or vertical. 布局方式是横还是竖。 [default:Orient....
Definition: Legend.cs:125
XCharts.Serie
系列。每个系列通过 type 决定自己的图表类型。
Definition: Serie.cs:261
XCharts.Location.left
float left
Distance between component and the left side of the container. 离容器左侧的距离。
Definition: Location.cs:66
XCharts.Examples
Definition: RewardChart.cs:14
XCharts.Legend.itemHeight
float itemHeight
Image height of legend symbol. 图例标记的图形高度。 [default:12f]
Definition: Legend.cs:155
XCharts.BaseChart.AddSerie
virtual Serie AddSerie(SerieType type, string serieName=null, bool show=true, bool addToHead=false)
Add a serie to serie list. 添加一个系列到系列列表中。
Definition: BaseChart_API.cs:199
XCharts.BaseChart.AddRadar
void AddRadar(Radar radar)
添加雷达坐标系组件。
Definition: RadarChart_API.cs:43
XCharts.BaseChart.legend
Legend? legend
The legend setting of chart. 图例组件
Definition: BaseChart_API.cs:55
XCharts.BaseChart.RemoveRadar
void RemoveRadar()
移除所有雷达坐标系组件。
Definition: RadarChart_API.cs:24
XCharts.RadarChart
Definition: RadarChart.cs:17
XCharts.BaseChart.title
Title? title
The title setting of chart. 标题组件
Definition: BaseChart_API.cs:49
XCharts.Location.align
Align align
对齐方式。
Definition: Location.cs:57
XCharts.Legend.itemWidth
float itemWidth
Image width of legend symbol. 图例标记的图形宽度。 [default:24f]
Definition: Legend.cs:145
XCharts.BaseChart.RemoveData
virtual void RemoveData()
Remove all data from series and legend. The series list is also cleared. 清除所有系列和图例数据,系列的列表也会被清除。
Definition: BaseChart_API.cs:166