This is a migrated thread and some comments may be shown as answers.

ArgumentOutOfRangeException when using SeriesProvider

1 Answer 105 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 2
Martin asked on 26 Jan 2016, 10:37 AM

I found an issue in our code that was incorrectly calling chart.Series.Clear() as well as clearing the ObservableCollection we use with the SeriesProvider.

This causes the following exception when the chart tries to redraw.

System.ArgumentOutOfRangeException
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
    at System.Collections.ObjectModel.Collection`1.RemoveAt(Int32 index)
    at Telerik.Windows.Controls.ChartView.RadChartBase.RemoveDynamicSeries(ChartSeries series, Int32 index)
    at Telerik.Windows.Controls.ChartView.RadChartBase.RemoveDynamicSeries()
    at Telerik.Windows.Controls.ChartView.RadChartBase.UpdateDynamicSeries(List`1 actions)
    at Telerik.Windows.Controls.ChartView.RadChartBase.OnSeriesProviderStateChanged(List`1 actions)
    at Telerik.Windows.Controls.ChartView.ChartSeriesProvider.NotifyListeners()
    at Telerik.Windows.Controls.ChartView.ChartSeriesProvider.RefreshAttachedCharts()
    at Telerik.Windows.Controls.ChartView.ChartSeriesProvider.<ScheduleRefreshAttachedCharts>b__22()
    ...

 

I've just switched from 2014 Q3 and this didn't cause any problems in that version.

Obviously this is quite simple once I found it and we shouldn't be manually changing the Series collection when using a SeriesProvider. But it wasn't easy to find when its built into a large application and the stack trace doesn't help much.

Would it be possible to silently cope with this, or perhaps throw an exception when accessing the Series if the graph is using a SeriesProvider, that would make it much easier to find the problem.

 

Heres a small project to show what happens. Just run it and click the button.

https://dl.dropboxusercontent.com/u/32945770/SeriesProviderError.zip 

 

Thanks,

Martin

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 27 Jan 2016, 11:38 AM
Hello Martin,

Thank you for the project and the description. I am glad to hear that you managed to find the reason for the issue on your side. Basically, this scenario is not valid for the chart - it is not recommended to work with the Series collection when using SeriesProvider. Instead, you can use the Source property of the provider in order to modify the series.

Regards,
Martin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ChartView
Asked by
Martin
Top achievements
Rank 2
Answers by
Martin Ivanov
Telerik team
Share this question
or