mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-29 20:58:47 +00:00
[feature][axis] support Settings.axisMaxSplitNumber
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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]))
|
||||
|
||||
@@ -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; } }
|
||||
/// <summary>
|
||||
@@ -137,6 +138,16 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetClass(ref m_LegendIconCornerRadius, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the max splitnumber of axis.
|
||||
/// |坐标轴最大分隔段数。段数过大时可能会生成较多的label节点。
|
||||
/// </summary>
|
||||
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;
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace XCharts.Runtime
|
||||
axis.context.offset = 0;
|
||||
axis.context.lastCheckInverse = axis.inverse;
|
||||
|
||||
AxisHandler<ParallelAxis>.UpdateAxisTickValueList(axis);
|
||||
(axis.handler as ParallelAxisHander).UpdateAxisTickValueList(axis);
|
||||
(axis.handler as ParallelAxisHander).UpdateAxisLabelText(axis);
|
||||
chart.RefreshChart();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user