SerieTheme.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 Color32 m_CandlestickColor = new Color32(235, 84, 84, 255);
  12. [SerializeField] protected Color32 m_CandlestickColor0 = new Color32(71, 178, 98, 255);
  13. [SerializeField] protected float m_CandlestickBorderWidth = 1;
  14. [SerializeField] protected Color32 m_CandlestickBorderColor = new Color32(235, 84, 84, 255);
  15. [SerializeField] protected Color32 m_CandlestickBorderColor0 = new Color32(71, 178, 98, 255);
  16. /// <summary>
  17. /// the color of text.
  18. /// ||文本颜色。
  19. /// </summary>
  20. public float lineWidth
  21. {
  22. get { return m_LineWidth; }
  23. set { if (PropertyUtil.SetStruct(ref m_LineWidth, value)) SetVerticesDirty(); }
  24. }
  25. /// <summary>
  26. /// the symbol size of line serie.
  27. /// ||折线图的Symbol大小。
  28. /// </summary>
  29. public float lineSymbolSize
  30. {
  31. get { return m_LineSymbolSize; }
  32. set { if (PropertyUtil.SetStruct(ref m_LineSymbolSize, value)) SetVerticesDirty(); }
  33. }
  34. /// <summary>
  35. /// the symbol size of scatter serie.
  36. /// ||散点图的Symbol大小。
  37. /// </summary>
  38. public float scatterSymbolSize
  39. {
  40. get { return m_ScatterSymbolSize; }
  41. set { if (PropertyUtil.SetStruct(ref m_ScatterSymbolSize, value)) SetVerticesDirty(); }
  42. }
  43. /// <summary>
  44. /// K线图阳线(涨)填充色
  45. /// </summary>
  46. public Color32 candlestickColor
  47. {
  48. get { return m_CandlestickColor; }
  49. set { if (PropertyUtil.SetColor(ref m_CandlestickColor, value)) SetVerticesDirty(); }
  50. }
  51. /// <summary>
  52. /// K线图阴线(跌)填充色
  53. /// </summary>
  54. public Color32 candlestickColor0
  55. {
  56. get { return m_CandlestickColor0; }
  57. set { if (PropertyUtil.SetColor(ref m_CandlestickColor0, value)) SetVerticesDirty(); }
  58. }
  59. /// <summary>
  60. /// K线图阳线(跌)边框色
  61. /// </summary>
  62. public Color32 candlestickBorderColor
  63. {
  64. get { return m_CandlestickBorderColor; }
  65. set { if (PropertyUtil.SetColor(ref m_CandlestickBorderColor, value)) SetVerticesDirty(); }
  66. }
  67. /// <summary>
  68. /// K线图阴线(跌)边框色
  69. /// </summary>
  70. public Color32 candlestickBorderColor0
  71. {
  72. get { return m_CandlestickBorderColor0; }
  73. set { if (PropertyUtil.SetColor(ref m_CandlestickBorderColor0, value)) SetVerticesDirty(); }
  74. }
  75. /// <summary>
  76. /// K线图边框宽度
  77. /// </summary>
  78. public float candlestickBorderWidth
  79. {
  80. get { return m_CandlestickBorderWidth; }
  81. set { if (PropertyUtil.SetStruct(ref m_CandlestickBorderWidth, value < 0 ? 0f : value)) SetVerticesDirty(); }
  82. }
  83. public void Copy(SerieTheme theme)
  84. {
  85. m_LineWidth = theme.lineWidth;
  86. m_LineSymbolSize = theme.lineSymbolSize;
  87. m_ScatterSymbolSize = theme.scatterSymbolSize;
  88. m_CandlestickColor = theme.candlestickColor;
  89. m_CandlestickColor0 = theme.candlestickColor0;
  90. m_CandlestickBorderColor = theme.candlestickBorderColor;
  91. m_CandlestickBorderColor0 = theme.candlestickBorderColor0;
  92. m_CandlestickBorderWidth = theme.candlestickBorderWidth;
  93. }
  94. public SerieTheme(ThemeType theme)
  95. {
  96. m_LineWidth = XCSettings.serieLineWidth;
  97. m_LineSymbolSize = XCSettings.serieLineSymbolSize;
  98. m_ScatterSymbolSize = XCSettings.serieScatterSymbolSize;
  99. m_CandlestickBorderWidth = XCSettings.serieCandlestickBorderWidth;
  100. switch (theme)
  101. {
  102. case ThemeType.Default:
  103. m_CandlestickColor = ColorUtil.GetColor("#eb5454");
  104. m_CandlestickColor0 = ColorUtil.GetColor("#47b262");
  105. m_CandlestickBorderColor = ColorUtil.GetColor("#eb5454");
  106. m_CandlestickBorderColor0 = ColorUtil.GetColor("#47b262");
  107. break;
  108. case ThemeType.Light:
  109. m_CandlestickColor = ColorUtil.GetColor("#eb5454");
  110. m_CandlestickColor0 = ColorUtil.GetColor("#47b262");
  111. m_CandlestickBorderColor = ColorUtil.GetColor("#eb5454");
  112. m_CandlestickBorderColor0 = ColorUtil.GetColor("#47b262");
  113. break;
  114. case ThemeType.Dark:
  115. m_CandlestickColor = ColorUtil.GetColor("#f64e56");
  116. m_CandlestickColor0 = ColorUtil.GetColor("#54ea92");
  117. m_CandlestickBorderColor = ColorUtil.GetColor("#f64e56");
  118. m_CandlestickBorderColor0 = ColorUtil.GetColor("#54ea92");
  119. break;
  120. }
  121. }
  122. }
  123. }