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

Answered
1
0

I saw in tips and tricks for performance the use of

scichartsurface.suspendupdate

before something is added to the dataseries. But usually I don’t have access in ViewModel to surface. How can I suspendupdate in the ViewModel when updating the series?

Is dataseries.SuspendUpdate used for this?

  • You must to post comments
Best Answer
1
0

Hi Uwe,

This has been asked a few times before. What DataSeries.SuspendUpdates does is it locks the parent surface SyncRoot object ensuring that Render Operations cannot be processed while the DataSeries is being updated e.g.

var ds0 = new XyDataSeries<double,double>();
var ds1 = new XyDataSeries<double,double>();

// can suspend one dataseries, which locks the parent surface 
using (ds0.SuspendUpdates())
{
     // Can append many dataseries
     ds0.Append(..., ...);
     ds1.Append(..., ...); 
}
// parent surface redraws

DataSeries.SuspendUpdates() doesn’t behave exactly the same as SciChartSurface.SuspendUpdates(), but it does synchonize the DataSeries and SciChartSurface preventing re-draw inside the suspend updates block.

Let me know if this works in your situation.

Best regards,
Andrew

  • Uwe Hafner
    If I do that I can see that with my 8 dataseries that usually have an update frequency of >15.000 datapoints per second per series drop to below 13.900 points/s and the refreshing of the chart looks a bit jerky. I will stick to the "violation" :-) of the MVVM pattern and hold a reference to the surface to suspendupdates. It looks like it works smoother for my case.
  • Andrew
    I agree. MVVM is a tool to help us, we're not working for MVVM, its working for us :) My advice is then pass SciChartSurface into the ViewModel as ISuspendable (interface) or ISciChartSurface. That way its a very simple clean interface which keeps your ViewModel decoupled from your View, can still be tested etc... See https://www.scichart.com/questions/question/faq-how-to-call-scichartsurface-suspendupdates-in-a-viewmodel for more details. Hope this helps!
  • Uwe Hafner
    @Andrew I found a DataSeries.Parent Property that contains the SciChartSurface. I am using this now to suspend updates on the surface instead of the series (XyDataSeries.Parent.SuspendUpdate). And I don't have to somehow pass the surface from the view to viewmodel. Am I correct that this is the same as SciChartSurface.SuspendUpdate (Just sounds too easy after I tried to keep the surface in a separate variable). Can I use it or am I making a mistake in my thoughts?
    • Guest
    • 3 years ago
    Hi Uwe, yes, it does the same and you may use it if it's suitable for you. The only reason to pass a surface is that DataSeries.ParentSurface is set internally so it's Null until the corresponding RenderableSeries is being added to a surface.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.