How to Prevent Zoom or Pan on Just One Axis
Posted by Andrew BT on 12 February 2019 12:14 PM
You have a multi axis chart and you are using the RubberBandXyZoomModifier or ZoomPanModifier or MouseWheelModifier. You want to zoom and pan the chart but you want just one axis to stay fixed (not zoom along with the others).
Hide an Axis from a Modifier
<s:SciChartSurface> <!-- RenderableSeries omited for brevity --> <s:SciChartSurface.XAxes> <s:NumericAxis Id="FirstXAxis" s:ZoomPanModifier.IncludeAxis="False" /> <s:NumericAxis Id="SecondXAxis" /> </s:SciChartSurface.XAxes> <s:SciChartSurface.YAxes> <s:NumericAxis Id="FirstXAxis" /> <s:NumericAxis Id="SecondXAxis" s:YAxisDragModifier.IncludeAxis="False" /> </s:SciChartSurface.YAxes> <s:SciChartSurface.ChartModifier> <s:ModifierGroup> <s:ZoomPanModifier /> <s:XAxisDragModifier/> <s:YAxisDragModifier/> </s:ModifierGroup> </s:SciChartSurface.ChartModifier> </s:SciChartSurface>
Workaround 1, use VisibleRangeChanged
Subscribe to VisibleRangeChanged of the chosen axis and on change, always set it back to the fixed range you want, e.g.
var axis = new NumericAxis(); var range = new DoubleRange(0, 1); axis.VisibleRangeChanged += (s,e) => axis.VisibleRange = range;
Workaround 2, use ViewportManager to override Axis Ranges
If that doesn't work for you, take a look at our ViewportManager feature, which allows you to go into the SciChart core and override the AutoRange and range setting of any axis. There are examples of use here:
For further information about SciChart APIs please see our documentation: