Best Practices: Display Large Data
- 5 minutes to read
A chart's performance directly relates to how many points and elements it displays: fewer elements result in higher performance. This topic explains how to reduce the number of data points and enhance the chart's performance.
- Data Aggregation
- Loading Data
- Automatic Resampling
- Automatic Calculations
- Visual Elements
- Interactivity Optimization
- Changeable Data
Data Aggregation groups raw data points into points with a larger argument measurement unit. When the Aggregation is enabled, the chart splits the x-axis into intervals (according to the measurement unit value), and uses an aggregation function to automatically aggregate data for each interval:
|Non-aggregated data||Data aggregated by month|
The following approaches reduce the time the chart control takes to load data:
Store all data points in as few series as possible. The Chart control is optimized to render a small number of series with many points, rather than a large number of series with a few points. For example, a single series with a million points is processed faster than 10 series with 100000 points each.
Add points to the series in a single operation instead of adding each point separately:
Use the Series.DataSourceSorted property to notify the chart that the series's data source is sorted to prevent the chart's internal sorting procedures.
An internal data resampling algorithm allows the chart to avoid unnecessary operations when rendering series. The chart renders the minimum set of points required to display the correct series shape and form. The algorithm discards all points that have no effect on the output (for example, overlapped points). Every time the zoom level or visible data range changes, the chart re-calculates the minimum point set.
The resampling algorithm is in effect under the following conditions:
- The Chart or series is bound to data. For more information, see the ChartControl.DataSource and Series.DataSource properties.
- The data source contains more than ten thousand data points.
- The series's AllowResample property is set to true.
- The series has numeric values, and its numeric, DateTime or TimeSpan arguments are sorted in ascending order. Note that series with qualitative arguments are not resampled.
The resampled data algorithm and aggregated data display technique optimize RAM usage, but aggregate calculations require additional time and the resulting series shape can be different from the original.
Note that the resampling algorithm is not supported for the following series:
Automatic range, scale type, and layout calculations require additional resources.
Use the Range.SetMinMaxValues method to define an AxisBase.WholeRange's limits for x- and y-axes if the points' argument and value range are known. Refer to the Whole and Visual Ranges document for more information on axis ranges.
Set the ChartControl.AutoLayout property to false.
Define a scale type for series points' arguments if possible. For this, set the Series.ArgumentScaleType property to the ScaleType.Numerical, ScaleType.DateTime or ScaleType.Qualitative value depending on your data type. A chart should perform additional calculations to determine the actual scale type when ScaleType.Auto is used. Note that a chart achieves the best possible performance when it has the Numerical arguments' axis scale type. However, the DateTime scale type does not suffer from significant performance degradation. In comparison with them, the Qualitative scale type requires more resources to process data values.
Follow the steps below to decrease the time needed to render a chart's visual elements:
Avoid to use templates to customize chart elements' appearance and behavior.
The Chart control needs additional resources to handle the ChartControl.CustomDrawSeriesPoint event. Place points that should be customized in a separate series.
Use a single color to paint series points. Avoid to use the XYSeries.ColorEach property.
Each additional chart element (for example, a series point label) requires extra rendering time. This also applies to visual effects, for instance, chart elements' shadows.
Use the LineSeries2D to represent a large amount of data. Disable point markers (LineSeries2D.MarkerVisible) when you use the LineSeries2D and its descendants. Also, modify the LineSeries2D.LineStyle property's line style settings as follows:
Use small values to define the PointSeries2D.MarkerSize property.
Customize the following parameters to optimize a Bar Series:
This section contains tips to enhance performance when a chart shows a dataset that changes frequently.
Remove an existing point and add a new one instead to update the chart's data. The existing SeriesPoint argument/value change results in unnecessary calculations. For example, the SeriesPoint.Value property's change entails the chart content's update.
The Chart Control handles the following events to avoid to reload all data when the chart is bound to a dataset that updates frequently: