ArgumentOutOfRangeException when trying to remove items from LineSeries ItemSource

I'm binding the series of an SfChart as shown below:

  <syncfusion:SfChart Grid.RowSpan="2" Series="{Binding Path=ChartSeries}">


I dynamically create line series' and add them to this ChartSeries, which works and the Lines display as intended:

  private void CreateLineSeries(measurement m)
  {
     Application.Current.Dispatcher.Invoke(() =>
     {
      FastLineBitmapSeries newLine = new FastLineBitmapSeries();
      newLine.ItemsSource = measurement.DataPoints;
      newLine.XBindingPath = "TimeStamp";
      newLine.YBindingPath = "Data";
      newLine.IsSeriesVisible = false;
      newLine.Label = measurement.Name + " (" + measurement.Units + ")";
      Application.Current.Dispatcher.Invoke(() =>
      {
     ChartSeries.Add(newLine);
      });
     });
    }
   }
  }


However, when I try to remove Elements from the ItemsSource after the Source gets too large, I get an ArgumentOutOfRangeException

if (DataPoints.Count > MaxDataPoints)
{
     Application.Current.Dispatcher.Invoke(() => {
          DataPoints.RemoveAt(0);
     });

}


Any idea why this would be happening?
Thanks




1 Reply

SR Samuel Rajadurai Edwin Rajamanickam Syncfusion Team July 17, 2018 02:05 PM UTC

Hi Clan,  
  
We have validated your query, and considering this as bug in our control. Since the series is updated only after the dispatcher update there is a mismatch in the index of the data points generated for the series. Thus the argument out of range exception is thrown. 
  
So, we have logged an issue report for this, you can track the status of the issue in the support incident which you have already created. 
  
  
Regards, 
Samuel 


Loader.
Up arrow icon