React Chart Performance
React charts are optimized for high performance of rendering millions of data points and updating them every few milliseconds. However, there are several chart features that affect performance of the chart and they should be considered when optimizing performance in your application. This topic will guide you to make React charts work as fast as possible in your application.
React Chart Performance Examples
The following examples demonstrates two high performance scenarios of React charts.
React Chart with High-Frequency
In High-Frequency scenario, the React Charts can render data items that are updating in real time or at specified milliseconds intervals. You will experience no lag, no screen-flicker, and no visual delays, even as you interact with the chart on a touch-device. The following sample demonstrates the IgrCategoryChart
in High-Frequency scenario.
React Chart with High-Volume
In High-Volume scenario, the React Charts can render 1 million of data points while the chart keeps providing smooth performance when end-users tries zooming in/out or navigating chart content. The following sample demonstrates the IgrCategoryChart
in High-Volume scenario.
General Performance Guidelines
This section lists guidelines and chart features that add to the overhead and processing updates in the React charts.
Data Size
If you need to plot data sources with large number of data points (e.g. 10,000+), we recommend using React IgrDataChart
with one of the following type of series which where designed for specially for that purpose.
- Scatter HD Chart instead of Category Point Chart or Scatter Marker Chart
- Scatter Polyline Chart instead of Category Line Chart or Scatter Line Chart
- Scatter Polygon Chart instead of Category Area Chart or Column Chart
Data Structure
Although React charts support rendering of multiple data sources by binding array of arrays of data points to ItemsSource
property. It is much faster for charts if multiple data sources are flatten into single data source where each data item contains multiple data columns rather just one data column. For example:
this.CategoryChart.dataSource = FlattenDataSource.create();
this.FinancialChart.dataSource = FlattenDataSource.create();
export class FlattenDataSource {
public static create(): any[] {
const data: any[] = [];
data.push({ "Year": "1996", "USA": 148, "CHN": 110 });
data.push({ "Year": "2000", "USA": 142, "CHN": 115 });
return data;
}
}
// instead of this data structure:
export class MultiDataSources {
public static create(): any[] {
const dataSource1: any[] = [];
dataSource1.push({ "Year": "1996", "Value": 148 });
dataSource1.push({ "Year": "2000", "Value": 142 });
const dataSource2: any[] = [];
dataSource2.push({ "Year": "1996", "Value": 110 });
dataSource2.push({ "Year": "2000", "Value": 115 });
const multipleSources: any[] = [dataSource1, dataSource2];
return multipleSources;
}
}
Data Filtering
React IgrCategoryChart
and the IgrFinancialChart
controls have built-in data adapter that analyzes your data and generates chart series for you. However, it works faster if you use includedProperties
and excludedProperties
to filter only those data columns that you actually want to render. For example,
this.Chart.includedProperties = [ "Year", "USA", "RUS" ];
this.Chart.excludedProperties = [ "CHN", "FRN", "GER" ];
Chart Performance Guidelines
Chart Types
Simpler chart types such as Line Chart have faster performance than using Spline Chart because of the complex interpolation of spline lines between data points. Therefore, you should use chartType
property of React IgrCategoryChart
or the IgrFinancialChart
control to select type of chart that renders faster. Alternatively, you can change a type of series to a faster series in React IgrDataChart
control.
The following table lists chart types in order from the fastest performance to slower performance in each group of charts:
* Note that the Scatter Polygon Chart and Scatter Polyline Chart have better performance than rest of charts if you have a lot of data sources bound to the chart. For more info, see Series Collection section. Otherwise, other chart types are faster.
Chart Animations
Enabling Chart Animations will slightly delay final rendering series in the React charts while they play transition-in animations.
Chart Annotations
Enabling Chart Annotations such as the Callout Annotations, Crosshairs Annotations, or Final Value Annotations, will slightly decrease performance of the React chart.
Chart Highlighting
Enabling the Chart Highlighting will slightly decrease performance of the React chart.
Chart Legend
Adding a legend to the React charts might decrease performance if titles of series or data items mapped to legend are changing often at runtime.
Chart Markers
In React charts, Markers are especially expensive when it comes to chart performance because they add to the layout complexity of the chart, and perform data binding to obtain certain information. Also, markers decrease performance when there are a lot of data points or if there are many data sources bound. Therefore, if markers are not needed, they should be removed from the chart.
This code snippet shows how to remove markers from the React charts.
// on CategoryChart or FinancialChart
this.Chart.markerTypes.clear();
this.Chart.markerTypes.add(MarkerType.None);
// on LineSeries of DataChart
this.LineSeries.markerType = MarkerType.None;
Chart Resolution
Setting the resolution
property to a higher value will improve performance, but it will lower the graphical fidelity of lines of plotted series. As such, it can be increased up until the fidelity is unacceptable.
This code snippet shows how to decrease resolution in the React charts.
// on CategoryChart or FinancialChart:
this.Chart.Resolution = 10;
// on LineSeries of DataChart:
this.LineSeries.Resolution = 10;
Chart Overlays
Enabling Chart Overlays will slightly decrease performance of the React chart.
Chart Trendlines
Enabling Chart Trendlines will slightly decrease performance of the React chart.
Axis Types
Usage of x-axis with DateTime support is not recommended if spaces between data points, based on the amount of time span between them, are not important. Instead, ordinal/category axis should be used because it is more efficient in the way it coalesces data. Also, ordinal/category axis doesn’t perform any sorting on the data like the time-based x-axis does.
[!Note] The
IgrCategoryChart
already uses ordinal/category axis so there is no need to change its properties.
This code snippet shows how to ordinal/category x-axis in the IgrFinancialChart
and IgrDataChart
controls.
<IgrFinancialChart xAxisMode="Ordinal" />
<IgrDataChart>
<IgrCategoryXAxis label="Time" />
</IgrDataChart>
Axis Intervals
By default, React charts will automatically calculate yAxisInterval
based on range of your data. Therefore, you should avoid setting axis interval especially to a small value to prevent rendering of too many of axis gridlines and axis labels. Also, you might want to consider increasing yAxisInterval
property to a larger value than the automatically calculated axis interval if you do not need many axis gridlines or axis labels.
[!Note] We do not recommend setting axis minor interval as it will decrease chart performance.
This code snippet shows how to set axis major interval in the React charts.
<IgrCategoryChart xAxisInterval={5} yAxisInterval={50}/>
<IgrFinancialChart xAxisInterval={5} yAxisInterval={50}/>
<IgrDataChart>
<IgrCategoryXAxis name="xAxis" interval={5} />
<IgrNumericYAxis name="yAxis" interval={50}/>
</IgrDataChart>
Axis Scale
Setting the yAxisIsLogarithmic
property to false is recommended for higher performance, as fewer operations are needed than calculating axis range and values of axis labels in logarithmic scale.
Axis Labels Visibility
In the same way as Markers, axis labels are also expensive because they use templates and bindings, and may have their data context changed often. If labels are not used, they should be hidden or their interval should be increased to decrease number of axis labels.
This code snippet shows how to hide axis labels in the React charts.
<IgrCategoryChart xAxisLabelVisibility="Collapsed" yAxisLabelVisibility="Collapsed" />
<IgrFinancialChart xAxisLabelVisibility="Collapsed" yAxisLabelVisibility="Collapsed" />
<IgrDataChart>
<IgrCategoryXAxis name="xAxis" labelVisibility="Collapsed" />
<IgrNumericYAxis name="yAxis" labelVisibility="Collapsed" />
</IgrDataChart>
Axis Labels Abbreviation
Although, the React charts support abbreviation of large numbers (e.g. 10,000+) displayed in axis labels when yAxisAbbreviateLargeNumbers
is set to true. We recommend, instead pre-processing large values in your data items by dividing them a common factor and then setting yAxisTitle
to a string that represents factor used used to abbreviate your data values.
This code snippet shows how to set axis title in the React charts.
<IgrCategoryChart yAxisTitle="In millions of Dollars" />
<IgrFinancialChart yAxisTitle="In millions of Dollars" />
<IgrDataChart>
<IgrNumericYAxis title="In millions of Dollars" />
</IgrDataChart>
Axis Labels Extent
At runtime, the React charts adjust extent of labels on y-axis based on a label with longest value. This might decrease chart performance if range of data changes and labels need to be updated often. Therefore, it is recommended to set label extent at design time in order to improve chart performance.
The following code snippet shows how to set a fixed extent for labels on y-axis in the React charts.
<IgrCategoryChart xAxisLabelExtent={50} yAxisLabelExtent={50}/>
<IgrFinancialChart xAxisLabelExtent={50} yAxisLabelExtent={50}/>
<IgrDataChart>
<IgrCategoryXAxis name="xAxis" labelExtent={50} />
<IgrNumericYAxis name="yAxis" labelExtent={50} />
</IgrDataChart>
Axis Other Visuals
Enabling additional axis visuals (e.g. axis titles) or changing their default values might decrease performance in the React charts.
For example, changing these properties on the IgrCategoryChart
or IgrFinancialChart
control:
Axis Visual | X-Axis Properties | Y-Axis Properties |
---|---|---|
All Axis Visual | xAxisInterval xAxisMinorInterval |
yAxisInterval yAxisMinorInterval |
Axis Tickmarks | xAxisTickStroke xAxisTickStrokeThickness xAxisTickLength |
yAxisTickStroke yAxisTickStrokeThickness yAxisTickLength |
Axis Major Gridlines | xAxisMajorStroke xAxisMajorStrokeThickness |
yAxisMajorStroke yAxisMajorStrokeThickness |
Axis Minor Gridlines | xAxisMinorStroke xAxisMinorStrokeThickness |
yAxisMinorStroke yAxisMinorStrokeThickness |
Axis Main Line | xAxisStroke xAxisStrokeThickness |
yAxisStroke yAxisStrokeThickness |
Axis Titles | xAxisTitle xAxisTitleAngle |
yAxisTitle yAxisTitleAngle |
Axis Strips | xAxisStrip |
yAxisStrip |
Or changing properties of an IgrAxis
in the IgrDataChart
control:
Axis Visual | Axis Properties |
---|---|
All Axis Visuals | Interval , MinorInterval |
Axis Tickmarks | TickStroke , TickStrokeThickness , TickLength |
Axis Major Gridlines | MajorStroke , MajorStrokeThickness |
Axis Minor Gridlines | MinorStroke , MinorStrokeThickness |
Axis Main Line | Stroke , StrokeThickness |
Axis Titles | chartTitle , TitleAngle |
Axis Strips | Strip |
Performance in Financial Chart
In addition to above performance guidelines, the React IgrFinancialChart
control has the following unique features that affect performance.
Y-Axis Mode
Setting the yAxisMode
option to Numeric
is recommended for higher performance, as fewer operations are needed than using PercentChange
mode.
Chart Panes
Setting a lot of panes using indicatorTypes
and overlayTypes
options, might decrease performance and it is recommended to use a few financial indicators and one financial overlay.
Zoom Slider
Setting the zoomSliderType
option to None
will improve chart performance and enable more vertical space for other indicators and the volume pane.
Volume Type
Setting the volumeType
property can have the following impact on chart performance:
None
- is the least expensive since it does not display the volume pane.Line
- is more expensive volume type to render and it is recommended when rendering a lot of data points or when plotting a lot of data sources.Area
- is more expensive to render than theLine
volume type.Column
- is more expensive to render than theArea
volume type and it is recommended when rendering volume data of 1-3 stocks.
Performance in Data Chart
In addition to the general performance guidelines, the React IgrDataChart
control has the following unique features that affect performance.
Axes Collection
Adding too many axis to the Axes
collection of the IgrDataChart
control will decrease chart performance and we recommend Sharing Axes between series.
Series Collection
Also, adding a lot of series to the IgrSeries
collection of the React IgrDataChart
control will add overhead to rendering because each series has its own rendering canvas. This is especially important if you have more than 10 series in the Data Chart. We recommend combining multiple data sources into flatten data source (see Data Structure section) and then using conditional styling feature of the following series:
Slower Performance Scenario | Faster Scenario with Conditional Styling |
---|---|
10+ of IgrLineSeries |
Single IgrScatterLineSeries |
20+ of IgrLineSeries |
Single IgrScatterPolylineSeries |
10+ of IgrScatterLineSeries |
Single IgrScatterPolylineSeries |
10+ of IgrPointSeries |
Single IgrScatterSeries |
20+ of IgrPointSeries |
Single IgrHighDensityScatterSeries |
20+ of IgrScatterSeries |
Single IgrHighDensityScatterSeries |
10+ of IgrAreaSeries |
Single IgrScatterPolygonSeries |
10+ of IgrColumnSeries |
Single IgrScatterPolygonSeries |
Additional Resources
You can find more information about related chart types in these topics:
- Area Chart
- Bar Chart
- Bubble Chart
- Column Chart
- Donut Chart
- Pie Chart
- Point Chart
- Polar Chart
- Radial Chart
- Shape Chart
- Spline Chart
- Scatter Chart
- Stacked Chart
- Step Chart
- Stock Chart
- Chart Animations
- Chart Annotations
- Chart Highlighting
- Chart Markers
- Chart Overlays
- Chart Trendlines
API References
The following table lists API members mentioned in above sections: