增加Axism_MinCategorySpacing设置类目轴默认的最小类目间距

This commit is contained in:
monitor1394
2024-06-09 22:59:38 +08:00
parent a12c98b1a5
commit caee79630b
8 changed files with 20 additions and 2 deletions

View File

@@ -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
{

View File

@@ -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);