Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

AxisTick.cs 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using UnityEngine;
  2. namespace XCharts.Runtime
  3. {
  4. /// <summary>
  5. /// Settings related to axis tick.
  6. /// |坐标轴刻度相关设置。
  7. /// </summary>
  8. [System.Serializable]
  9. public class AxisTick : BaseLine
  10. {
  11. [SerializeField] private bool m_AlignWithLabel;
  12. [SerializeField] private bool m_Inside;
  13. [SerializeField] private bool m_ShowStartTick;
  14. [SerializeField] private bool m_ShowEndTick;
  15. [SerializeField] private float m_Distance;
  16. [SerializeField] protected int m_SplitNumber = 0;
  17. [SerializeField] private bool m_AutoColor;
  18. /// <summary>
  19. /// The distance between the tick line and axis line.
  20. /// |刻度线与轴线的距离。
  21. /// </summary>
  22. public float distance { get { return m_Distance; } set { m_Distance = value; } }
  23. /// <summary>
  24. /// Align axis tick with label, which is available only when boundaryGap is set to be true in category axis.
  25. /// |类目轴中在 boundaryGap 为 true 的时候有效,可以保证刻度线和标签对齐。
  26. /// </summary>
  27. public bool alignWithLabel
  28. {
  29. get { return m_AlignWithLabel; }
  30. set { if (PropertyUtil.SetStruct(ref m_AlignWithLabel, value)) SetVerticesDirty(); }
  31. }
  32. /// <summary>
  33. /// Set this to true so the axis labels face the inside direction.
  34. /// |坐标轴刻度是否朝内,默认朝外。
  35. /// </summary>
  36. public bool inside
  37. {
  38. get { return m_Inside; }
  39. set { if (PropertyUtil.SetStruct(ref m_Inside, value)) SetVerticesDirty(); }
  40. }
  41. /// <summary>
  42. /// Whether to display the first tick.
  43. /// |是否显示第一个刻度。
  44. /// </summary>
  45. public bool showStartTick
  46. {
  47. get { return m_ShowStartTick; }
  48. set { if (PropertyUtil.SetStruct(ref m_ShowStartTick, value)) SetVerticesDirty(); }
  49. }
  50. /// <summary>
  51. /// Whether to display the last tick.
  52. /// |是否显示最后一个刻度。
  53. /// </summary>
  54. public bool showEndTick
  55. {
  56. get { return m_ShowEndTick; }
  57. set { if (PropertyUtil.SetStruct(ref m_ShowEndTick, value)) SetVerticesDirty(); }
  58. }
  59. /// <summary>
  60. /// Number of segments that the axis is split into.
  61. /// |分隔线之间分割的刻度数。
  62. /// </summary>
  63. public int splitNumber
  64. {
  65. get { return m_SplitNumber; }
  66. set { if (PropertyUtil.SetStruct(ref m_SplitNumber, value)) SetAllDirty(); }
  67. }
  68. public bool autoColor { get { return m_AutoColor; } set { m_AutoColor = value; } }
  69. public static AxisTick defaultTick
  70. {
  71. get
  72. {
  73. var tick = new AxisTick
  74. {
  75. m_Show = true,
  76. m_AlignWithLabel = false,
  77. m_Inside = false,
  78. m_ShowStartTick = true,
  79. m_ShowEndTick = true
  80. };
  81. return tick;
  82. }
  83. }
  84. public AxisTick Clone()
  85. {
  86. var axisTick = new AxisTick();
  87. axisTick.show = show;
  88. axisTick.alignWithLabel = alignWithLabel;
  89. axisTick.inside = inside;
  90. axisTick.showStartTick = showStartTick;
  91. axisTick.showEndTick = showEndTick;
  92. axisTick.lineStyle = lineStyle.Clone();
  93. return axisTick;
  94. }
  95. public void Copy(AxisTick axisTick)
  96. {
  97. show = axisTick.show;
  98. alignWithLabel = axisTick.alignWithLabel;
  99. inside = axisTick.inside;
  100. showStartTick = axisTick.showStartTick;
  101. showEndTick = axisTick.showEndTick;
  102. }
  103. }
  104. }