Pre loader

NullReferenceException in DataPointSelectionModifier after changing XyDataSeries

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums


Here’s the situation:
Our app has a viewmodel with an XyDataSeries Property bound to the plot. We’ve overridden DataPointSelectionModifer to allow us to trigger calculations when the selected points are changed. This overridden modifier is not instantiated by nor is it directly aware of the viewmodel; it is referenced only in the view xaml.

When changing between datasets we replace the contents of the XyDataSeries Property. Afterwards we are experiencing NullReferenceExceptions in DataPointSelectionModifier.SelectManyPoints(). This occurs whether we replace the contents of the data series or we set a completely new XyDataSeries object into the property.

It appears that the DataPointSelectionModifier.SelectedPointMarkers collection is no longer properly synced to the plot’s XyDataSeries. The size of the the collections are different and with the original DataSeries being garbage-collected the DataPointInfo.DataPointMetadata references are null. So we attempt to dial in a new selection and the deselection of this orphaned null metadata raises exceptions.

Is there some secret-sauce to keeping these collections in line?
Any and all suggestions are greatly appreciated.

  • You must to post comments
Great Answer

Hi Nicholas,

Thank you for reporting this. DataPointSelectionModifier doesn’t handle this case; let me log the issue and we’ll think what can be done.

For now, you could just call Clear() on the SelectedPointMarkers collection, or call DeselectAllPointMarkers() in your custom modifier. Or just re-create it.

As to handling changes of DataSeries, the most straightforward way is to subscribe to the DataSeries.DataSeriesChanged event in your custom modifier. You could subscribe to the RenderableSeriesCollection changes in the Attach() method and in the handler subscribe/unsubscribe to the DataSeries.DataSeriesChanged event for every RenderableSeries.

Hope this helps!

Best regards,

  • Nicholas Repka
    Thanks Yuriy! Your answer was very instructive in solving this problem. Any idea on the if/when the underlying issue might be corrected?
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies