We are also utilizing thousand of data points. But instead of starting with an empty collection and adding thousands of datapoints (we have the collection populated and bind once, which works fine), we need to update all the datapoints at the same time.
Again, by default, each datapoint update generates a change notification and the RadChart re-analyses the data (which takes long, varying on the number of datapoints)
We're trying to update the information more efficiently, similar to the example of adding points more efficiently:
//observable collection implementation
public
class
CustomObservableCollection<T> : ObservableCollection<T>
{
public
void
UpdateData()
{
//manually force chart to update
base
.OnCollectionChanged(
new
NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
}
//data structure, INotifyPropertyChangedis also not implemented in the viewmodel.
//Therefore no change reflects an update; we have control through CustomObservableCollection.UpdateData() to force and update
//For the viewmodel, accessing the PointColor property (which is mapped in the xaml) calculates the value
public
class
MyData
{
public
double
XValue {
get
;
set
; }
public
double
YValue {
get
;
set
; }
}
//multiple series implementation: collection of collection.
private
CustomObservableCollection<CustomObservableCollection<MyDataViewModel>> chartData =
new
CustomObservableCollection<CustomObservableCollection<MyDataViewModel>>();
//Data binding once series-mappings have been completed, this takes about a second regardless of the volume of information
public
void
BindData(BatchUpdateObservableCollection<BatchUpdateObservableCollection<MyDataViewModel>> pchartData)
{
chartData = pchartData;
RadChartMain.ItemsSource =
this
.chartData;
}
//update code
public
void
UpdateChart()
{
for
(
int
series = 0; series < chartData.Count; series++)
{
for
(
int
datapoint = 0; datapoint < chartData[series].Count; datapoint++)
{
Random rnd =
new
Random(DateTime.Now.Second + series + datapoint);
chartData[series][datapoint].MyData.YValue = rnd.Next(0, 100);
}
}
//call once to force the update
chartData.UpdateData();
}
While this functions (update messages are now not sent automatically and we can force the RadChart to refresh once all the points are updated), the update process still takes the same time. In comparason, the initial binding takes only a second.
Is there something missing in our implementation causing the RadChart to re-analyze the data datapoint by datapoint?