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
- yefchak asked 11 years ago
- last edited 9 years ago
- You must login to post comments
Hi George,
If you have created your series using DataSeriesSet.AddSeries(), they will be of type XyDataSeries<TX, TY>. Both XyDataSeries<TX, TY> and IXyDataSeries<TX, 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
- Andrew Burnett-Thompson answered 11 years ago
-
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
-
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 -
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 login to post comments
Please login first to submit.