AirControl  1.3.0
Open Source, Modular, and Extensible Flight Simulator For Deep Learning Research
AxisDrawer.cs
1 /************************************************/
2 /* */
3 /* Copyright (c) 2018 - 2021 monitor1394 */
4 /* https://github.com/monitor1394 */
5 /* */
6 /************************************************/
7 
8 using UnityEditor;
9 using UnityEngine;
10 
11 namespace XCharts
12 {
13  [CustomPropertyDrawer(typeof(Axis), true)]
15  {
16  public override string ClassName { get { return "Axis"; } }
17 
18  public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
19  {
20  base.OnGUI(pos, prop, label);
21  if (MakeFoldout(prop, "m_Show"))
22  {
23  SerializedProperty m_Type = prop.FindPropertyRelative("m_Type");
24  SerializedProperty m_LogBase = prop.FindPropertyRelative("m_LogBase");
25  SerializedProperty m_MinMaxType = prop.FindPropertyRelative("m_MinMaxType");
26  Axis.AxisType type = (Axis.AxisType)m_Type.enumValueIndex;
27  var chart = prop.serializedObject.targetObject as BaseChart;
28  var isPolar = chart is PolarChart;
29  EditorGUI.indentLevel++;
30  PropertyField(prop, isPolar ? "m_PolarIndex" : "m_GridIndex");
31  PropertyField(prop, "m_Type");
32  if (type == Axis.AxisType.Time)
33  {
34  var chartTypeName = prop.serializedObject.targetObject.GetType().Name;
35  if (!chartTypeName.Equals("GanttChart"))
36  EditorGUILayout.HelpBox("The Time axis is currently only supported in GanttChart.", MessageType.Warning);
37  }
38  PropertyField(prop, "m_Position");
39  PropertyField(prop, "m_Offset");
40  if (type == Axis.AxisType.Log)
41  {
42  PropertyField(prop, "m_LogBaseE");
43  EditorGUI.BeginChangeCheck();
44  PropertyField(prop, "m_LogBase");
45  if (m_LogBase.floatValue <= 0 || m_LogBase.floatValue == 1)
46  {
47  m_LogBase.floatValue = 10;
48  }
49  EditorGUI.EndChangeCheck();
50  }
51  if (type == Axis.AxisType.Value || type == Axis.AxisType.Time)
52  {
53  PropertyField(prop, "m_MinMaxType");
54  Axis.AxisMinMaxType minMaxType = (Axis.AxisMinMaxType)m_MinMaxType.enumValueIndex;
55  switch (minMaxType)
56  {
57  case Axis.AxisMinMaxType.Default:
58  break;
59  case Axis.AxisMinMaxType.MinMax:
60  break;
61  case Axis.AxisMinMaxType.Custom:
62  EditorGUI.indentLevel++;
63  PropertyField(prop, "m_Min");
64  PropertyField(prop, "m_Max");
65  EditorGUI.indentLevel--;
66  break;
67  }
68  PropertyField(prop, "m_CeilRate");
69  if (type == Axis.AxisType.Value)
70  {
71  PropertyField(prop, "m_Inverse");
72  }
73  }
74  PropertyField(prop, "m_SplitNumber");
75  if (type == Axis.AxisType.Category)
76  {
77  PropertyField(prop, "m_InsertDataToHead");
78  PropertyField(prop, "m_MaxCache");
79  PropertyField(prop, "m_BoundaryGap");
80  }
81  else
82  {
83  PropertyField(prop, "m_Interval");
84  }
85  DrawExtendeds(prop);
86  PropertyField(prop, "m_AxisLine");
87  PropertyField(prop, "m_AxisName");
88  PropertyField(prop, "m_AxisTick");
89  PropertyField(prop, "m_AxisLabel");
90  PropertyField(prop, "m_SplitLine");
91  PropertyField(prop, "m_SplitArea");
92  PropertyField(prop, "m_IconStyle");
93  PropertyListField(prop, "m_Icons", true);
94  if (type == Axis.AxisType.Category)
95  {
96  PropertyListField(prop, "m_Data", true);
97  }
98  EditorGUI.indentLevel--;
99  }
100  }
101  }
102 
103  [CustomPropertyDrawer(typeof(XAxis), true)]
104  public class XAxisDrawer : AxisDrawer
105  {
106  public override string ClassName { get { return "XAxis"; } }
107  }
108 
109  [CustomPropertyDrawer(typeof(YAxis), true)]
110  public class YAxisDrawer : AxisDrawer
111  {
112  public override string ClassName { get { return "YAxis"; } }
113  }
114 
115  [CustomPropertyDrawer(typeof(AngleAxis), true)]
117  {
118  public override string ClassName { get { return "AngleAxis"; } }
119  protected override void DrawExtendeds(SerializedProperty prop)
120  {
121  base.DrawExtendeds(prop);
122  PropertyField(prop, "m_StartAngle");
123  PropertyField(prop, "m_Clockwise");
124  }
125  }
126 
127  [CustomPropertyDrawer(typeof(RadiusAxis), true)]
129  {
130  public override string ClassName { get { return "RadiusAxis"; } }
131  }
132 
133  [CustomPropertyDrawer(typeof(AxisLabel), true)]
135  {
136  public override string ClassName { get { return "AxisLabel"; } }
137  public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
138  {
139  base.OnGUI(pos, prop, label);
140  if (MakeFoldout(prop, "m_Show"))
141  {
142  ++EditorGUI.indentLevel;
143  PropertyField(prop, "m_Inside");
144  PropertyField(prop, "m_Interval");
145  PropertyField(prop, "m_Margin");
146  PropertyField(prop, "m_Width");
147  PropertyField(prop, "m_Height");
148  PropertyField(prop, "m_Formatter");
149  PropertyField(prop, "m_NumericFormatter");
150  PropertyField(prop, "m_ShowAsPositiveNumber");
151  PropertyField(prop, "m_OnZero");
152  PropertyField(prop, "m_ShowStartLabel");
153  PropertyField(prop, "m_ShowEndLabel");
154  PropertyField(prop, "m_TextLimit");
155  PropertyField(prop, "m_TextStyle");
156  --EditorGUI.indentLevel;
157  }
158  }
159  }
160 
161  [CustomPropertyDrawer(typeof(AxisName), true)]
163  {
164  public override string ClassName { get { return "AxisName"; } }
165  public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
166  {
167  base.OnGUI(pos, prop, label);
168  if (MakeFoldout(prop, "m_Show"))
169  {
170  ++EditorGUI.indentLevel;
171  PropertyField(prop, "m_Name");
172  PropertyField(prop, "m_Location");
173  PropertyField(prop, "m_TextStyle");
174  --EditorGUI.indentLevel;
175  }
176  }
177  }
178 
179  [CustomPropertyDrawer(typeof(AxisSplitArea), true)]
181  {
182  public override string ClassName { get { return "SplitArea"; } }
183  public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
184  {
185  base.OnGUI(pos, prop, label);
186  if (MakeFoldout(prop, "m_Show"))
187  {
188  ++EditorGUI.indentLevel;
189  PropertyField(prop, "m_Color");
190  --EditorGUI.indentLevel;
191  }
192  }
193  }
194 }
XCharts.BasePropertyDrawer
Definition: BasePropertyDrawer.cs:15
XCharts.AngleAxis
Angle axis of Polar Coordinate. 极坐标系的角度轴。
Definition: Axis.cs:1056
XCharts.AxisLabel
Settings related to axis label. 坐标轴刻度标签的相关设置。
Definition: AxisLabel.cs:19
XCharts.AxisLabelDrawer
Definition: AxisDrawer.cs:134
XCharts.AxisNameDrawer
Definition: AxisDrawer.cs:162
XCharts.XAxis
The x axis in cartesian(rectangular) coordinate. a grid component can place at most 2 x axis,...
Definition: Axis.cs:960
XCharts
Definition: RewardChart.cs:14
XCharts.XAxisDrawer
Definition: AxisDrawer.cs:104
XCharts.Axis
The axis in rectangular coordinate. 直角坐标系的坐标轴组件。
Definition: Axis.cs:20
XCharts.RadiusAxis
Radial axis of polar coordinate. 极坐标系的径向轴。
Definition: Axis.cs:1027
XCharts.AxisName
the name of axis. 坐标轴名称。
Definition: AxisName.cs:18
XCharts.AxisSplitArea
Split area of axis in grid area, not shown by default. 坐标轴在 grid 区域中的分隔区域,默认不显示。
Definition: AxisSplitArea.cs:19
XCharts.AngleAxisDrawer
Definition: AxisDrawer.cs:116
XCharts.RadiusAxisDrawer
Definition: AxisDrawer.cs:128
XCharts.YAxis
The x axis in cartesian(rectangular) coordinate. a grid component can place at most 2 x axis,...
Definition: Axis.cs:996
XCharts.SerieSymbolType.Rect
@ Rect
正方形。可通过设置itemStyle的cornerRadius变成圆角矩形。
XCharts.YAxisDrawer
Definition: AxisDrawer.cs:110
XCharts.AxisSplitAreaDrawer
Definition: AxisDrawer.cs:180
XCharts.Axis.AxisType
AxisType
the type of axis. 坐标轴类型。
Definition: Axis.cs:26
XCharts.BaseChart
The base class of all charts. 所有Chart的基类。
Definition: BaseChart_API.cs:21
XCharts.PolarChart
Definition: PolarChart.cs:20
XCharts.AxisDrawer
Definition: AxisDrawer.cs:14
XCharts.Axis.AxisMinMaxType
AxisMinMaxType
the type of axis min and max value. 坐标轴最大最小刻度显示类型。
Definition: Axis.cs:54