diff --git a/CHANGELOG.md b/CHANGELOG.md index 472448c7..6c63499b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ ## master +* (2022.07.04) 增加`Settings`的`axisMaxSplitNumber`参数设置`Axis`的最大分隔段数 * (2022.07.04) 修复`Axis`在设置`offset`后`Tick`绘制位置异常的问题 (#209) * (2022.07.03) 优化`AxisLabel`的`formatterFunction`自定义委托 * (2022.07.03) 增加`AxisName`的`onZero`参数支持设置坐标轴名称位置是否和Y轴0刻度一致 (#207) diff --git a/Editor/ChildComponents/SettingsDrawer.cs b/Editor/ChildComponents/SettingsDrawer.cs index 4608af10..4a7cab97 100644 --- a/Editor/ChildComponents/SettingsDrawer.cs +++ b/Editor/ChildComponents/SettingsDrawer.cs @@ -28,6 +28,7 @@ namespace XCharts.Editor PropertyField(prop, "m_LineSmoothness"); PropertyField(prop, "m_LineSegmentDistance"); PropertyField(prop, "m_CicleSmoothness"); + PropertyField(prop, "m_AxisMaxSplitNumber"); PropertyField(prop, "m_LegendIconLineWidth"); PropertyListField(prop, "m_LegendIconCornerRadius", true); --EditorGUI.indentLevel; diff --git a/Runtime/Component/Axis/AxisHandler.cs b/Runtime/Component/Axis/AxisHandler.cs index 44fdaf47..96456755 100644 --- a/Runtime/Component/Axis/AxisHandler.cs +++ b/Runtime/Component/Axis/AxisHandler.cs @@ -218,7 +218,7 @@ namespace XCharts axis.UpdateLabelText(runtimeWidth, dataZoom, isPercentStack); } - internal static void UpdateAxisTickValueList(Axis axis) + internal void UpdateAxisTickValueList(Axis axis) { if (axis.IsTime()) { @@ -267,12 +267,13 @@ namespace XCharts list.Add(axis.context.minValue); value = Math.Ceiling(axis.context.minValue / tick) * tick; } + var maxSplitNumber = chart.settings.axisMaxSplitNumber; while (value <= axis.context.maxValue) { list.Add(value); value += tick; - if (list.Count > 100) + if (maxSplitNumber > 0 && list.Count > maxSplitNumber) break; } if (!ChartHelper.IsEquals(axis.context.maxValue, list[list.Count - 1])) diff --git a/Runtime/Component/Settings/Settings.cs b/Runtime/Component/Settings/Settings.cs index 5a7fb4c1..0b7d771e 100644 --- a/Runtime/Component/Settings/Settings.cs +++ b/Runtime/Component/Settings/Settings.cs @@ -23,6 +23,7 @@ namespace XCharts.Runtime [SerializeField][Range(1, 10)] protected float m_CicleSmoothness = 2f; [SerializeField] protected float m_LegendIconLineWidth = 2; [SerializeField] private float[] m_LegendIconCornerRadius = new float[] { 0.25f, 0.25f, 0.25f, 0.25f }; + [SerializeField][Since("v3.1.0")] protected float m_AxisMaxSplitNumber = 20; public bool show { get { return m_Show; } } /// @@ -137,6 +138,16 @@ namespace XCharts.Runtime set { if (PropertyUtil.SetClass(ref m_LegendIconCornerRadius, value, true)) SetVerticesDirty(); } } + /// + /// the max splitnumber of axis. + /// |坐标轴最大分隔段数。段数过大时可能会生成较多的label节点。 + /// + public float axisMaxSplitNumber + { + get { return m_AxisMaxSplitNumber; } + set { if (PropertyUtil.SetStruct(ref m_AxisMaxSplitNumber, value)) SetVerticesDirty(); } + } + public void Copy(Settings settings) { m_ReversePainter = settings.reversePainter; diff --git a/Runtime/Coord/Parallel/ParallelCoordHandler.cs b/Runtime/Coord/Parallel/ParallelCoordHandler.cs index 2976b3f1..7e68ada6 100644 --- a/Runtime/Coord/Parallel/ParallelCoordHandler.cs +++ b/Runtime/Coord/Parallel/ParallelCoordHandler.cs @@ -165,7 +165,7 @@ namespace XCharts.Runtime axis.context.offset = 0; axis.context.lastCheckInverse = axis.inverse; - AxisHandler.UpdateAxisTickValueList(axis); + (axis.handler as ParallelAxisHander).UpdateAxisTickValueList(axis); (axis.handler as ParallelAxisHander).UpdateAxisLabelText(axis); chart.RefreshChart(); }