Hello,
I took the example from the previous reply and changed some things. I wanted to throw these changes out to see if anyone thinks this is good or not. It seems to be working but I'm still testing . The LimitAxisZoom call just limits the value to 0 and 1. Is this needed, or will the ZoomFactor and ZoomPosition automatically limit to 0 and 1?
private void NumericalAxis_ActualRangeChanged(object sender, Syncfusion.UI.Xaml.Charts.ActualRangeChangedEventArgs e)
{
if (_graph != null)
{
if (!e.IsScrolling && _graph.SecondaryAxis.ZoomFactor < 1 && _lastNumericalAxis != null)
{
// Determine the range of the new axis
Double newRange = (Double)e.ActualMaximum - (Double)e.ActualMinimum;
// Determine the change for the max and min
Double deltaMax = (Double)e.ActualMaximum - (Double)_lastNumericalAxis.ActualMaximum;
Double deltaMin = (Double)e.ActualMinimum - (Double)_lastNumericalAxis.ActualMinimum;
// Determine the total percent change in relation to the new range
Double totalPercentChange = (deltaMax + deltaMin) / newRange;
// Adjust the zoom factor based on the percent change of the total range
_graph.SecondaryAxis.ZoomFactor = LimitAxisZoom(_graph.SecondaryAxis.ZoomFactor - (totalPercentChange * _graph.SecondaryAxis.ZoomFactor));
// Determine the max and min percent change in relation to the new range
Double maxPercentChange = deltaMax / newRange;
Double minPercentChange = deltaMin / newRange;
// Adjust the zoom position based on the max and min percent change of the total range
_graph.SecondaryAxis.ZoomPosition = LimitAxisZoom(_graph.SecondaryAxis.ZoomPosition + (minPercentChange * _graph.SecondaryAxis.ZoomPosition) - (maxPercentChange * _graph.SecondaryAxis.ZoomPosition));
}
// Remember for next time
_lastNumericalAxis = e;
}
}