Hi
I'm working with the WPF controls and trying to build an application to display call data on a screen.
My screen has 2 charts, the first of which is a line graph showing call volume over time. In this, I add a new data point to a series as the day progresses - this works OK.
The second chart is a summary of all calls by a business area. Therefore, it is possible that all the data points on this chart could change. Therefore I would either need to refresh or remove and add the data points. I cannot find anything in documentation or examples to suggest how this could be done.
There seems to be a Remove() method on the DataSeries object, but this takes a DataPoint object - so therefore I wrote code to enumerate the data points in a series and attempt to remove them :
DataSeries inboundBarSeries = new DataSeries(); |
DataSeries outboundBarSeries = new DataSeries(); |
inboundBarSeries.Definition = new BarSeriesDefinition(); |
outboundBarSeries.Definition = new BarSeriesDefinition(); |
inboundBarSeries.Label = "Inbound"; |
outboundBarSeries.Label = "Outbound"; |
skillBarChart.DefaultView.ChartArea.DataSeries.Add(inboundBarSeries); |
skillBarChart.DefaultView.ChartArea.DataSeries.Add(outboundBarSeries); |
} |
public void PopulateSkillChart() |
{ |
foreach(DataPoint dp in skillBarChart.DefaultView.ChartArea.DataSeries[0]) |
{ |
skillBarChart.DefaultView.ChartArea.DataSeries[0].Remove(dp); |
} |
DataSeries inboundBarSeries = skillBarChart.DefaultView.ChartArea.DataSeries[0]; |
DataSeries outboundBarSeries = skillBarChart.DefaultView.ChartArea.DataSeries[1]; |
this.loadInboundSkillChart(inboundBarSeries, outboundBarSeries); |
} |
The first chunk of code runs once when the screen is initialised, and adds the empty series to the chart. The PopulateSkillChart code then runs on a periodic basis and is intended to remove the data points and re-add them. However this code fails with "Collection was modified; enumeration operation may not execute." when I try and execute it.
Would this be recommended as a way to refresh the data set or is there an easier method which I am missing?
I would appreciate your help on this.
Thanks
Richard