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

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

0
0

Hello,
I would like to ZoomOut immedeatly after new data is rendered.
I would like to have flexibility in Zooming Out, therefore I cannot use AutoRange.Always.
I have implemented ZoomOut in SciChartSurface.Rendered, but that seems to be too early, as it doesnt react on the new data, instead zooms out based on the old data.
I have to wait 100 ms, then it works and it zooms out based on the new data.
Is there an event even after SciChartSurface.Rendered that is better suited to call the ZoomOut function?

I have used the technique described in the answer below. However, I am awaiting the dataChange and then call ZoomOut. It still doesnt work.

In my Code behind:

            await viewModel.DisplayData();
            viewModel.ZoomOut();

DisplayData adds LineRenderableSeriesViewModel with DataSeries to the RenderableSeries Observable Collection.

And in my ViewModel:

    internal void ZoomOut()
    {
        if (RenderableSeries.Count() > 0)
        {
            var parentSurface = ((LineRenderableSeriesViewModel)RenderableSeries.ElementAt(0)).DataSeries.ParentSurface;
            var viewportManager = parentSurface.ViewportManager;
            viewportManager.BeginInvoke(() =>
                {
                    viewportManager.AnimateZoomExtents(TimeSpan.FromMilliseconds(250));
                });

        }
    }

This way it works:

            await viewModel.DisplayData();
            await Task.Run(()=>System.Threading.Thread.Sleep(TimeSpan.FromMilliseconds(500)));
            viewModel.ZoomOut();

But that can’t be the solution – I need an event that fires when all the data is known to sciChartSurface.

Thanks,
Holger

Version
newest
  • You must to post comments
1
1

Not enough info here to fully understand the problem. However, some observations.

1.) SciChartSurface.Rendered fires whenever the chart is rendered. This could be resized, mouse-move with a tooltip, data changed, property changed, anything. If you zoom when rendered then you’ll zoom + render in a loop because zoom triggers render.

2.) If you change data in a DataSeries in a ViewModel then immediately try to zoom to fit, there will be some latency as WPF has not evaluated the bindings yet. To workaround this you can use this technique.

Best regards,
Andrew

  • Holger Schlüter
    I have changed my question to reflect your answer.
  • Andrew
    Got it. There is no such event sadly. DataSeries.DataSeriesChanged is fired by DataSeries when its data changes, not when a chart has drawn with its data. I will have to have a think about how best to do this. Until then the best workaround I’m afraid is the one you have.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.