Knowledgebase
Axis Interactivity (Zoom, Scroll, Pan Programmatically)
Posted by Andrew BT on 07 February 2019 10:37 AM
|
|
Programmatically Scrolling an AxisSciChart provides a clean and simple API to interact with a single Axis programmatically, e.g. to Zoom, Scroll or Pan an axis. This can come in useful when creating custom ChartModifierBase derived classes e.g. custom zooming or panning of the chart. For further information, please see our documentation: | |
|
Comments (2)
Ryan Green
05 May 2014 07:36 PM
Question, if I wanted to through the SimpleZoomInOutModifier in to my program before modifying it, what do I need to do to get it to work? If I include it in my XAML, I get the error "Object reference not set to an instance of an object." I've never built/used a custom modifier so I'm uncertain where to start looking. This issue does not appear to be present in the SimpleZoomPanModifier example, but that example doesn't use the key press events that I'm looking for.
Andrew Burnett-Thompson
28 May 2014 08:15 PM
Hi Ryan,
This depends on which line gets a null reference exception. I'm guessing its this line
<code>
mainWindow.PreviewKeyDown -= SciChart_PreviewKeyDown;
</code>
If so, the SciChartSurface cannot find a parent of type Window. The SciChartSurface is either not in a window yet, or you are not hosting the SciChartSurface in a window (e.g. off screen).
The modifier is provided for example purposes. Basically you need a KeyDown event from something in your application. If you can get that, then you can adjust the zoom using the technique which is demonstrated, which is XAxis.ZoomBy() and YAxis.ZoomBy(). This ties in to the theme of the article which is the Axis interactivity methods such as Scroll, ScrollBy, Zoom, ZoomBy.
I hope this helps,
Andrew
This depends on which line gets a null reference exception. I'm guessing its this line
<code>
mainWindow.PreviewKeyDown -= SciChart_PreviewKeyDown;
</code>
If so, the SciChartSurface cannot find a parent of type Window. The SciChartSurface is either not in a window yet, or you are not hosting the SciChartSurface in a window (e.g. off screen).
The modifier is provided for example purposes. Basically you need a KeyDown event from something in your application. If you can get that, then you can adjust the zoom using the technique which is demonstrated, which is XAxis.ZoomBy() and YAxis.ZoomBy(). This ties in to the theme of the article which is the Axis interactivity methods such as Scroll, ScrollBy, Zoom, ZoomBy.
I hope this helps,
Andrew