Files
XCharts/Runtime/Component/Axis/AxisTick.cs

110 lines
3.8 KiB
C#
Raw Normal View History

2019-07-13 16:38:38 +08:00
using UnityEngine;
2022-02-19 22:37:57 +08:00
namespace XCharts.Runtime
2019-07-13 16:38:38 +08:00
{
/// <summary>
/// Settings related to axis tick.
2022-03-24 08:37:06 +08:00
/// |坐标轴刻度相关设置。
/// </summary>
2019-07-13 16:38:38 +08:00
[System.Serializable]
2021-01-11 08:54:28 +08:00
public class AxisTick : BaseLine
2019-07-13 16:38:38 +08:00
{
[SerializeField] private bool m_AlignWithLabel;
[SerializeField] private bool m_Inside;
2021-04-14 08:59:03 +08:00
[SerializeField] private bool m_ShowStartTick;
[SerializeField] private bool m_ShowEndTick;
2022-02-19 17:35:22 +08:00
[SerializeField] private float m_Distance;
[SerializeField] protected int m_SplitNumber = 0;
[SerializeField] private bool m_AutoColor;
/// <summary>
/// The distance between the tick line and axis line.
2022-03-24 08:37:06 +08:00
/// |刻度线与轴线的距离。
2022-02-19 17:35:22 +08:00
/// </summary>
public float distance { get { return m_Distance; } set { m_Distance = value; } }
2019-07-13 16:38:38 +08:00
/// <summary>
/// Align axis tick with label, which is available only when boundaryGap is set to be true in category axis.
2022-03-24 08:37:06 +08:00
/// |类目轴中在 boundaryGap 为 true 的时候有效,可以保证刻度线和标签对齐。
/// </summary>
public bool alignWithLabel
{
get { return m_AlignWithLabel; }
2021-01-11 08:54:28 +08:00
set { if (PropertyUtil.SetStruct(ref m_AlignWithLabel, value)) SetVerticesDirty(); }
}
/// <summary>
/// Set this to true so the axis labels face the inside direction.
2022-03-24 08:37:06 +08:00
/// |坐标轴刻度是否朝内,默认朝外。
/// </summary>
public bool inside
{
get { return m_Inside; }
2021-01-11 08:54:28 +08:00
set { if (PropertyUtil.SetStruct(ref m_Inside, value)) SetVerticesDirty(); }
}
2021-04-14 08:59:03 +08:00
/// <summary>
/// Whether to display the first tick.
2022-03-24 08:37:06 +08:00
/// |是否显示第一个刻度。
2021-04-14 08:59:03 +08:00
/// </summary>
public bool showStartTick
{
get { return m_ShowStartTick; }
set { if (PropertyUtil.SetStruct(ref m_ShowStartTick, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to display the last tick.
2022-03-24 08:37:06 +08:00
/// |是否显示最后一个刻度。
2021-04-14 08:59:03 +08:00
/// </summary>
public bool showEndTick
{
get { return m_ShowEndTick; }
set { if (PropertyUtil.SetStruct(ref m_ShowEndTick, value)) SetVerticesDirty(); }
}
2022-02-19 17:35:22 +08:00
/// <summary>
/// Number of segments that the axis is split into.
2022-03-24 08:37:06 +08:00
/// |分隔线之间分割的刻度数。
2022-02-19 17:35:22 +08:00
/// </summary>
public int splitNumber
{
get { return m_SplitNumber; }
set { if (PropertyUtil.SetStruct(ref m_SplitNumber, value)) SetAllDirty(); }
}
public bool autoColor { get { return m_AutoColor; } set { m_AutoColor = value; } }
2019-07-13 16:38:38 +08:00
public static AxisTick defaultTick
{
get
{
var tick = new AxisTick
{
m_Show = true,
m_AlignWithLabel = false,
m_Inside = false,
2021-11-28 20:31:41 +08:00
m_ShowStartTick = true,
2021-04-14 08:59:03 +08:00
m_ShowEndTick = true
2019-07-13 16:38:38 +08:00
};
return tick;
}
}
public AxisTick Clone()
{
var axisTick = new AxisTick();
axisTick.show = show;
axisTick.alignWithLabel = alignWithLabel;
axisTick.inside = inside;
2021-04-14 08:59:03 +08:00
axisTick.showStartTick = showStartTick;
axisTick.showEndTick = showEndTick;
2021-01-11 08:54:28 +08:00
axisTick.lineStyle = lineStyle.Clone();
return axisTick;
}
public void Copy(AxisTick axisTick)
{
show = axisTick.show;
alignWithLabel = axisTick.alignWithLabel;
inside = axisTick.inside;
2021-04-14 08:59:03 +08:00
showStartTick = axisTick.showStartTick;
showEndTick = axisTick.showEndTick;
}
2019-07-13 16:38:38 +08:00
}
}