Pre loader

How to Update existing data (MVVM)

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

0
0

Hi,

I’m using the MVVM pattern with my _chartSeries declared as:
ObjectModel.ObservableCollection(Of IChartSeriesViewModel)

What’s the recommended way to update (not append) data values in one of the data series?

I tried looking for something like _chartSeries]0].DataSeries.Update but couldn’t find anything.

Thanks,
–George

  • You must to post comments
0
0

Hi George,

If you have created your series using DataSeriesSet.AddSeries(), they will be of type XyDataSeries&ltTX, TY>. Both XyDataSeries&ltTX, TY> and IXyDataSeries&ltTX, TY> have methods Append, Update, Insert, Remove. You’ll need to perform a cast as IChartSeriesViewModel exposes the series as type IDataSeries.

Hope that helps,
Andrew

  • yefchak
    Thanks. I was missing the cast to XyDataSeries. But I have a followup question. In order to update a large number of points, performance is very slow unless (I presume) I do a SuspendUpdates first. But I'm updating my data in my ViewModel, whereas I need to execute SuspendUpdates in the View (is this right?). I'm not sure I see a clean way to do this. I suppose I can raise an event to notify the view that it needs to update, or vice versa, but I trust you have a cleaner solution. Thanks, --George
  • Andrew Burnett-Thompson
    Hi George, We pre-empted this and put the SuspendUpdates pattern on IDataSeriesSet. You can freeze the entire chart by using this code:
    using (var s = DataSeriesSet.SuspendUpdates())
    {
        dataSeries.Insert(...)
    }
    
    Can you try that and let me know how it performs? If its poor we might need an InsertRange or another interface method to allow re-setting of data. Best regards, Andrew
  • yefchak
    Oh, cool! I'll try that... OOPS, but I don't think I have a DataSeriesSet. I just have a collection of IChartSeriesViewModel. I'll keep looking...
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

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

Start TrialCase Studies