AirControl  1.3.0
Open Source, Modular, and Extensible Flight Simulator For Deep Learning Research
Axis.cs
1 /******************************************/
2 /* */
3 /* Copyright (c) 2021 monitor1394 */
4 /* https://github.com/monitor1394 */
5 /* */
6 /******************************************/
7 
8 using System;
9 using System.Collections.Generic;
10 using UnityEngine;
11 using UnityEngine.UI;
12 
13 namespace XCharts
14 {
19  [System.Serializable]
20  public class Axis : MainComponent
21  {
26  public enum AxisType
27  {
32  Value,
37  Category,
42  Log,
47  Time
48  }
49 
54  public enum AxisMinMaxType
55  {
60  Default,
65  MinMax,
70  Custom
71  }
76  public enum AxisPosition
77  {
78  Left,
79  Right,
80  Bottom,
81  Top
82  }
83 
84  [SerializeField] protected bool m_Show = true;
85  [SerializeField] protected AxisType m_Type;
86  [SerializeField] protected AxisMinMaxType m_MinMaxType;
87  [SerializeField] protected int m_GridIndex;
88  [SerializeField] protected int m_PolarIndex;
89  [SerializeField] protected AxisPosition m_Position;
90  [SerializeField] protected float m_Offset;
91  [SerializeField] protected float m_Min;
92  [SerializeField] protected float m_Max;
93  [SerializeField] protected int m_SplitNumber = 5;
94  [SerializeField] protected float m_Interval = 0;
95  [SerializeField] protected bool m_BoundaryGap = true;
96  [SerializeField] protected int m_MaxCache = 0;
97  [SerializeField] protected float m_LogBase = 10;
98  [SerializeField] protected bool m_LogBaseE = false;
99  [SerializeField] protected int m_CeilRate = 0;
100  [SerializeField] protected bool m_Inverse = false;
101  [SerializeField] private bool m_Clockwise = true;
102  [SerializeField] private bool m_InsertDataToHead;
103  [SerializeField] private IconStyle m_IconStyle = new IconStyle();
104  [SerializeField] protected List<Sprite> m_Icons = new List<Sprite>();
105  [SerializeField] protected List<string> m_Data = new List<string>();
106  [SerializeField] protected AxisLine m_AxisLine = AxisLine.defaultAxisLine;
107  [SerializeField] protected AxisName m_AxisName = AxisName.defaultAxisName;
108  [SerializeField] protected AxisTick m_AxisTick = AxisTick.defaultTick;
109  [SerializeField] protected AxisLabel m_AxisLabel = AxisLabel.defaultAxisLabel;
110  [SerializeField] protected AxisSplitLine m_SplitLine = AxisSplitLine.defaultSplitLine;
111  [SerializeField] protected AxisSplitArea m_SplitArea = AxisSplitArea.defaultSplitArea;
112 
113  [NonSerialized] private double m_MinMaxValueRange;
114  [NonSerialized] private bool m_NeedUpdateFilterData;
115 
120  public bool show
121  {
122  get { return m_Show; }
123  set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetAllDirty(); }
124  }
129  public AxisType type
130  {
131  get { return m_Type; }
132  set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetAllDirty(); }
133  }
139  {
140  get { return m_MinMaxType; }
141  set { if (PropertyUtil.SetStruct(ref m_MinMaxType, value)) SetAllDirty(); }
142  }
147  public int gridIndex
148  {
149  get { return m_GridIndex; }
150  set { if (PropertyUtil.SetStruct(ref m_GridIndex, value)) SetAllDirty(); }
151  }
156  public int polarIndex
157  {
158  get { return m_PolarIndex; }
159  set { if (PropertyUtil.SetStruct(ref m_PolarIndex, value)) SetAllDirty(); }
160  }
165  public AxisPosition position
166  {
167  get { return m_Position; }
168  set { if (PropertyUtil.SetStruct(ref m_Position, value)) SetAllDirty(); }
169  }
174  public float offset
175  {
176  get { return m_Offset; }
177  set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetAllDirty(); }
178  }
183  public float min
184  {
185  get { return m_Min; }
186  set { if (PropertyUtil.SetStruct(ref m_Min, value)) SetAllDirty(); }
187  }
192  public float max
193  {
194  get { return m_Max; }
195  set { if (PropertyUtil.SetStruct(ref m_Max, value)) SetAllDirty(); }
196  }
201  public int splitNumber
202  {
203  get { return m_SplitNumber; }
204  set { if (PropertyUtil.SetStruct(ref m_SplitNumber, value)) SetAllDirty(); }
205  }
210  public float interval
211  {
212  get { return m_Interval; }
213  set { if (PropertyUtil.SetStruct(ref m_Interval, value)) SetAllDirty(); }
214  }
219  public bool boundaryGap
220  {
221  get { return IsCategory() ? m_BoundaryGap : false; }
222  set { if (PropertyUtil.SetStruct(ref m_BoundaryGap, value)) SetAllDirty(); }
223  }
228  public float logBase
229  {
230  get { return m_LogBase; }
231  set
232  {
233  if (value <= 0 || value == 1) value = 10;
234  if (PropertyUtil.SetStruct(ref m_LogBase, value)) SetAllDirty();
235  }
236  }
241  public bool logBaseE
242  {
243  get { return m_LogBaseE; }
244  set { if (PropertyUtil.SetStruct(ref m_LogBaseE, value)) SetAllDirty(); }
245  }
251  public int maxCache
252  {
253  get { return m_MaxCache; }
254  set { if (PropertyUtil.SetStruct(ref m_MaxCache, value < 0 ? 0 : value)) SetAllDirty(); }
255  }
260  public int ceilRate
261  {
262  get { return m_CeilRate; }
263  set { if (PropertyUtil.SetStruct(ref m_CeilRate, value < 0 ? 0 : value)) SetAllDirty(); }
264  }
269  public bool inverse
270  {
271  get { return m_Inverse; }
272  set { if (m_Type == AxisType.Value && PropertyUtil.SetStruct(ref m_Inverse, value)) SetAllDirty(); }
273  }
278  public bool clockwise
279  {
280  get { return m_Clockwise; }
281  set { if (PropertyUtil.SetStruct(ref m_Clockwise, value)) SetAllDirty(); }
282  }
287  public List<string> data
288  {
289  get { return m_Data; }
290  set { if (value != null) { m_Data = value; SetAllDirty(); } }
291  }
295  public List<Sprite> icons
296  {
297  get { return m_Icons; }
298  set { if (value != null) { m_Icons = value; SetAllDirty(); } }
299  }
304  public AxisLine axisLine
305  {
306  get { return m_AxisLine; }
307  set { if (value != null) { m_AxisLine = value; SetVerticesDirty(); } }
308  }
313  public AxisName axisName
314  {
315  get { return m_AxisName; }
316  set { if (value != null) { m_AxisName = value; SetComponentDirty(); } }
317  }
322  public AxisTick axisTick
323  {
324  get { return m_AxisTick; }
325  set { if (value != null) { m_AxisTick = value; SetVerticesDirty(); } }
326  }
331  public AxisLabel axisLabel
332  {
333  get { return m_AxisLabel; }
334  set { if (value != null) { m_AxisLabel = value; SetComponentDirty(); } }
335  }
340  public AxisSplitLine splitLine
341  {
342  get { return m_SplitLine; }
343  set { if (value != null) { m_SplitLine = value; SetVerticesDirty(); } }
344  }
349  public AxisSplitArea splitArea
350  {
351  get { return m_SplitArea; }
352  set { if (value != null) { m_SplitArea = value; SetVerticesDirty(); } }
353  }
358  public bool insertDataToHead
359  {
360  get { return m_InsertDataToHead; }
361  set { if (PropertyUtil.SetStruct(ref m_InsertDataToHead, value)) SetAllDirty(); }
362  }
366  public IconStyle iconStyle
367  {
368  get { return m_IconStyle; }
369  set { if (PropertyUtil.SetClass(ref m_IconStyle, value)) SetAllDirty(); }
370  }
371  public override bool vertsDirty
372  {
373  get { return m_VertsDirty || axisLine.anyDirty || axisTick.anyDirty || splitLine.anyDirty || splitArea.anyDirty; }
374  }
375  public override bool componentDirty
376  {
377  get { return m_ComponentDirty || axisName.anyDirty || axisLabel.anyDirty; }
378  }
379  public override void ClearComponentDirty()
380  {
381  base.ClearComponentDirty();
382  axisName.ClearComponentDirty();
383  axisLabel.ClearComponentDirty();
384  }
385 
386  public override void ClearVerticesDirty()
387  {
388  base.ClearVerticesDirty();
389  axisLine.ClearVerticesDirty();
390  axisTick.ClearVerticesDirty();
391  splitLine.ClearVerticesDirty();
392  splitArea.ClearVerticesDirty();
393  }
394  public int index { get; internal set; }
395  public List<ChartLabel> runtimeAxisLabelList { get { return m_AxisLabelList; } set { m_AxisLabelList = value; } }
400  public double runtimeMinValue
401  {
402  get { return m_RuntimeMinValue; }
403  internal set
404  {
405  m_RuntimeMinValue = value;
406  m_RuntimeLastMinValue = value;
407  m_RuntimeMinValueUpdateTime = Time.time;
408  m_RuntimeMinValueChanged = true;
409  }
410  }
415  public double runtimeMaxValue
416  {
417  get { return m_RuntimeMaxValue; }
418  internal set
419  {
420  m_RuntimeMaxValue = value;
421  m_RuntimeLastMaxValue = value;
422  m_RuntimeMaxValueUpdateTime = Time.time;
423  m_RuntimeMaxValueChanged = false;
424  }
425  }
430  public float runtimeZeroXOffset { get; internal set; }
435  public float runtimeZeroYOffset { get; internal set; }
436  public int runtimeMinLogIndex { get { return logBaseE ? (int)Math.Log(runtimeMinValue) : (int)Math.Log(runtimeMinValue, logBase); } }
437  public int runtimeMaxLogIndex { get { return logBaseE ? (int)Math.Log(runtimeMaxValue) : (int)Math.Log(runtimeMaxValue, logBase); } }
438  public bool runtimeLastCheckInverse { get; set; }
439  public double runtimeMinMaxRange { get { return m_MinMaxValueRange; } set { m_MinMaxValueRange = value; } }
440  public List<string> runtimeData { get { return m_RuntimeData; } }
441  public float runtimeScaleWidth { get; internal set; }
442  private int filterStart;
443  private int filterEnd;
444  private int filterMinShow;
445  private List<string> filterData;
446  private List<ChartLabel> m_AxisLabelList = new List<ChartLabel>();
447  private GameObject m_TooltipLabel;
448  private ChartText m_TooltipLabelText;
449  private RectTransform m_TooltipLabelRect;
450  private double m_RuntimeMinValue;
451  private double m_RuntimeLastMinValue;
452  private bool m_RuntimeMinValueChanged;
453  private float m_RuntimeMinValueUpdateTime;
454  private double m_RuntimeMaxValue;
455  private double m_RuntimeLastMaxValue;
456  private bool m_RuntimeMaxValueChanged;
457  private float m_RuntimeMaxValueUpdateTime;
458  private bool m_RuntimeMinValueFirstChanged = true;
459  private bool m_RuntimeMaxValueFirstChanged = true;
460  protected List<string> m_RuntimeData = new List<string>();
461 
462  public Axis Clone()
463  {
464  var axis = new Axis();
465  axis.show = show;
466  axis.type = type;
467  axis.gridIndex = 0;
468  axis.minMaxType = minMaxType;
469  axis.min = min;
470  axis.max = max;
471  axis.splitNumber = splitNumber;
472  axis.interval = interval;
473  axis.boundaryGap = boundaryGap;
474  axis.maxCache = maxCache;
475  axis.logBase = logBase;
476  axis.logBaseE = logBaseE;
477  axis.ceilRate = ceilRate;
478  axis.insertDataToHead = insertDataToHead;
479  axis.iconStyle = iconStyle.Clone();
480  axis.axisLine = axisLine.Clone();
481  axis.axisName = axisName.Clone();
482  axis.axisTick = axisTick.Clone();
483  axis.axisLabel = axisLabel.Clone();
484  axis.splitLine = splitLine.Clone();
485  axis.splitArea = splitArea.Clone();
486  axis.icons = new List<Sprite>();
487  axis.data = new List<string>();
488  ChartHelper.CopyList(axis.data, data);
489  return axis;
490  }
491 
492  public override void SetComponentDirty()
493  {
494  m_NeedUpdateFilterData = true;
495  base.SetComponentDirty();
496  }
497 
498  public void Copy(Axis axis)
499  {
500  show = axis.show;
501  type = axis.type;
502  minMaxType = axis.minMaxType;
503  gridIndex = axis.gridIndex;
504  min = axis.min;
505  max = axis.max;
506  splitNumber = axis.splitNumber;
507  interval = axis.interval;
508  boundaryGap = axis.boundaryGap;
509  maxCache = axis.maxCache;
510  logBase = axis.logBase;
511  logBaseE = axis.logBaseE;
512  ceilRate = axis.ceilRate;
513  insertDataToHead = axis.insertDataToHead;
514  iconStyle.Copy(axis.iconStyle);
515  axisLine.Copy(axis.axisLine);
516  axisName.Copy(axis.axisName);
517  axisTick.Copy(axis.axisTick);
518  axisLabel.Copy(axis.axisLabel);
519  splitLine.Copy(axis.splitLine);
520  splitArea.Copy(axis.splitArea);
521  ChartHelper.CopyList(data, axis.data);
522  ChartHelper.CopyList<Sprite>(icons, axis.icons);
523  }
524 
528  public void ClearData()
529  {
530  m_Data.Clear();
531  m_Icons.Clear();
532  m_RuntimeData.Clear();
533  SetAllDirty();
534  }
535 
540  public bool IsCategory()
541  {
542  return type == AxisType.Category;
543  }
544 
549  public bool IsValue()
550  {
551  return type == AxisType.Value;
552  }
553 
558  public bool IsLog()
559  {
560  return type == AxisType.Log;
561  }
562 
566  public bool IsTime()
567  {
568  return type == AxisType.Time;
569  }
570 
571  public void SetNeedUpdateFilterData()
572  {
573  m_NeedUpdateFilterData = true;
574  }
575 
580  public void AddData(string category)
581  {
582  if (maxCache > 0)
583  {
584  while (m_Data.Count >= maxCache)
585  {
586  m_NeedUpdateFilterData = true;
587  m_Data.RemoveAt(m_InsertDataToHead ? m_Data.Count - 1 : 0);
588  }
589  }
590  if (m_InsertDataToHead) m_Data.Insert(0, category);
591  else m_Data.Add(category);
592  SetAllDirty();
593  }
594 
600  public void UpdateData(int index, string category)
601  {
602  if (index >= 0 && index < m_Data.Count)
603  {
604  m_Data[index] = category;
605  SetComponentDirty();
606  }
607  }
608 
613  public void AddIcon(Sprite icon)
614  {
615  if (maxCache > 0)
616  {
617  while (m_Icons.Count > maxCache)
618  {
619  m_Icons.RemoveAt(m_InsertDataToHead ? m_Icons.Count - 1 : 0);
620  }
621  }
622  if (m_InsertDataToHead) m_Icons.Insert(0, icon);
623  else m_Icons.Add(icon);
624  SetAllDirty();
625  }
626 
632  public void UpdateIcon(int index, Sprite icon)
633  {
634  if (index >= 0 && index < m_Icons.Count)
635  {
636  m_Icons[index] = icon;
637  SetComponentDirty();
638  }
639  }
640 
646  public string GetData(int index)
647  {
648  if (index >= 0 && index < m_Data.Count)
649  return m_Data[index];
650  else
651  return null;
652  }
653 
660  public string GetData(int index, DataZoom dataZoom)
661  {
662  var showData = GetDataList(dataZoom);
663  if (index >= 0 && index < showData.Count)
664  return showData[index];
665  else
666  return "";
667  }
668 
669  public Sprite GetIcon(int index)
670  {
671  if (index >= 0 && index < m_Icons.Count)
672  return m_Icons[index];
673  else
674  return null;
675  }
676 
682  internal List<string> GetDataList(DataZoom dataZoom)
683  {
684  if (dataZoom != null && dataZoom.enable && dataZoom.IsContainsAxis(this))
685  {
686  UpdateFilterData(dataZoom);
687  return filterData;
688  }
689  else
690  {
691  return m_Data.Count > 0 ? m_Data : m_RuntimeData;
692  }
693  }
694 
695  internal List<string> GetDataList()
696  {
697  return m_Data.Count > 0 ? m_Data : m_RuntimeData;
698  }
699 
700  private List<string> emptyFliter = new List<string>();
705  internal void UpdateFilterData(DataZoom dataZoom)
706  {
707  if (dataZoom != null && dataZoom.enable && dataZoom.IsContainsAxis(this))
708  {
709  var data = GetDataList();
710  var range = Mathf.RoundToInt(data.Count * (dataZoom.end - dataZoom.start) / 100);
711  if (range <= 0) range = 1;
712  int start = 0, end = 0;
713  if (dataZoom.runtimeInvert)
714  {
715  end = Mathf.CeilToInt(data.Count * dataZoom.end / 100);
716  start = end - range;
717  if (start < 0) start = 0;
718  }
719  else
720  {
721  start = Mathf.FloorToInt(data.Count * dataZoom.start / 100);
722  end = start + range;
723  if (end > data.Count) end = data.Count;
724  }
725  if (start != filterStart || end != filterEnd || dataZoom.minShowNum != filterMinShow || m_NeedUpdateFilterData)
726  {
727  filterStart = start;
728  filterEnd = end;
729  filterMinShow = dataZoom.minShowNum;
730  m_NeedUpdateFilterData = false;
731  if (data.Count > 0)
732  {
733  if (range < dataZoom.minShowNum)
734  {
735  if (dataZoom.minShowNum > data.Count) range = data.Count;
736  else range = dataZoom.minShowNum;
737  }
738  filterData = data.GetRange(start, range);
739  }
740  else
741  {
742  filterData = data;
743  }
744  }
745  else if (end == 0)
746  {
747  filterData = emptyFliter;
748  }
749  }
750  }
751 
757  internal int GetDataNumber(DataZoom dataZoom)
758  {
759  return GetDataList(dataZoom).Count;
760  }
761 
766  internal void UpdateLabelText(float coordinateWidth, DataZoom dataZoom, bool forcePercent, float duration)
767  {
768  var minValue = GetCurrMinValue(duration);
769  var maxValue = GetCurrMaxValue(duration);
770  for (int i = 0; i < runtimeAxisLabelList.Count; i++)
771  {
772  if (runtimeAxisLabelList[i] != null)
773  {
774  var text = AxisHelper.GetLabelName(this, coordinateWidth, i, minValue, maxValue, dataZoom, forcePercent);
775  runtimeAxisLabelList[i].SetText(text);
776  }
777  }
778  }
779 
780  internal void SetTooltipLabel(GameObject label)
781  {
782  m_TooltipLabel = label;
783  m_TooltipLabelRect = label.GetComponent<RectTransform>();
784  m_TooltipLabelText = new ChartText(label);
785  ChartHelper.SetActive(m_TooltipLabel, true);
786  }
787 
788  internal void SetTooltipLabelColor(Color bgColor, Color textColor)
789  {
790  m_TooltipLabel.GetComponent<Image>().color = bgColor;
791  m_TooltipLabelText.SetColor(textColor);
792  }
793 
794  internal void SetTooltipLabelActive(bool flag)
795  {
796  if (m_TooltipLabel == null) return;
797  ChartHelper.SetActive(m_TooltipLabel, flag);
798  }
799 
800  internal void UpdateTooptipLabelText(string text)
801  {
802  if (m_TooltipLabelText != null)
803  {
804  m_TooltipLabelText.SetText(text);
805  m_TooltipLabelRect.sizeDelta = new Vector2(m_TooltipLabelText.GetPreferredWidth() + 8,
806  m_TooltipLabelText.GetPreferredHeight() + 8);
807  }
808  }
809 
810  internal void UpdateTooltipLabelPos(Vector2 pos)
811  {
812  if (m_TooltipLabel)
813  {
814  m_TooltipLabel.transform.localPosition = pos;
815  }
816  }
817 
818  internal void UpdateMinValue(double value, bool check)
819  {
820  if (value != m_RuntimeMaxValue)
821  {
822  if (check && Application.isPlaying)
823  {
824  if (m_RuntimeMinValueFirstChanged)
825  {
826  m_RuntimeMinValueFirstChanged = false;
827  }
828  else
829  {
830  m_RuntimeLastMinValue = m_RuntimeMinValue;
831  m_RuntimeMinValueChanged = true;
832  m_RuntimeMinValueUpdateTime = Time.time;
833  }
834  m_RuntimeMinValue = value;
835  }
836  else
837  {
838  m_RuntimeMinValue = value;
839  m_RuntimeLastMinValue = value;
840  m_RuntimeMinValueUpdateTime = Time.time;
841  m_RuntimeMinValueChanged = true;
842  }
843  }
844  }
845 
846  internal void UpdateMaxValue(double value, bool check)
847  {
848  if (value != m_RuntimeMaxValue)
849  {
850  if (check && Application.isPlaying)
851  {
852  if (m_RuntimeMaxValueFirstChanged)
853  {
854  m_RuntimeMaxValueFirstChanged = false;
855  }
856  else
857  {
858  m_RuntimeLastMaxValue = m_RuntimeMaxValue;
859  m_RuntimeMaxValueChanged = true;
860  m_RuntimeMaxValueUpdateTime = Time.time;
861  }
862  m_RuntimeMaxValue = value;
863  }
864  else
865  {
866  m_RuntimeMaxValue = value;
867  m_RuntimeLastMaxValue = value;
868  m_RuntimeMaxValueUpdateTime = Time.time;
869  m_RuntimeMaxValueChanged = false;
870  }
871  }
872  }
873 
874  public double GetCurrMinValue(float duration)
875  {
876  if (!Application.isPlaying) return m_RuntimeMinValue;
877  if (m_RuntimeMinValue == 0 && m_RuntimeMaxValue == 0) return 0;
878  if (!m_RuntimeMinValueChanged) return m_RuntimeMinValue;
879  var time = Time.time - m_RuntimeMinValueUpdateTime;
880  if (time == 0) return m_RuntimeMinValue;
881  var total = duration / 1000;
882  if (duration > 0 && time <= total)
883  {
884  var curr = MathUtil.Lerp(m_RuntimeLastMinValue, m_RuntimeMinValue, time / total);
885  return curr;
886  }
887  else
888  {
889  m_RuntimeMinValueChanged = false;
890  return m_RuntimeMinValue;
891  }
892  }
893 
894  public double GetCurrMaxValue(float duration)
895  {
896  if (!Application.isPlaying) return m_RuntimeMaxValue;
897  if (m_RuntimeMinValue == 0 && m_RuntimeMaxValue == 0) return 0;
898  if (!m_RuntimeMaxValueChanged) return m_RuntimeMaxValue;
899  var time = Time.time - m_RuntimeMaxValueUpdateTime;
900  if (time == 0) return m_RuntimeMaxValue;
901  var total = duration / 1000;
902  if (duration > 0 && time < total)
903  {
904  var curr = MathUtil.Lerp(m_RuntimeLastMaxValue, m_RuntimeMaxValue, time / total);
905  return curr;
906  }
907  else
908  {
909  m_RuntimeMaxValueChanged = false;
910  return m_RuntimeMaxValue;
911  }
912  }
913 
914  public bool IsValueChanging(float duration)
915  {
916  if (!Application.isPlaying) return false;
917  if (GetCurrMinValue(duration) != m_RuntimeMinValue || GetCurrMaxValue(duration) != m_RuntimeMaxValue)
918  {
919  return true;
920  }
921  else
922  {
923  return false;
924  }
925  }
926 
927  public float GetLogValue(double value)
928  {
929  if (value <= 0 || value == 1) return 0;
930  return logBaseE ? (float)Math.Log(value) : (float)Math.Log(value, logBase);
931  }
932 
933  public bool IsLeft()
934  {
935  return position == AxisPosition.Left;
936  }
937 
938  public bool IsRight()
939  {
940  return position == AxisPosition.Right;
941  }
942 
943  public bool IsTop()
944  {
945  return position == AxisPosition.Top;
946  }
947 
948  public bool IsBottom()
949  {
950  return position == AxisPosition.Bottom;
951  }
952  }
953 
959  [System.Serializable]
960  public class XAxis : Axis
961  {
962  public static XAxis defaultXAxis
963  {
964  get
965  {
966  var axis = new XAxis
967  {
968  m_Show = true,
969  m_Type = AxisType.Category,
970  m_Min = 0,
971  m_Max = 0,
972  m_SplitNumber = 5,
973  m_BoundaryGap = true,
974  m_Position = AxisPosition.Bottom,
975  m_Offset = 0,
976  m_Data = new List<string>()
977  {
978  "x1","x2","x3","x4","x5"
979  },
980  m_Icons = new List<Sprite>(5),
981  };
982  axis.splitLine.show = false;
983  axis.splitLine.lineStyle.type = LineStyle.Type.None;
984  axis.axisLabel.textLimit.enable = true;
985  return axis;
986  }
987  }
988  }
989 
995  [System.Serializable]
996  public class YAxis : Axis
997  {
998  public static YAxis defaultYAxis
999  {
1000  get
1001  {
1002  var axis = new YAxis
1003  {
1004  m_Show = true,
1005  m_Type = AxisType.Value,
1006  m_Min = 0,
1007  m_Max = 0,
1008  m_SplitNumber = 5,
1009  m_BoundaryGap = false,
1010  m_Position = AxisPosition.Left,
1011  m_Data = new List<string>(5),
1012 
1013  };
1014  axis.splitLine.show = true;
1015  axis.splitLine.lineStyle.type = LineStyle.Type.None;
1016  axis.axisLabel.textLimit.enable = false;
1017  return axis;
1018  }
1019  }
1020  }
1021 
1026  [System.Serializable]
1027  public class RadiusAxis : Axis
1028  {
1029  public static RadiusAxis defaultRadiusAxis
1030  {
1031  get
1032  {
1033  var axis = new RadiusAxis
1034  {
1035  m_Show = true,
1036  m_Type = AxisType.Value,
1037  m_Min = 0,
1038  m_Max = 0,
1039  m_SplitNumber = 5,
1040  m_BoundaryGap = false,
1041  m_Data = new List<string>(5),
1042  };
1043  axis.splitLine.show = true;
1044  axis.splitLine.lineStyle.type = LineStyle.Type.Solid;
1045  axis.axisLabel.textLimit.enable = false;
1046  return axis;
1047  }
1048  }
1049  }
1050 
1055  [System.Serializable]
1056  public class AngleAxis : Axis
1057  {
1058  [SerializeField] private float m_StartAngle = 90;
1059 
1064  public float startAngle
1065  {
1066  get { return m_StartAngle; }
1067  set { if (PropertyUtil.SetStruct(ref m_StartAngle, value)) SetAllDirty(); }
1068  }
1069 
1070  public float runtimeStartAngle { get; set; }
1071 
1072  public static AngleAxis defaultAngleAxis
1073  {
1074  get
1075  {
1076  var axis = new AngleAxis
1077  {
1078  m_Show = true,
1079  m_Type = AxisType.Value,
1080  m_SplitNumber = 12,
1081  m_BoundaryGap = false,
1082  m_Data = new List<string>(12),
1083  };
1084  axis.splitLine.show = true;
1085  axis.splitLine.lineStyle.type = LineStyle.Type.Solid;
1086  axis.axisLabel.textLimit.enable = false;
1087  axis.minMaxType = AxisMinMaxType.Custom;
1088  axis.min = 0;
1089  axis.max = 360;
1090  return axis;
1091  }
1092  }
1093  }
1094 }
XCharts.AngleAxis.startAngle
float startAngle
Starting angle of axis. 90 degrees by default, standing for top position of center....
Definition: Axis.cs:1065
XCharts.Axis.maxCache
int? maxCache
The max number of axis data cache. The first data will be remove when the size of axis data is larger...
Definition: Axis.cs:252
XCharts.Axis.interval
float interval
Compulsively set segmentation interval for axis.This is unavailable for category axis....
Definition: Axis.cs:211
XCharts.Axis.IsValue
bool IsValue()
是否为数值轴。
Definition: Axis.cs:549
XCharts.Axis.inverse
bool inverse
Whether the axis are reversed or not. Invalid in Category axis. 是否反向坐标轴。在类目轴中无效。
Definition: Axis.cs:270
XCharts.Axis.AddIcon
void AddIcon(Sprite icon)
添加图标
Definition: Axis.cs:613
XCharts.SerieType.Custom
@ Custom
自定义。
XCharts.AngleAxis
Angle axis of Polar Coordinate. 极坐标系的角度轴。
Definition: Axis.cs:1056
XCharts.Axis.splitLine
AxisSplitLine splitLine
axis split line. 坐标轴分割线。
Definition: Axis.cs:341
XCharts.Axis.ceilRate
int? ceilRate
The ratio of maximum and minimum values rounded upward. The default is 0, which is automatically calc...
Definition: Axis.cs:261
XCharts.DataZoom
DataZoom component is used for zooming a specific area, which enables user to investigate data in det...
Definition: DataZoom.cs:24
XCharts.Axis.runtimeMinValue
double runtimeMinValue
the current minimun value. 当前最小值。
Definition: Axis.cs:401
XCharts.AxisLabel
Settings related to axis label. 坐标轴刻度标签的相关设置。
Definition: AxisLabel.cs:19
XCharts.Axis.min
float min
The minimun value of axis.Valid when minMaxType is Custom 设定的坐标轴刻度最小值,当minMaxType为Custom时有效。
Definition: Axis.cs:184
XCharts.MainComponent
Definition: ChartComponent.cs:67
XCharts.ChartComponent.anyDirty
bool anyDirty
需要重绘图表或重新初始化组件。
Definition: ChartComponent.cs:29
XCharts.Axis.AddData
void AddData(string category)
添加一个类目到类目数据列表
Definition: Axis.cs:580
XCharts.Axis.axisTick
AxisTick axisTick
axis tick. 坐标轴刻度。
Definition: Axis.cs:323
XCharts.LineStyle.Type
Type
线的类型。
Definition: LineStyle.cs:25
XCharts.Axis.type
AxisType type
the type of axis. 坐标轴类型。
Definition: Axis.cs:130
XCharts.Axis.splitArea
AxisSplitArea splitArea
axis split area. 坐标轴分割区域。
Definition: Axis.cs:350
XCharts.Axis.runtimeZeroXOffset
float runtimeZeroXOffset
the x offset of zero position. 坐标轴原点在X轴的偏移。
Definition: Axis.cs:430
XCharts.Axis.offset
float offset
the offset of axis from the default position. Useful when the same position has multiple axes....
Definition: Axis.cs:175
XCharts.Axis.runtimeMaxValue
double runtimeMaxValue
the current maximum value. 当前最大值。
Definition: Axis.cs:416
XCharts.XAxis
The x axis in cartesian(rectangular) coordinate. a grid component can place at most 2 x axis,...
Definition: Axis.cs:960
XCharts.IconStyle
Definition: IconStyle.cs:14
XCharts.Axis.UpdateData
void UpdateData(int index, string category)
更新类目数据
Definition: Axis.cs:600
XCharts.AxisTick
Settings related to axis tick. 坐标轴刻度相关设置。
Definition: AxisTick.cs:18
XCharts
Definition: RewardChart.cs:14
XCharts.Axis.IsTime
bool IsTime()
是否为时间轴。
Definition: Axis.cs:566
XCharts.Axis
The axis in rectangular coordinate. 直角坐标系的坐标轴组件。
Definition: Axis.cs:20
XCharts.Axis.UpdateIcon
void UpdateIcon(int index, Sprite icon)
更新图标
Definition: Axis.cs:632
XCharts.Axis.GetData
string GetData(int index, DataZoom dataZoom)
获得在dataZoom范围内指定索引的类目数据
Definition: Axis.cs:660
XCharts.Axis.clockwise
bool clockwise
Whether the positive position of axis is in clockwise. True for clockwise by default....
Definition: Axis.cs:279
XCharts.Axis.IsLog
bool IsLog()
是否为对数轴。
Definition: Axis.cs:558
XCharts.LineStyle
The style of line. 线条样式。 注: 修改 lineStyle 中的颜色不会影响图例颜色,如果需要图例颜色和折线图颜色一致,需修改 itemStyle....
Definition: LineStyle.cs:20
XCharts.RadiusAxis
Radial axis of polar coordinate. 极坐标系的径向轴。
Definition: Axis.cs:1027
XCharts.Axis.max
float max
The maximum value of axis.Valid when minMaxType is Custom 设定的坐标轴刻度最大值,当minMaxType为Custom时有效。
Definition: Axis.cs:193
XCharts.Axis.runtimeZeroYOffset
float runtimeZeroYOffset
the y offset of zero position. 坐标轴原点在Y轴的偏移。
Definition: Axis.cs:435
XCharts.Axis.axisLine
AxisLine axisLine
axis Line. 坐标轴轴线。 ///
Definition: Axis.cs:305
XCharts.Axis.insertDataToHead
bool insertDataToHead
Whether to add new data at the head or at the end of the list. 添加新数据时是在列表的头部还是尾部加入。
Definition: Axis.cs:359
XCharts.Axis.GetData
string GetData(int index)
获得指定索引的类目数据
Definition: Axis.cs:646
XCharts.Axis.boundaryGap
bool? boundaryGap
The boundary gap on both sides of a coordinate axis, which is valid only for category axis with type:...
Definition: Axis.cs:220
XCharts.AxisName
the name of axis. 坐标轴名称。
Definition: AxisName.cs:18
XCharts.Axis.show
bool show
Whether to show axis. 是否显示坐标轴。
Definition: Axis.cs:121
XCharts.AxisSplitArea
Split area of axis in grid area, not shown by default. 坐标轴在 grid 区域中的分隔区域,默认不显示。
Definition: AxisSplitArea.cs:19
XCharts.Theme.Default
@ Default
默认主题。
XCharts.Axis.icons
List< Sprite > icons
类目数据对应的图标。
Definition: Axis.cs:296
XCharts.Axis.data
List< string > data
Category data, available in type: 'Category' axis. 类目数据,在类目轴(type: 'category')中有效。
Definition: Axis.cs:288
XCharts.Axis.polarIndex
int polarIndex
The index of the polar on which the axis are located, by default, is in the first polar....
Definition: Axis.cs:157
XCharts.YAxis
The x axis in cartesian(rectangular) coordinate. a grid component can place at most 2 x axis,...
Definition: Axis.cs:996
XCharts.Axis.splitNumber
int splitNumber
Number of segments that the axis is split into. 坐标轴的分割段数。
Definition: Axis.cs:202
XCharts.Axis.minMaxType
AxisMinMaxType minMaxType
the type of axis minmax. 坐标轴刻度最大最小值显示类型。
Definition: Axis.cs:139
XCharts.AxisLine
Settings related to axis line. 坐标轴轴线。
Definition: AxisLine.cs:17
XCharts.BaseLine.show
bool show
Set this to false to prevent the axis line from showing. 是否显示坐标轴轴线。
Definition: BaseLine.cs:27
XCharts.Axis.IsCategory
bool IsCategory()
是否为类目轴。
Definition: Axis.cs:540
XCharts.Axis.axisName
AxisName axisName
axis name. 坐标轴名称。
Definition: Axis.cs:314
XCharts.Axis.position
AxisPosition position
the position of axis in grid. 坐标轴在Grid中的位置。
Definition: Axis.cs:166
XCharts.Axis.AxisType
AxisType
the type of axis. 坐标轴类型。
Definition: Axis.cs:26
XCharts.Axis.AxisPosition
AxisPosition
the position of axis in grid. 坐标轴在Grid中的位置
Definition: Axis.cs:76
XCharts.Axis.gridIndex
int gridIndex
The index of the grid on which the axis are located, by default, is in the first grid....
Definition: Axis.cs:148
XCharts.Axis.logBase
float logBase
Base of logarithm, which is valid only for numeric axes with type: 'Log'. 对数轴的底数,只在对数轴(type:'Log')中有效...
Definition: Axis.cs:229
XCharts.Axis.ClearData
void ClearData()
清空类目数据
Definition: Axis.cs:528
XCharts.Axis.iconStyle
IconStyle iconStyle
图标样式。
Definition: Axis.cs:367
XCharts.Axis.logBaseE
bool logBaseE
On the log axis, if base e is the natural number, and is true, logBase fails. 对数轴是否以自然数 e 为底数,为 true ...
Definition: Axis.cs:242
XCharts.AxisSplitLine
Split line of axis in grid area. 坐标轴在 grid 区域中的分隔线。
Definition: AxisSplitLine.cs:18
XCharts.Axis.AxisMinMaxType
AxisMinMaxType
the type of axis min and max value. 坐标轴最大最小刻度显示类型。
Definition: Axis.cs:54
XCharts.Axis.axisLabel
AxisLabel axisLabel
axis label. 坐标轴刻度标签。
Definition: Axis.cs:332