Pre loader

Toggle the view range between two states

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

Answered
1
0

We want to add a toggle button to our chart, that changes the view range between zooming to a particular region of the graph and showing the whole dataset.
To achieve so, we have followed this post that suggests overriding the methods OnCalculateNewYRange and OnCalculateNewXRange inside a custom viewport manager https://www.scichart.com/documentation/win/current/webframe.html#ViewportManager%20-%20Full%20Control%20over%20Axis%20Ranges%20and%20Viewport.html

However, we have found that always overriding those methods does not work, because they get called when the user zooms and pans around the chart, where you want the default range to be returned, not our custom computed one.
Adding a flag to only override the methods when you click the button has also proven tricky, as those methods get called internally many times and it is difficult to control.
Is there an easier way to achieve this behaviour?

Our overridden methods look something along these lines:

/// <inheritdoc/>
    protected override IRange OnCalculateNewXRange(
        IAxis axis )
    {
        var computedRange = base.OnCalculateNewXRange( axis );

        if ( !( GetXLimitsForCurrentVisibleRangeLevel is null ) ) 
        {
            // Method that returns our computed visible range as a function of the toggle button state (CurrentVisibleRangeLevel )
           // Returns null when a flag indicates that it has already been called after the toggle button was clicked
            var newRange = GetXLimitsForCurrentVisibleRangeLevel( CurrentVisibleRangeLevel );
            return newRange ?? computedRange;
        }

        return computedRange;
    }    

Many thanks in advance!

Malu

Version
6.2.1.13304
  • You must to post comments
Best Answer
0
0

Why not simply set Axis.VisibleRange = new DoubleRange(min, max) to zoom into a region, then call SciChartSurface.zoomExtents() to show all data?

  • malú Diaz
    Yes, we ended up following that approach, it was much simpler. Thanks
  • You must to post comments
0
0

Why not simply set Axis.VisibleRange = new DoubleRange(min, max) to zoom into a region, then call SciChartSurface.zoomExtents() to show all data?

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.