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

DataSeries.AddRange Error!!

1 Answer 36 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Jerry
Top achievements
Rank 1
Jerry asked on 27 Oct 2010, 04:59 AM
Hello,

When I use DataSeries.AddRange method,a exception occurs:

Object reference not set to an instance of an object.
at Telerik.Windows.Controls.Charting.DataSeries.InsertItem(Int32 index, DataPoint item) in c:\Builds\WPF_Scrum\HotFix_2010_Q2\Sources\Development\Controls\Chart\Chart\Data\DataSeries.cs:line 214

My code snap is followed:
DataSeries barSeries = new DataSeries();
var maxKey = features.Max(x => x.Key);
ObservableCollection<DataPoint> dataPoints=new ObservableCollection<DataPoint>();
Parallel.For(1, maxKey, i =>
             {
                 DataPoint dataPoint;
                 if (features.ContainsKey(i))
                 {
                      int xLabel = i*_mStatisticsStep;
                      dataPoint = new DataPoint(xLabel, features[i])
                                   {XCategory = xLabel.ToString()};
                  }
                  else
                  {
                       int xLabel = i*_mStatisticsStep;
                       dataPoint = new DataPoint(xLabel, 0)
                                   {XCategory = xLabel.ToString()};
 
                  }
                  dataPoints.Add(dataPoint);
                  });
barSeries.AddRange(dataPoints);

1 Answer, 1 is accepted

Sort by
0
Jerry
Top achievements
Rank 1
answered on 27 Oct 2010, 07:12 AM
Sorry for my question,It is my fault!
the collection contains null values!
Tags
Chart
Asked by
Jerry
Top achievements
Rank 1
Answers by
Jerry
Top achievements
Rank 1
Share this question
or