ArgumentOutOfRangeException when using SeriesProvider

2 posts, 0 answers
  1. Martin
    Martin avatar
    17 posts
    Member since:
    Apr 2009

    Posted 26 Jan Link to this post

    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

  2. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 27 Jan Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top