답변 :

 

t's actually not a bug, but may seem such.

In stacked or segmented mode, vertical zooming currently works as follows:
axis.Maximum and Minimum are multiplied or divided (depending on in/out zoom) by ViewXY.ZoomPanOptions.ZoomFactor value. That happens when zooming with Ctrl + left or right mouse button click. Wheel is related to factor this as well.

As your Y range is not symmetrical to 0 level, the new zoomed scale is not suitable for your data. And in your code you have enabled series.LimitYToStackSegment, so it shows up very clearly and ugly.

There's a way to override zooming with custom logic like this, by using BeforeZooming event handler:

m_chart.ViewXY.BeforeZooming += ViewXY_BeforeZooming;


//Make symmetrical zooming around old Y range center point.
void ViewXY_BeforeZooming(System.Collections.Generic.List<RangeChangeInfo> xRanges,
System.Collections.Generic.List<RangeChangeInfo> yRanges, bool byWheel, ref bool cancel)
{
m_chart.BeginUpdate();
cancel = true;
foreach(RangeChangeInfo rci in yRanges)
{
double yMid = (rci.OldMin + rci.OldMax) / 2.0;
double newYRange = rci.NewMax - rci.NewMin;

rci.Axis.SetRange(yMid-newYRange/2.0, yMid + newYRange/2.0);
}
m_chart.EndUpdate();
}


Maybe we should change the built-in zooming to use this kind of "symmetrical-to-Y-range-mid-point" instead of the current approach?

+ Recent posts