暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

AxisSplitArea.cs 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace XCharts.Runtime
  5. {
  6. /// <summary>
  7. /// Split area of axis in grid area, not shown by default.
  8. /// |坐标轴在 grid 区域中的分隔区域,默认不显示。
  9. /// </summary>
  10. [Serializable]
  11. public class AxisSplitArea : ChildComponent
  12. {
  13. [SerializeField] private bool m_Show;
  14. [SerializeField] private List<Color32> m_Color;
  15. /// <summary>
  16. /// Set this to true to show the splitArea.
  17. /// |是否显示分隔区域。
  18. /// </summary>
  19. public bool show
  20. {
  21. get { return m_Show; }
  22. set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
  23. }
  24. /// <summary>
  25. /// Color of split area. SplitArea color could also be set in color array,
  26. /// which the split lines would take as their colors in turns.
  27. /// Dark and light colors in turns are used by default.
  28. /// |分隔区域颜色。分隔区域会按数组中颜色的顺序依次循环设置颜色。默认是一个深浅的间隔色。
  29. /// </summary>
  30. public List<Color32> color
  31. {
  32. get { return m_Color; }
  33. set { if (value != null) { m_Color = value; SetVerticesDirty(); } }
  34. }
  35. public static AxisSplitArea defaultSplitArea
  36. {
  37. get
  38. {
  39. return new AxisSplitArea()
  40. {
  41. m_Show = false,
  42. m_Color = new List<Color32>() { }
  43. };
  44. }
  45. }
  46. public AxisSplitArea Clone()
  47. {
  48. var axisSplitArea = new AxisSplitArea();
  49. axisSplitArea.show = show;
  50. axisSplitArea.color = new List<Color32>();
  51. ChartHelper.CopyList(axisSplitArea.color, color);
  52. return axisSplitArea;
  53. }
  54. public void Copy(AxisSplitArea splitArea)
  55. {
  56. show = splitArea.show;
  57. color.Clear();
  58. ChartHelper.CopyList(color, splitArea.color);
  59. }
  60. public Color32 GetColor(int index, BaseAxisTheme theme)
  61. {
  62. if (color.Count > 0)
  63. {
  64. var i = index % color.Count;
  65. return color[i];
  66. }
  67. else
  68. {
  69. var i = index % theme.splitAreaColors.Count;
  70. return theme.splitAreaColors[i];
  71. }
  72. }
  73. }
  74. }