DevExtreme v24.2 is now available.

Explore our newest features/capabilities and share your thoughts with us.

Your search did not match any results.

React Charts - Dynamic Series from the DataSource

In certain scenarios, you may need to add more series to the data source after you created the Chart.

In this case, arrange your data source structure as follows:

Every object in the data source should correspond to a point in a single series.

To give you the ability to edit code on the fly, the demo uses SystemJS. For this reason, launching the demo takes some time. We strongly recommend that you do not use this approach in real projects.
Backend API

This demo uses the structure displayed above to organize data:

To define series, use the commonSeriesSettings object to specify common settings for all series: the argumentField, the valueField, and the type.

Then, use the seriesTemplate configuration object to define a template for the series. Within this object, assign the data source field that specifies the series name to the nameField property.

If you need to specify individual values for properties of a particular series, assign a callback function to the customizeSeries property of the seriesTemplate object. This demo uses the customizeSeries function to display a line instead of a bar for year: 2009.