AirControl  1.3.0
Open Source, Modular, and Extensible Flight Simulator For Deep Learning Research
Example12_CustomDrawing.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 using XUGL;
11 
12 
13 namespace XCharts.Examples
14 {
15  [DisallowMultipleComponent]
16  [ExecuteInEditMode]
17  public class Example12_CustomDrawing : MonoBehaviour
18  {
19  LineChart chart;
20  void Awake()
21  {
22  chart = gameObject.GetComponent<LineChart>();
23  if (chart == null) return;
24 
25  chart.onCustomDraw = delegate (VertexHelper vh)
26  {
27  };
28  // or
29  chart.onCustomDrawBeforeSerie = delegate (VertexHelper vh, Serie serie)
30  {
31  };
32  // or
33  chart.onCustomDrawAfterSerie = delegate (VertexHelper vh, Serie serie)
34  {
35  if (serie.index != 0) return;
36  var dataPoints = serie.dataPoints;
37  if (dataPoints.Count > 0)
38  {
39  var pos = dataPoints[3];
40  var zeroPos = new Vector3(chart.grid.runtimeX, chart.grid.runtimeY);
41  var startPos = new Vector3(pos.x, zeroPos.y);
42  var endPos = new Vector3(pos.x, zeroPos.y + chart.grid.runtimeHeight);
43  UGL.DrawLine(vh, startPos, endPos, chart.theme.serie.lineWidth, Color.blue);
44  UGL.DrawCricle(vh, pos, 5, Color.blue);
45  }
46  };
47  // or
48  chart.onCustomDrawTop = delegate (VertexHelper vh)
49  {
50  };
51  }
52  }
53 }
XCharts.Serie.dataPoints
List< Vector3 > dataPoints
数据项位置坐标。
Definition: Serie.cs:1159
XCharts.Serie.index
int index
The index of serie,start at 0. 系列的索引,从0开始。
Definition: Serie.cs:1145
XCharts.Examples.Example12_CustomDrawing
Definition: Example12_CustomDrawing.cs:17
XCharts.LineChart
Definition: LineChart.cs:17
XCharts.Serie
系列。每个系列通过 type 决定自己的图表类型。
Definition: Serie.cs:261
XUGL
Definition: UGL.cs:12
XCharts.Examples
Definition: RewardChart.cs:14
XCharts.CoordinateChart.grid
Grid? grid
grid component. 网格组件。
Definition: CoordinateChart_API.cs:24