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

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
    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.