mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 09:20:08 +00:00
增加Axis的m_MinCategorySpacing设置类目轴默认的最小类目间距
This commit is contained in:
@@ -99,6 +99,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField] protected bool m_Inverse = false;
|
||||
[SerializeField] private bool m_Clockwise = true;
|
||||
[SerializeField] private bool m_InsertDataToHead;
|
||||
[SerializeField][Since("v3.11.0")] private float m_MinCategorySpacing = 0;
|
||||
[SerializeField] protected List<Sprite> m_Icons = new List<Sprite>();
|
||||
[SerializeField] protected List<string> m_Data = new List<string>();
|
||||
[SerializeField] protected AxisLine m_AxisLine = AxisLine.defaultAxisLine;
|
||||
@@ -406,6 +407,15 @@ namespace XCharts.Runtime
|
||||
get { return m_InsertDataToHead; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_InsertDataToHead, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The minimum spacing between categories.
|
||||
/// ||类目之间的最小间距。
|
||||
/// </summary>
|
||||
public float minCategorySpacing
|
||||
{
|
||||
get { return m_MinCategorySpacing; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_MinCategorySpacing, value)) SetAllDirty(); }
|
||||
}
|
||||
|
||||
public override bool vertsDirty
|
||||
{
|
||||
|
||||
@@ -65,8 +65,10 @@ namespace XCharts.Runtime
|
||||
if (axis.splitNumber <= 0)
|
||||
{
|
||||
var eachWid = coordinateWid / dataCount;
|
||||
//var min = ((axis is YAxis) || (axis is ZAxis3D)) ? 20 : 80;
|
||||
var min = 20;
|
||||
|
||||
var min = axis.minCategorySpacing > 0
|
||||
? axis.minCategorySpacing
|
||||
: (Mathf.Abs(axis.context.dire.y) < 0.01 ? 80 : 20);
|
||||
if (eachWid > min) return dataCount;
|
||||
var tick = Mathf.CeilToInt(min / eachWid);
|
||||
return tick <= 1 ? dataCount : (int)(dataCount / tick);
|
||||
|
||||
Reference in New Issue
Block a user