Knowledgebase
How to Prevent Zoom or Pan on Just One Axis
Posted by Andrew BT on 26 March 2014 11:20 AM

The problem

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).

The solution

Hide an Axis from a Modifier

ZoomPanModifierXAxisDragModifier and YAxisDragModifier allow to exclude some axes from inspection by setting the IncludeAxis attached property on those:

        <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:

 

Further Reading

For further information about SciChart APIs please see our documentation:

(1 vote(s))
Helpful
Not helpful

Comments (0)

CONTACT US

Not sure where to start? Contact us, we are happy to help!


CONTACT US

SciChart Ltd, 16 Beaufort Court, Admirals Way, Docklands, London, E14 9XL. Email: Legal Company Number: 07430048, VAT Number: 101957725