SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Programmatically Setting the VisibleRange of an Axis

The visible range of each axis can be set programmatically. As of SciChart v1.3 and above the limitation that the visible range must lie within the min, max of the data no longer applies.

The following code:

sciChartSurface.XAxis.VisibleRange = new DoubleRange(0,600);
sciChartSurface.YAxis.VisibleRange = new DoubleRange(-0.6, 1.2);

Results in this output:

Similarly the above may be achieved in Xaml. Given a NumericAxis defined on the XAxis and YAxis properties of the SciChartSurface, the VisibleRange may be set as follows:

            <SciChart:DoubleRange Min="0" Max="600"/>

Adding Mouse Interactivity to the Chart

Interactivity is provided by a number of ChartModifierBase derived classes. These are set on the SciChartSurface as follows: C#

sciChartSurface.ChartModifier = new RubberBandXyZoomModifier();



This will result in the following output:

Available Modifiers within SciChart

A table of available ChartModifiers is SciChart follows:

RubberBandXyZoomModifierDraws a reticule over the screen to zoom into a locationLeft click/drag: draw reticule and zoom. Setting IsXAxisOnly to true results in a horizontal only zoom
ZoomPanModifierAllows the user to drag the chart surface using the mouseLeft click/drag: pans the viewable area in the X and Y direction
CursorModifierDraws a crosshair on the chart and renders X,Y data values on a custom control templateMouse move: Update crosshair location and X,Y value output
XAxisDragModifierAllows the user to drag the X Axis to scale the chartLeft click/drag: Scales the X Axis depending in the mouse direction, with direction depending on the start point of the drag operation
YAxisDragModifierAllows the user to drag the Y Axis to scale the chartLeft click/drag: Scales the Y Axis depending in the mouse direction, with direction depending on the start point of the drag operation
RolloverModifierGives visual feedback plus binding to detect datapoint values on mouse overMouse move: highlights the nearest datapoint on all series. Outputs hit test data to a collection of SeriesInfo which can be bound to
ZoomExtentsModifierAllows zooming to extents on user-defined actionZoomExtents on mouse right button up, or mouse double click depending on the value of the ExecuteOn property
MouseWheelZoomModifierAllows zooming using the mousewheelScrollwheel: Zooms in/out a single step
ModifierGroupAllows multiple modifiers to be combined and set on the SciChartSurfaceN/A

Applying Multiple ChartModifiers using a ModifierGroup

For example, to combine the X and Y Axis drag modifiers with a ZoomPanModifier, use the following code: C#

sciChartSurface.ChartModifier = new ModifierGroup(new XAxisDragModifier(),
                                       new YAxisDragModifier(),
                                       new ZoomPanModifier());

This results in the following behaviour:

Behavior of the chart with XAxis, YAxis drag and Zoom Pan modifiers added

Leave a Reply