Pre loader

Tag: ViewportManager

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

1 vote
3k views

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

0 votes
7k views

Hi!

I am trying to implement a custom ViewportManager for a SciChart3DSurface, but the overridden methods, such as OnCalculateNewXRange are not called after I assign the custom ViewportManager to a surface. The minimalistic version of my code is:

public class Test3DViewportManager : ViewportManager3DBase
    {
    public Test3DViewportManager() : base()
        {           
        }

    public override void OnParentSurfaceRendered(ISciChart3DSurface sciChartSurface)
        {
        base.OnParentSurfaceRendered(sciChartSurface);
        }

    protected override IRange OnCalculateNewXRange(IAxis3D xAxis)
        {
        return base.CalculateAutoRange(xAxis);
        }


    protected override IRange OnCalculateNewYRange(IAxis3D yAxis, RenderPassInfo3D renderPassInfo)
        {
        return base.CalculateAutoRange(yAxis);
        }


    protected override IRange OnCalculateNewZRange(IAxis3D zAxis, RenderPassInfo3D renderPassInfo)
        {
        return base.CalculateAutoRange(zAxis);
        }
    }

I tried to assign the custom manager is two different ways in code-behind, none of them work:

var VM= new Test3DViewportManager();
SciChart.ViewportManager = VM;  // way 1
VM.AttachSciChartSurface(SciChart); // way 2    

I would appreciate any suggestion, thanks in advance!

  • corvex asked 4 years ago
  • last active 4 years ago
0 votes
6k views

Hi

We use ViewportManager to automatically calculate the visible range of Y-axis for all series in the chart.

   <s:SciChartSurface Margin="0, 5, 0, 0"  Grid.Column="2"
                           ViewportManager="{Binding ViewportManager}"
                           MinHeight="250" MinWidth="250"
                           x:Name="MainChartSurface"
                           RenderableSeries="{s:SeriesBinding SeriesVms}"
                           ChartTitle="{Binding ChartModel.Title}"
                           Loaded="MainChartSurface_Loaded"
                           YAxes="{Binding YAxes}"
                           XAxes="{Binding XAxes}"
                           Style="{StaticResource YAxisStyle}"
                           Annotations="{s:AnnotationsBinding ChartModel.Annotations}">
      :
      : (omitted for brevity)
   </s:SciChartSurface>

This approach works fine for one chart.

We now have an additional requirement, which is to have the same VisibleRange for Y-axis over multiple charts. Basically, the VisibleRange should be set to be the [Min, Max] range over all the series in all charts.

Is there a way to achieve this with ViewportManager ?
Is there a way to make several charts related and assign it a common instance of ViewportManager?

BR, Gianni

0 votes
0 answers
8k views

I am synchronizing multiple scichart surfaces via shared VerticalChartGroup id and using a shared ViewPortManager. I also share MousEeventGroup.

Everything works fine exact for one issue:

I declare the modifier in xaml like this:

RubberBandXyZoomModifier ReceiveHandledEvents="True" IsAnimated = "False" IsXAxisOnly = "True" ExecuteOn = "MouseRightButton"/>

When using RubberBandXyZoomModifier I can select an x-axis zone and the zone will be zoomed in on all charts as long as the mouse pointer resides within the chart on which I zoom. For example when I right-click somewhere within the chart and drag the mouse to the right to choose a zone which to zoom in on and then release the right mouse button all synchronized charts zoom perfectly fine but ONLY if the mouse pointer resides within the chart upon release of the right mouse button.

This is a problem when I want to zoom in on an area that includes the very last data point that almost touches the y-axis that resides on my right side of the chart. Oftentimes I just want to quickly zoom and then release the mouse button when the mouse moves beyond the chart surface to the right. What happens in such event is that only the chart zooms on which I initiated the zoom or at other times only 2 out of the 4 synchronized charts zoom. Only when the mouse pointer resides within the chart on which I perform the zoom upon releasing the right mouse botton will the zoom be performed on all synchronized charts.

I believe this is a bug given that the chart on which the zoom is performed always zooms regardless of where the mouse pointer resides upon release of the right mouse button?

1 vote
9k views

Hello,

Currently I am using ViewportManager.AnimateZoomExtents to animate the data to fit the size of the graph. However, the animation causes the data to reach the very edge (X-Axis Max and Y-Axis Max). Is there a way that I can use AnimateZoomExtents to animate the data out but leave a 10% gap between the edge and X-Axis/Y-Axis Max?

I was able to do this using the following code, but I lose complete animation (which is what I’m looking for).

AxisYVisibleRange = new DoubleRange(AxisYVisibleRange.Min, AxisYVisibleRange.Max + (AxisYVisibleRange.Max * .10))
ViewportManager.AnimateZoomExtents(AnimateZoomTimeSpan);
1 vote
20k views

I want YAxis Auto Scale less than the value max 10% and greater value min 10%, how?

  • kingsoff asked 11 years ago
  • last active 9 years ago
1 vote
15k views

How exactly does the SuspendUpdates work? I was under the impression that the surface the ViewportManager is attached to should not be redrawn until the IUpdateSuspender was disposed.

        using (var s = ViewportManager.SuspendUpdates())
        {
            // Clear ObservableCollection<IChartSeriesViewModel> that is databound to SciChartSurface.SeriesSource
            // Add new IChartSeriesViewModel to ObservableCollection
        }

The behavior I’m observing is after the clear it is blanking out the chart and then I see the new series drawn on the surface. I was expecting to see the chart immediately switch to the new series without first seeing the chart surface being cleared. Is this not the behavior of SuspendUpdates?

  • dkuo asked 9 years ago
  • last active 9 years ago
Showing 7 results

Try SciChart Today

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

Start TrialCase Studies