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

Increase RadChart performance when updating data?

1 Answer 173 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Dirk Black
Top achievements
Rank 2
Dirk Black asked on 01 Sep 2010, 11:58 AM
Increase RadChart performance when updating data?

We are utilizing thousands 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 (where the messages for the collection changed are being suppressed):

//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(CustomObservableCollection<CustomObservableCollection<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?

1 Answer, 1 is accepted

Sort by
0
Vladimir Milev
Telerik team
answered on 06 Sep 2010, 08:48 AM
Hi Dirk Black,

The best way to batch update the chart would be to use a non ObservableCollection as source (or if you need to use such a collection, refrain from updating that instance) and simply generate a new updated collection and set the chart control ItemsSource to the new collection effectively swapping it with the old one.

Let me know if the chart is still slow after trying the above.

Regards,
Vladimir Milev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
Dirk Black
Top achievements
Rank 2
Answers by
Vladimir Milev
Telerik team
Share this question
or