diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 94351edc..7d644547 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -81,6 +81,7 @@ slug: /changelog ## master +* (2026.05.23) 修复`DataZoom`内绘制的折线图可能会超出范围的问题 * (2026.05.23) 修复`Axis`的`inverse`没能正确反转的问题 * (2026.05.23) 增加`LabelStyle`的`showCondition`,`showFilter`,`showThreshold`可控制`label`显示和隐藏 * (2026.05.22) 增加`LabelStyle`的`minGap`可避免`label`过于密集 diff --git a/Runtime/Component/DataZoom/DataZoomHandler.cs b/Runtime/Component/DataZoom/DataZoomHandler.cs index adec69f8..d1b47573 100644 --- a/Runtime/Component/DataZoom/DataZoomHandler.cs +++ b/Runtime/Component/DataZoom/DataZoomHandler.cs @@ -577,12 +577,11 @@ namespace XCharts.Runtime float scaleWid = showData.Count > 1 ? dataZoom.context.width / (showData.Count - 1) : dataZoom.context.width; Vector3 lp = Vector3.zero; Vector3 np = Vector3.zero; - double minValue = 0; - double maxValue = 0; + double minValue; + double maxValue; SeriesHelper.GetYMinMaxValue(chart, 0, axis.inverse, out minValue, out maxValue, false, false); - AxisHelper.AdjustMinMaxValue(axis, ref minValue, ref maxValue, true); - - // Check if x-axis is value/time type for accurate shadow x-positioning + minValue = ChartHelper.GetMinDivisibleValue(minValue, 0); + maxValue = ChartHelper.GetMaxDivisibleValue(maxValue, 0); double xMinValue = 0; double xMaxValue = 0; bool useXValueForShadow = false; @@ -710,11 +709,11 @@ namespace XCharts.Runtime float scaleWid = dataZoom.context.height / (showData.Count - 1); Vector3 lp = Vector3.zero; Vector3 np = Vector3.zero; - double minValue = 0; - double maxValue = 0; + double minValue; + double maxValue; SeriesHelper.GetYMinMaxValue(chart, 0, axis.inverse, out minValue, out maxValue); - AxisHelper.AdjustMinMaxValue(axis, ref minValue, ref maxValue, true); - + minValue = ChartHelper.GetMinDivisibleValue(minValue, 0); + maxValue = ChartHelper.GetMaxDivisibleValue(maxValue, 0); int rate = 1; var sampleDist = serie.sampleDist < 2 ? 2 : serie.sampleDist; var maxCount = showData.Count;