説明なし
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

SerieTheme.cs 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. using System;
  2. using UnityEngine;
  3. namespace XCharts.Runtime
  4. {
  5. [Serializable]
  6. public class SerieTheme : ChildComponent
  7. {
  8. [SerializeField] protected float m_LineWidth;
  9. [SerializeField] protected float m_LineSymbolSize;
  10. [SerializeField] protected float m_ScatterSymbolSize;
  11. [SerializeField] protected float m_PieTooltipExtraRadius;
  12. [SerializeField] protected float m_SelectedRate = 1.3f;
  13. [SerializeField] protected float m_PieSelectedOffset;
  14. [SerializeField] protected Color32 m_CandlestickColor = new Color32(235, 84, 84, 255);
  15. [SerializeField] protected Color32 m_CandlestickColor0 = new Color32(71, 178, 98, 255);
  16. [SerializeField] protected float m_CandlestickBorderWidth = 1;
  17. [SerializeField] protected Color32 m_CandlestickBorderColor = new Color32(235, 84, 84, 255);
  18. [SerializeField] protected Color32 m_CandlestickBorderColor0 = new Color32(71, 178, 98, 255);
  19. /// <summary>
  20. /// the color of text.
  21. /// |文本颜色。
  22. /// </summary>
  23. public float lineWidth
  24. {
  25. get { return m_LineWidth; }
  26. set { if (PropertyUtil.SetStruct(ref m_LineWidth, value)) SetVerticesDirty(); }
  27. }
  28. /// <summary>
  29. /// the symbol size of line serie.
  30. /// |折线图的Symbol大小。
  31. /// </summary>
  32. public float lineSymbolSize
  33. {
  34. get { return m_LineSymbolSize; }
  35. set { if (PropertyUtil.SetStruct(ref m_LineSymbolSize, value)) SetVerticesDirty(); }
  36. }
  37. /// <summary>
  38. /// the selected symbol size of line serie.
  39. /// |折线图Symbol在被选中状态时的大小。
  40. /// </summary>
  41. public float lineSymbolSelectedSize { get { return lineSymbolSize * selectedRate; } }
  42. /// <summary>
  43. /// the symbol size of scatter serie.
  44. /// |散点图的Symbol大小。
  45. /// </summary>
  46. public float scatterSymbolSize
  47. {
  48. get { return m_ScatterSymbolSize; }
  49. set { if (PropertyUtil.SetStruct(ref m_ScatterSymbolSize, value)) SetVerticesDirty(); }
  50. }
  51. /// <summary>
  52. /// the selected symbol size of scatter serie.
  53. /// |散点图的Symbol在被选中状态时的大小。
  54. /// </summary>
  55. public float scatterSymbolSelectedSize { get { return scatterSymbolSize * selectedRate; } }
  56. /// <summary>
  57. /// the rate of symbol size of line or scatter serie.
  58. /// |折线图或散点图在被选中时的放大倍数。
  59. /// </summary>
  60. public float selectedRate
  61. {
  62. get { return m_SelectedRate; }
  63. set { if (PropertyUtil.SetStruct(ref m_SelectedRate, value)) SetVerticesDirty(); }
  64. }
  65. /// <summary>
  66. /// the extra radius of pie when actived by tooltip.
  67. /// |饼图鼠标移到高亮时的额外半径
  68. /// </summary>
  69. public float pieTooltipExtraRadius
  70. {
  71. get { return m_PieTooltipExtraRadius; }
  72. set { if (PropertyUtil.SetStruct(ref m_PieTooltipExtraRadius, value < 0 ? 0f : value)) SetVerticesDirty(); }
  73. }
  74. /// <summary>
  75. /// the center offset of pie if selected.
  76. /// |饼图选中时的中心点偏移。
  77. /// </summary>
  78. public float pieSelectedOffset
  79. {
  80. get { return m_PieSelectedOffset; }
  81. set { if (PropertyUtil.SetStruct(ref m_PieSelectedOffset, value < 0 ? 0f : value)) SetVerticesDirty(); }
  82. }
  83. /// <summary>
  84. /// K线图阳线(涨)填充色
  85. /// </summary>
  86. public Color32 candlestickColor
  87. {
  88. get { return m_CandlestickColor; }
  89. set { if (PropertyUtil.SetColor(ref m_CandlestickColor, value)) SetVerticesDirty(); }
  90. }
  91. /// <summary>
  92. /// K线图阴线(跌)填充色
  93. /// </summary>
  94. public Color32 candlestickColor0
  95. {
  96. get { return m_CandlestickColor0; }
  97. set { if (PropertyUtil.SetColor(ref m_CandlestickColor0, value)) SetVerticesDirty(); }
  98. }
  99. /// <summary>
  100. /// K线图阳线(跌)边框色
  101. /// </summary>
  102. public Color32 candlestickBorderColor
  103. {
  104. get { return m_CandlestickBorderColor; }
  105. set { if (PropertyUtil.SetColor(ref m_CandlestickBorderColor, value)) SetVerticesDirty(); }
  106. }
  107. /// <summary>
  108. /// K线图阴线(跌)边框色
  109. /// </summary>
  110. public Color32 candlestickBorderColor0
  111. {
  112. get { return m_CandlestickBorderColor0; }
  113. set { if (PropertyUtil.SetColor(ref m_CandlestickBorderColor0, value)) SetVerticesDirty(); }
  114. }
  115. /// <summary>
  116. /// K线图边框宽度
  117. /// </summary>
  118. public float candlestickBorderWidth
  119. {
  120. get { return m_CandlestickBorderWidth; }
  121. set { if (PropertyUtil.SetStruct(ref m_CandlestickBorderWidth, value < 0 ? 0f : value)) SetVerticesDirty(); }
  122. }
  123. public void Copy(SerieTheme theme)
  124. {
  125. m_LineWidth = theme.lineWidth;
  126. m_LineSymbolSize = theme.lineSymbolSize;
  127. m_ScatterSymbolSize = theme.scatterSymbolSize;
  128. selectedRate = theme.selectedRate;
  129. m_PieTooltipExtraRadius = theme.pieTooltipExtraRadius;
  130. m_PieSelectedOffset = theme.pieSelectedOffset;
  131. m_CandlestickColor = theme.candlestickColor;
  132. m_CandlestickColor0 = theme.candlestickColor0;
  133. m_CandlestickBorderColor = theme.candlestickBorderColor;
  134. m_CandlestickBorderColor0 = theme.candlestickBorderColor0;
  135. m_CandlestickBorderWidth = theme.candlestickBorderWidth;
  136. }
  137. public SerieTheme(ThemeType theme)
  138. {
  139. m_LineWidth = XCSettings.serieLineWidth;
  140. m_LineSymbolSize = XCSettings.serieLineSymbolSize;
  141. m_ScatterSymbolSize = XCSettings.serieScatterSymbolSize;
  142. m_PieTooltipExtraRadius = XCSettings.pieTooltipExtraRadius;
  143. m_PieSelectedOffset = XCSettings.pieSelectedOffset;
  144. m_CandlestickBorderWidth = XCSettings.serieCandlestickBorderWidth;
  145. switch (theme)
  146. {
  147. case ThemeType.Default:
  148. m_CandlestickColor = ColorUtil.GetColor("#eb5454");
  149. m_CandlestickColor0 = ColorUtil.GetColor("#47b262");
  150. m_CandlestickBorderColor = ColorUtil.GetColor("#eb5454");
  151. m_CandlestickBorderColor0 = ColorUtil.GetColor("#47b262");
  152. break;
  153. case ThemeType.Light:
  154. m_CandlestickColor = ColorUtil.GetColor("#eb5454");
  155. m_CandlestickColor0 = ColorUtil.GetColor("#47b262");
  156. m_CandlestickBorderColor = ColorUtil.GetColor("#eb5454");
  157. m_CandlestickBorderColor0 = ColorUtil.GetColor("#47b262");
  158. break;
  159. case ThemeType.Dark:
  160. m_CandlestickColor = ColorUtil.GetColor("#f64e56");
  161. m_CandlestickColor0 = ColorUtil.GetColor("#54ea92");
  162. m_CandlestickBorderColor = ColorUtil.GetColor("#f64e56");
  163. m_CandlestickBorderColor0 = ColorUtil.GetColor("#54ea92");
  164. break;
  165. }
  166. }
  167. }
  168. }