ChartSeriesDataSource throwing ArgumentOutOfRangeException during data binding

6 posts, 2 answers
  1. Eric
    Eric avatar
    3 posts
    Member since:
    Jul 2015

    Posted 26 Mar Link to this post

    I have a custom queue-like collection that implements INotifyCollectionChanged and IList<>. Rather than raising CollectionChanged for every Enqueue() operation, it raises CollectionChanged once for every 5 Enqueue() operations: NotifyCollectionChangedEventArgs.NewItems contains a list of the 5 items added since the last CollectionChanged call, and NotifyCollectionChangedEventArgs.NewStartingIndex is set to my collection's Count property - 5.

    This collection is being used as a data binding source to a RadCartesianChart with a DateTimeContinuousAxis. Unfortunately, when my collection raises CollectionChanged, an ArgumentOutOfRangeException is thrown out of ChartSeriesDataSource.GenerateDataPoint(). It appears that ChartSeriesDataSource's internal List<> is out of sync with my collection. NotifyCollectionChangedEventArgs.NewStartingIndex lies within my collection, but is several indices (1-4) beyond the end of ChartSeriesDataSource's internal List<>. 

    Questions:

    1. Does ChartSeriesDataSource (and ChartView generally) play nicely when it receives a NotifyCollectionChangedEventArgs.NewItems that contains more than one item? Especially if the source collection already contains data when the data binding is set up?

    2. If not, is there another way to throttle ChartView's updates?
  2. Answer
    Martin
    Admin
    Martin avatar
    1099 posts

    Posted 29 Mar Link to this post

    Hi Eric,

    The chartview doesn't support adding a range of items and currently such implementation is not included in our planning. In order to resolve the exception you will need to add the items one by one.

    Regards,
    Martin
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Eric
    Eric avatar
    3 posts
    Member since:
    Jul 2015

    Posted 30 Mar in reply to Martin Link to this post

    OK, a follow-up question then: does ChartView perform better when its source collection implements IList and/or IList<>, compared to simply IEnumerable? (This is the case in other parts of WPF, but I don't see a specific mention of it in the ChartView docs.)
  5. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 04 Apr Link to this post

    Hello Eric,

    RadChartView is working with any collection that implements the IEnumerable interface. I hope that answers your question.

    Regards,
    Martin
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  6. Eric
    Eric avatar
    3 posts
    Member since:
    Jul 2015

    Posted 04 Apr in reply to Martin Link to this post

    My question is whether ChartView performs better with a collection that implements IList, versus a collection that only implements IEnumerable. 

    The docs for several other Telerik controls specifically mention that IList data sources perform better than IEnumerable data sources. Examples include RadListBox and RadGridView, both of which state: "If the scenario requires a custom collection to be implemented, use the IList interface, which provides individual access by index to its items and the best performance."

    Is this also the case for RadChartView?

  7. Answer
    Martin
    Admin
    Martin avatar
    1099 posts

    Posted 05 Apr Link to this post

    Hi Eric,

    No, the chart itself won't benefit much if you use IList instead of IEnumerable. If there is any performance difference it will came from the collection implementation itself and it won't be noticeable.

    Regards,
    Martin
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for WPF is Visual Studio 2017 Ready