8 using System.Collections;
9 using System.Collections.Generic;
14 [DisallowMultipleComponent]
18 private float speed = 100f;
25 private void OnEnable()
33 StartCoroutine(CheatSheet());
36 IEnumerator CheatSheet()
38 StartCoroutine(InitChart());
39 StartCoroutine(ComponentTitle());
40 yield
return new WaitForSeconds(2);
41 StartCoroutine(ComponentAxis());
42 yield
return new WaitForSeconds(2);
43 StartCoroutine(ComponentGrid());
44 yield
return new WaitForSeconds(2);
45 StartCoroutine(ComponentSerie());
46 yield
return new WaitForSeconds(4);
47 StartCoroutine(ComponentLegend());
48 yield
return new WaitForSeconds(4);
50 yield
return new WaitForSeconds(4);
51 StartCoroutine(ComponentDataZoom());
52 yield
return new WaitForSeconds(5);
53 StartCoroutine(ComponentVisualMap());
54 yield
return new WaitForSeconds(3);
58 IEnumerator InitChart()
60 chart = gameObject.GetComponent<
LineChart>();
61 if (chart ==
null) gameObject.AddComponent<
LineChart>();
63 chart.title.show =
true;
64 chart.title.text =
"术语解析-组件";
70 chart.dataZooms[0].enable =
false;
71 chart.visualMap.enable =
false;
78 for (
int i = 0; i < 8; i++)
81 chart.AddData(0, Random.Range(10, 100));
82 chart.AddData(1, Random.Range(30, 100));
87 IEnumerator ComponentTitle()
89 chart.title.text =
"术语解析 - 组件";
90 chart.title.subText =
"Title 标题:可指定主标题和子标题";
93 chart.series.list[0].show =
false;
94 chart.series.list[1].show =
false;
95 chart.legend.show =
false;
96 for (
int i = 0; i < 4; i++)
98 chart.title.show = !chart.title.show;
100 yield
return new WaitForSeconds(0.2f);
102 chart.title.show =
true;
103 chart.RefreshChart();
106 IEnumerator ComponentAxis()
108 chart.title.subText =
"Axis 坐标轴:配置X和Y轴的轴线、刻度、标签等样式外观配置";
109 chart.series.list[0].show =
false;
110 chart.series.list[1].show =
false;
111 for (
int i = 0; i < 4; i++)
115 chart.RefreshChart();
116 yield
return new WaitForSeconds(0.2f);
120 chart.RefreshChart();
121 yield
return new WaitForSeconds(1f);
124 IEnumerator ComponentGrid()
126 chart.title.subText =
"Grid 网格:调整坐标系边距和颜色等";
127 for (
int i = 0; i < 4; i++)
130 chart.RefreshChart();
131 yield
return new WaitForSeconds(0.2f);
134 chart.RefreshChart();
135 yield
return new WaitForSeconds(1f);
138 IEnumerator ComponentSerie()
140 chart.title.subText =
"Serie 系列:调整坐标系边距和颜色等";
141 chart.series.list[0].show =
true;
142 chart.series.list[1].show =
true;
143 chart.AnimationReset();
144 chart.RefreshChart();
145 yield
return new WaitForSeconds(1.2f);
146 for (
int i = 0; i < 4; i++)
148 chart.series.list[0].show = !chart.series.list[0].show;
149 chart.series.list[1].show = !chart.series.list[1].show;
150 chart.RefreshChart();
151 yield
return new WaitForSeconds(0.2f);
153 chart.series.list[0].show =
true;
154 chart.series.list[1].show =
true;
155 chart.RefreshChart();
156 yield
return new WaitForSeconds(1f);
159 IEnumerator ComponentLegend()
161 chart.title.subText =
"Legend 图例:展示不同系列的名字和颜色,可控制系列显示等";
162 chart.legend.show =
true;
164 chart.legend.location.top = 50;
165 chart.RefreshChart();
166 yield
return new WaitForSeconds(1f);
167 for (
int i = 0; i < 4; i++)
169 chart.legend.show = !chart.legend.show;
170 chart.RefreshChart();
171 yield
return new WaitForSeconds(0.2f);
173 chart.legend.show =
true;
174 chart.RefreshChart();
175 yield
return new WaitForSeconds(1f);
176 chart.ClickLegendButton(0,
"Line",
false);
177 yield
return new WaitForSeconds(0.2f);
178 chart.ClickLegendButton(0,
"Line",
true);
179 yield
return new WaitForSeconds(0.5f);
181 chart.ClickLegendButton(1,
"Bar",
false);
182 yield
return new WaitForSeconds(0.2f);
183 chart.ClickLegendButton(1,
"Bar",
true);
184 yield
return new WaitForSeconds(0.5f);
189 chart.title.subText =
"Theme 主题:可从全局上配置图表的颜色、字体等效果,支持默认主题切换";
190 yield
return new WaitForSeconds(1f);
191 chart.title.subText =
"Theme 主题:Light主题";
192 chart.UpdateTheme(
Theme.Light);
193 yield
return new WaitForSeconds(1f);
194 chart.title.subText =
"Theme 主题:Dark主题";
195 chart.UpdateTheme(
Theme.Dark);
196 yield
return new WaitForSeconds(1f);
197 chart.title.subText =
"Theme 主题:Default主题";
198 chart.UpdateTheme(
Theme.Default);
199 yield
return new WaitForSeconds(1f);
202 IEnumerator ComponentDataZoom()
204 chart.title.subText =
"DataZoom 区域缩放:可通过拖、拽、缩小、放大来观察细节数据";
207 chart.dataZooms[0].enable =
true;
208 chart.dataZooms[0].supportInside =
true;
209 chart.dataZooms[0].supportSlider =
true;
210 chart.dataZooms[0].start = 0;
211 chart.dataZooms[0].end = 100;
213 chart.RefreshChart();
214 for (
int i = 0; i < 4; i++)
216 chart.dataZooms[0].supportSlider = !chart.dataZooms[0].supportSlider;
217 chart.RefreshChart();
218 yield
return new WaitForSeconds(0.2f);
220 chart.dataZooms[0].supportSlider =
true;
221 chart.RefreshChart();
222 yield
return new WaitForSeconds(1f);
223 while (chart.dataZooms[0].start < 40)
225 chart.dataZooms[0].start += speed * Time.deltaTime * 0.8f;
227 chart.RefreshChart();
230 while (chart.dataZooms[0].end > 60)
232 chart.dataZooms[0].end -= speed * Time.deltaTime * 0.8f;
234 chart.RefreshChart();
237 while (chart.dataZooms[0].start > 0)
239 chart.dataZooms[0].start -= speed * Time.deltaTime * 0.8f;
240 chart.dataZooms[0].end -= speed * Time.deltaTime * 0.8f;
242 chart.RefreshChart();
245 while (chart.dataZooms[0].end < 100)
247 chart.dataZooms[0].start += speed * Time.deltaTime * 0.8f;
248 chart.dataZooms[0].end += speed * Time.deltaTime * 0.8f;
250 chart.RefreshChart();
253 while (chart.dataZooms[0].start > 0 || chart.dataZooms[0].end < 100)
255 chart.dataZooms[0].start -= speed * Time.deltaTime * 0.8f;
256 chart.dataZooms[0].end += speed * Time.deltaTime * 0.8f;
258 chart.RefreshChart();
263 IEnumerator ComponentVisualMap()
265 chart.title.subText =
"VisualMap 视觉映射:可从全局上配置图表的颜色、字体等效果,支持默认主题切换";
267 chart.visualMap.enable =
true;
268 chart.visualMap.show =
true;
269 chart.visualMap.orient =
Orient.Vertical;
270 chart.visualMap.calculable =
true;
271 chart.visualMap.min = 0;
272 chart.visualMap.max = 100;
273 chart.visualMap.range[0] = 0;
274 chart.visualMap.range[1] = 100;
276 var colors =
new List<string>{
"#313695",
"#4575b4",
"#74add1",
"#abd9e9",
"#e0f3f8",
"#ffffbf",
277 "#fee090",
"#fdae61",
"#f46d43",
"#d73027",
"#a50026"};
278 chart.visualMap.inRange.Clear();
279 foreach (var str
in colors)
285 chart.RefreshChart();
287 yield
return new WaitForSeconds(1f);
288 while (chart.visualMap.rangeMin < 40)
290 chart.visualMap.rangeMin += speed * Time.deltaTime;
291 chart.RefreshChart();
294 while (chart.visualMap.rangeMax > 60)
296 chart.visualMap.rangeMax -= speed * Time.deltaTime;
297 chart.RefreshChart();
300 while (chart.visualMap.rangeMin > 0 || chart.visualMap.rangeMax < 100)
302 chart.visualMap.rangeMin -= speed * Time.deltaTime;
303 chart.visualMap.rangeMax += speed * Time.deltaTime;
304 chart.RefreshChart();