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
- malú Diaz asked 3 years ago
- You must login to post comments
Why not simply set Axis.VisibleRange = new DoubleRange(min, max) to zoom into a region, then call SciChartSurface.zoomExtents() to show all data?
- Andrew Burnett-Thompson answered 3 years ago
-
Yes, we ended up following that approach, it was much simpler. Thanks
- You must login to post comments
Why not simply set Axis.VisibleRange = new DoubleRange(min, max) to zoom into a region, then call SciChartSurface.zoomExtents() to show all data?
- Andrew Burnett-Thompson answered 3 years ago
- You must login to post comments
Please login first to submit.