Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. using UnityEngine;
  2. namespace XCharts.Runtime
  3. {
  4. /// <summary>
  5. /// 标域类型
  6. /// </summary>
  7. public enum MarkAreaType
  8. {
  9. None,
  10. /// <summary>
  11. /// 最小值。
  12. /// </summary>
  13. Min,
  14. /// <summary>
  15. /// 最大值。
  16. /// </summary>
  17. Max,
  18. /// <summary>
  19. /// 平均值。
  20. /// </summary>
  21. Average,
  22. /// <summary>
  23. /// 中位数。
  24. /// </summary>
  25. Median
  26. }
  27. /// <summary>
  28. /// Used to mark an area in chart. For example, mark a time interval.
  29. /// |图表标域,常用于标记图表中某个范围的数据。
  30. /// </summary>
  31. [System.Serializable]
  32. [ComponentHandler(typeof(MarkAreaHandler), true)]
  33. public class MarkArea : MainComponent
  34. {
  35. [SerializeField] private bool m_Show = true;
  36. [SerializeField] private string m_Text = "";
  37. [SerializeField] private int m_SerieIndex = 0;
  38. [SerializeField] private MarkAreaData m_Start = new MarkAreaData();
  39. [SerializeField] private MarkAreaData m_End = new MarkAreaData();
  40. [SerializeField] private ItemStyle m_ItemStyle = new ItemStyle();
  41. [SerializeField] private LabelStyle m_Label = new LabelStyle();
  42. public ChartLabel runtimeLabel { get; internal set; }
  43. public Vector3 runtimeLabelPosition { get; internal set; }
  44. public Rect runtimeRect { get; internal set; }
  45. /// <summary>
  46. /// 是否显示标域。
  47. /// </summary>
  48. public bool show
  49. {
  50. get { return m_Show; }
  51. set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
  52. }
  53. /// <summary>
  54. /// The text of markArea.
  55. /// 标域显示的文本。
  56. /// </summary>
  57. public string text
  58. {
  59. get { return m_Text; }
  60. set { if (PropertyUtil.SetClass(ref m_Text, value)) SetComponentDirty(); }
  61. }
  62. /// <summary>
  63. /// Serie index of markArea.
  64. /// 标域影响的Serie索引。
  65. /// </summary>
  66. public int serieIndex
  67. {
  68. get { return m_SerieIndex; }
  69. set { if (PropertyUtil.SetStruct(ref m_SerieIndex, value)) SetVerticesDirty(); }
  70. }
  71. /// <summary>
  72. /// 标域范围的起始数据。
  73. /// </summary>
  74. public MarkAreaData start
  75. {
  76. get { return m_Start; }
  77. set { if (PropertyUtil.SetClass(ref m_Start, value)) SetVerticesDirty(); }
  78. }
  79. /// <summary>
  80. /// 标域范围的结束数据。
  81. /// </summary>
  82. public MarkAreaData end
  83. {
  84. get { return m_End; }
  85. set { if (PropertyUtil.SetClass(ref m_End, value)) SetVerticesDirty(); }
  86. }
  87. /// <summary>
  88. /// 标域样式。
  89. /// </summary>
  90. public ItemStyle itemStyle
  91. {
  92. get { return m_ItemStyle; }
  93. set { if (PropertyUtil.SetClass(ref m_ItemStyle, value)) SetVerticesDirty(); }
  94. }
  95. /// <summary>
  96. /// 标域文本样式。
  97. /// </summary>
  98. public LabelStyle label
  99. {
  100. get { return m_Label; }
  101. set { if (PropertyUtil.SetClass(ref m_Label, value)) SetComponentDirty(); }
  102. }
  103. public override void SetDefaultValue()
  104. {
  105. m_ItemStyle = new ItemStyle();
  106. m_ItemStyle.opacity = 0.6f;
  107. m_Label = new LabelStyle();
  108. m_Label.show = true;
  109. }
  110. }
  111. /// <summary>
  112. /// 标域的数据。
  113. /// </summary>
  114. [System.Serializable]
  115. public class MarkAreaData : ChildComponent
  116. {
  117. [SerializeField] private MarkAreaType m_Type = MarkAreaType.None;
  118. [SerializeField] private string m_Name;
  119. [SerializeField] private int m_Dimension = 1;
  120. [SerializeField] private float m_XPosition;
  121. [SerializeField] private float m_YPosition;
  122. [SerializeField] private double m_XValue;
  123. [SerializeField] private double m_YValue;
  124. public double runtimeValue { get; internal set; }
  125. /// <summary>
  126. /// Name of the marker, which will display as a label.
  127. /// |标注名称。会作为文字显示。
  128. /// </summary>
  129. public string name
  130. {
  131. get { return m_Name; }
  132. set { if (PropertyUtil.SetClass(ref m_Name, value)) SetVerticesDirty(); }
  133. }
  134. /// <summary>
  135. /// Special markArea types, are used to label maximum value, minimum value and so on.
  136. /// |特殊的标域类型,用于标注最大值最小值等。
  137. /// </summary>
  138. public MarkAreaType type
  139. {
  140. get { return m_Type; }
  141. set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
  142. }
  143. /// <summary>
  144. /// From which dimension of data to calculate the maximum and minimum value and so on.
  145. /// |从哪个维度的数据计算最大最小值等。
  146. /// </summary>
  147. public int dimension
  148. {
  149. get { return m_Dimension; }
  150. set { if (PropertyUtil.SetStruct(ref m_Dimension, value)) SetVerticesDirty(); }
  151. }
  152. /// <summary>
  153. /// The x coordinate relative to the origin, in pixels.
  154. /// |相对原点的 x 坐标,单位像素。当type为None时有效。
  155. /// </summary>
  156. public float xPosition
  157. {
  158. get { return m_XPosition; }
  159. set { if (PropertyUtil.SetStruct(ref m_XPosition, value)) SetVerticesDirty(); }
  160. }
  161. /// <summary>
  162. /// The y coordinate relative to the origin, in pixels.
  163. /// |相对原点的 y 坐标,单位像素。当type为None时有效。
  164. /// </summary>
  165. public float yPosition
  166. {
  167. get { return m_YPosition; }
  168. set { if (PropertyUtil.SetStruct(ref m_YPosition, value)) SetVerticesDirty(); }
  169. }
  170. /// <summary>
  171. /// The value specified on the X-axis. A value specified when the X-axis is the category axis represents the index of the category axis data, otherwise a specific value.
  172. /// |X轴上的指定值。当X轴为类目轴时指定值表示类目轴数据的索引,否则为具体的值。当type为None时有效。
  173. /// </summary>
  174. public double xValue
  175. {
  176. get { return m_XValue; }
  177. set { if (PropertyUtil.SetStruct(ref m_XValue, value)) SetVerticesDirty(); }
  178. }
  179. /// <summary>
  180. /// That's the value on the Y-axis. The value specified when the Y axis is the category axis represents the index of the category axis data, otherwise the specific value.
  181. /// |Y轴上的指定值。当Y轴为类目轴时指定值表示类目轴数据的索引,否则为具体的值。当type为None时有效。
  182. /// </summary>
  183. public double yValue
  184. {
  185. get { return m_YValue; }
  186. set { if (PropertyUtil.SetStruct(ref m_YValue, value)) SetVerticesDirty(); }
  187. }
  188. }
  189. }