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


Having used v3.1 for 9 years, I always found working with visible ranges to be a little “unwieldy” (unless I’ve been missing something all this time!). So after migrating to 6.5 I’ve been wondering if there have been any improvements that I can utilise. This is typically how I do things:

Most of my charts use pan & zoom modifiers, therefore AutoRange is set to “Never”, while the VM will expose (say) ‘DoubleRange’ properties for both the x-axis and y-axis ranges, bound to the ‘VisibleRange’ property of the axes in the view. These VM properties are usually instantiated after populating the data series (using the X & Y min/max in some way). The VM also exposes properties that are clones of these “initial” ranges.

In addition to the pan & zoom modifiers, I also use a custom ZoomExtentsModifier that lets a user double-click the chart to restore the axes back to those “initial” ranges. The custom class simply raises an event when the mouse is double clicked, and the event handler (in the view’s code-behind) does something like the following:

        var vm = (MyViewModel)DataContext;
        xaxis.AnimateVisibleRangeTo(vm.InitialXAxisRange, new TimeSpan(0, 0, 0, 0, 500));
        yaxis.AnimateVisibleRangeTo(vm.InitialYAxisRange, new TimeSpan(0, 0, 0, 0, 500));

So in a nutshell, this is how I’ve handled visible ranges all this time – to provide pan & zoom plus the custom “restore zoom” functionality. It’s quite a lot of plumbing/boilerplate/duplicate code, across dozens of charts/views/VMs in several applications, so is there any way to simplify any aspect of this?

  • You must to post comments

Not really, because you’re talking about complex and occasionally conflicting interactions.

  • AutoRange means autorange the chart. You can’t zoom and pan while the chart is also zooming to fit.

  • Zoom extents means zoom to the extents of the data. You can (as you have) create a custom zoom extents modifier to zoom to a specified range, but you need to specify that

One improvement you might find useful is we added a property SciChartSurface.ZoomState to tell you if the viewport is zoomed to extents or not. We utilise this in one of our tutorials to allow zooming/panning with autorange. Take a look:

Preserving Old Data and Allowing Zooming

If you let us know the exact set of requirements you have (what behaviour occurs when) we can suggest something for you

Best regards,

  • Andrew Stephens
    Thanks for the reply. I must admit you now have me wondering why I use my approach in the first place, rather than the vanilla zoom extents modifier! I’ve been using SciChart for many years, and I suspect I originally implemented it to solve a particular problem (maybe restoring the zoom level to specific x & y ranges rather than data extents), then simply fell into the habit of using this approach in every chart I’ve implemented since.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.