Skip to main content

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

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
Non-Aggregated Data Aggregated Data

Loading Data

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.

  • Enclose the code that adds points in the ChartControl.BeginInit and ChartControl.EndInit methods’ calls to avoid frequent chart updates:

    chartControl.BeginInit();
    for(int i = 0; i < PointsCount; i++) {
        chartControl.Diagram.Series[0].Points.Add(new SeriesPoint(i, i));
    }
    chartControl.EndInit();
    
  • Add points to the series in a single operation instead of adding each point separately:

    SeriesPoint[] points = new SeriesPoint[PointsCount];
    for (int i = 0; i < PointsCount; i++) {
        points[i] = new SeriesPoint(i, i);
    }
    chartControl.Diagram.Series[0].Points.AddRange(points);
    
  • Series with added points are rendered faster than series bound to a data source or automatically generated series.

  • 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.

Automatic Resampling

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 Calculations

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.

Visual Elements

Follow the steps below to decrease the time needed to render a chart’s visual elements:

Interactivity Optimization

The selection and tooltips features require additional CPU and RAM resources and may decrease performance.

Changeable Data

This section contains tips to enhance performance when a chart shows a dataset that changes frequently.

For this reason, use the IBindingList and ObservableCollection<T> objects to provide data to the chart control when it should display data that updates frequently.

See Also