Best Practices: Display Large Data
- 6 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 Calculations
- Rendering Visual Elements
- Interactivity Optimization
- Changeable Data
You can use the Data Aggregation functionality to configure a more compact and readable view for a large amount of data. When using data aggregation, the chart splits the x-axis into intervals (according to the measurement unit value), and automatically aggregates data for each interval using an aggregation function. The following images illustrate this feature:
|Non-aggregated data||Data aggregated by year|
Refer to the Data Aggregation document for more details.
The following approaches can help you to accelerate loading data:
- If possible, store all data points in a few series. Since the Chart control is optimized for rendering a small number of series that have many points, rather than rendering 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.
- Since v16.1, the Chart Control loads data and applies settings when a chart is being rendered. This means you do not have to use the ChartControl.BeginInit and ChartControl.EndInit methods, or the SeriesPointCollection's ChartCollectionBase.BeginUpdate and ChartCollectionBase.EndUpdate methods to accelerate loading data.
Manual series point creation is faster than individual series binding (series points are generated based on a data source) and series template binding (series and points are generated based on a data source). However, data binding does not cause a significant performance loss.
You can use the Series.DataSourceSorted property to notify the chart that the series's data source is already sorted to prevent the chart's internal sorting procedures.
The best way to add points to the series is using a single operation instead of adding each point separately. The code below demonstrates this approach:
Range, scale type and layout's automatic calculations require additional resources. The following steps can help accelerate rendering a chart:
- If the points' argument and value range are known, manually define an AxisBase.WholeRange's limits for x- and y-axes using the Range.SetMinMaxValues method. Refer to the Visual Ranges and Whole Ranges document for more information on axis ranges.
- Set the ChartControl.AutoLayout property to false.
- If possible, define a scale type for series points' arguments. For this, specify the SeriesBase.ArgumentScaleType property to the ScaleType.Numerical, ScaleType.DateTime or ScaleType.Qualitative value depending on your data type. When ScaleType.Auto is used, a chart should perform additional calculations to determine the actual scale type. Note that a chart achieves the best possible performance when it has the Numerical arguments' axis scale type. However, the Date-Time scale type does not suffer from significant performance degradation. In comparison with them, the Qualitative scale type requires more resources to process data values.
Rendering Visual Elements
Follow the steps below to decrease the time needed for rendering a chart's visual elements:
- Leave the ChartControl.RefreshDataOnRepaint property value as false to prevent a chart from reloading all its data when it is redrawn.
- Using the ChartControl.CustomDrawSeriesPoint event functionality requires additional resources. Place points that should be customized into a separate series to improve performance.
- Specify the ChartControl.CacheToMemory property to true. This prevents a chart from unnecessary redrawing operations.
- The most suitable series view to represent a large amount of data is the SwiftPlotSeriesView. The Swift Plot lacks some elements and features available for other view types. These limitations allow this view to achieve the best possible performance. Refer to the Swift Plot Series View for more information.
- Use a single color to paint series points instead of applying the SeriesViewColorEachSupportBase.ColorEach property.
- Also note that each additional chart element (for example, a series point label) requires extra rendering time. This also applies to visual effects, for instance, chart elements' Shadow.
Customize the following parameters to optimize the Bar Series Views:
The runtime hit testing, selection and tooltips features require additional CPU and RAM resources and may decrease performance.
- The ChartControl.RuntimeHitTesting property is set to false by default. Leave this option disabled unless it is required.
- The ChartControl.SelectionMode property is specified as None by default. Leave this option disabled unless it is required.
- Use the Crosshair Cursor functionality instead of Tooltip.
This section contains tips that allow you to increase 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. Changing an existing SeriesPoint's argument or value results in unnecessary calculations. For example, changing the SeriesPoint.Values property calls the ChartControl.RefreshData method and updates the chart's data.
Since v17.1, the Chart Control completely processes the following event arguments to avoid reloading all the data when the chart is bound to a dataset that updates frequently:
- ListChangedEventArgs - obtained on the IBindingList.ListChanged;
- System.Collections.Specialized.NotifyCollectionChangedEventArgs - received on the INotifyCollectionChanged.CollectionChanged.
For this reason, use the IBindingList objects to process data efficiently when a chart frequently updates data.