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

Optimization

1 Answer 76 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Jason D
Top achievements
Rank 1
Veteran
Jason D asked on 12 Jun 2020, 05:37 PM

I've been testing the chart using bitmap rendering and am pleased with the performance so far. I have some questions regarding optimization. I am creating a simple line chart and am using a ScatterLineSeries, which seems to be the best match. The number of series may change, but the data itself will not change.

1. Is it possible to directly bind to or use arrays instead of arrays of objects? For example, I have 1 million data points that are stored in two arrays: one for X and one for Y. Is there any way to use the data as-is without creating intermediate classes?

2. The chart appears to create a ScatterDataPoint for each of my points. I directly added ScatterDataPoint objects to avoid creating an intermediate class, which worked. However, is there no way to specify an initial capacity? With one million points, isn't the collection going to be constantly resizing?

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 17 Jun 2020, 09:55 AM

Hello Jason,

The RadCartesianChart series can be populate using two methods. The first one is to provide a collection with System.Double (or any other numeric type) values. This will populate the series with DataPoint objects (like ScatterDataPoint) which gets the Y value from the collection of System.Double and the X value is automatically set to the index of the data point. So, on the X axis you will have 1, 2, 3, etc.

The second method is to provide a collection of any object that contains two public properties that can be used from the series to get X and Y values.

In your situation, with the two collections, you have two options:

  • To wrap each X/Y pair in a custom object and use the standard data binding approach. The downside of this approach is that you will hit downgrade in the performance and probably the memory footprint.
    |
  • Or instead of using the ItemsSource of the series with custom objects, you can directly populate the DataPoints collection with ScatterDataPoint objects (as you already tried). This way you will decrease the memory footprint because you will avoid creating 1 million additional objects and also you will avoid some processing time from the logic that links the custom objects with the DataPoint objects. The downside of this approach is that you will need to manually synchronize both collections with X and Y values with the DataPoints collection of the chart.

    As for the capacity of the DataPoints collection, I am afraid there is no API that allows setting this.

I hope this answers your questions. If you have any others, please let me know.

Regards,
Martin Ivanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
ChartView
Asked by
Jason D
Top achievements
Rank 1
Veteran
Answers by
Martin Ivanov
Telerik team
Share this question
or