Pre loader

HOw to use ZoomeEtend with button command

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

Dear all,

I have define a button bind to a command in order to reset the zoom to fit the chart viewport.
For that I try to use the follying code :

private void ResetZoomCmd(object arg)
    {
        //ZoomExtents();
        if (ViewportManager!=null)
        ViewportManager.ZoomExtents();
    }

But it has no effect, I have try also AnimatedZoomExtend command with same result.

What is the way to do ?

Version
4
  • You must to post comments
0
0
    private void ZoomExtentesClicked(object sender, RoutedEventArgs e)
      {
          MySciChartSurface.AnimateZoomExtents(TimeSpan.FromMilliseconds(300));
      }
  
  • sc sc
    I want to do it from a MVVM model command without refering directly the sciChqrtSurface object in my code behind. Possible ?
  • You must to post comments
0
0

Any dataseries has the method InvalidateParentSurface(RangeMode.ZoomToFit) which you can use to force a redraw and zoom to fit from the ViewModel.

You can also control the SciChartSurface from a ViewportManager instance hosted in your viewmodel.

  • sc sc
    Hi ANdrew, thanks for your reply. I have try the folloying : if (ViewportManager!=null)         ViewportManager.ZoomExtents(); with no help
  • sc sc
    Hi Andew, I have tried what you suggest by using the InvalidateParentSurface(RangeMode.ZoomToFit) after updating my data series or using the Viewportmanager.ZoomExtents, both solution have no effect after updating my series. the only way which works is to call the ZoomExtend directly from chartsurface instance. Any idea about reason ?
  • Andrew Burnett-Thompson
    Have a look at this example: https://www.scichart.com/example/wpf-chart-example-dashboard-style-charts. We actually use ViewportManager.ZoomExtents in DashboardStyleChartsViewModel.cs to zoom to fit after data change.
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies