增加DataZoomfilterAxisRange设置坐标轴的范围计算是否受DataZoom的影响

This commit is contained in:
monitor1394
2026-05-26 08:46:49 +08:00
parent 584ef9a834
commit b040f27b2c
7 changed files with 50 additions and 35 deletions

View File

@@ -92,6 +92,7 @@ namespace XCharts.Runtime
[SerializeField][Since("v3.5.0")] private MarqueeStyle m_MarqueeStyle = new MarqueeStyle();
[SerializeField][Since("v3.6.0")] private bool m_StartLock;
[SerializeField][Since("v3.6.0")] private bool m_EndLock;
[SerializeField][Since("v3.12.0")] private bool m_FilterAxisRange = true;
public DataZoomContext context = new DataZoomContext();
private CustomDataZoomStartEndFunction m_StartEndFunction;
@@ -325,6 +326,16 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_EndLock, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether dataZoom filters the axis min/max range. When true, the axis scale adapts to the current zoom window.
/// When false, the axis always shows the full data range regardless of the zoom position.
/// ||是否根据DataZoom的缩放窗口过滤坐标轴的最大最小值范围。为true时坐标轴范围随缩放窗口变化为false时坐标轴始终显示全部数据范围。
/// </summary>
public bool filterAxisRange
{
get { return m_FilterAxisRange; }
set { if (PropertyUtil.SetStruct(ref m_FilterAxisRange, value)) SetVerticesDirty(); }
}
/// <summary>
/// The end percentage of the window out of the data extent, in the range of 0 ~ 100.
/// ||数据窗口范围的结束百分比。范围是0 ~ 100。
/// </summary>

View File

@@ -591,9 +591,9 @@ 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;
double maxValue;
SeriesHelper.GetYMinMaxValue(chart, 0, axis.inverse, out minValue, out maxValue, false, false);
// shadow always shows the full data range, independent of DataZoom window
double minValue = SerieHelper.GetMinData(serie, 1, null, axis.inverse);
double maxValue = SerieHelper.GetMaxData(serie, 1, null, axis.inverse);
minValue = ChartHelper.GetMinDivisibleValue(minValue, 0);
maxValue = ChartHelper.GetMaxDivisibleValue(maxValue, 0);
double xMinValue = 0;
@@ -603,7 +603,8 @@ namespace XCharts.Runtime
var xAxis = chart.GetChartComponent<XAxis>(xAxisIndex);
if (xAxis != null && (xAxis.IsValue() || xAxis.IsTime()))
{
SeriesHelper.GetXMinMaxValue(chart, xAxisIndex, xAxis.inverse, out xMinValue, out xMaxValue, false, false);
xMinValue = SerieHelper.GetMinData(serie, 0, null, xAxis.inverse);
xMaxValue = SerieHelper.GetMaxData(serie, 0, null, xAxis.inverse);
AxisHelper.AdjustMinMaxValue(xAxis, ref xMinValue, ref xMaxValue, true);
useXValueForShadow = (xMaxValue - xMinValue) > 0;
}