React Data GridSave / Restore Charts

Enterprise

This section shows how the Grid API can be used to save and restore charts.

Saving / Restoring Charts Copy Link

The example below demonstrates how you can save and then later restore a chart. You can make changes to the chart type, theme, data and formatting options and note how the restored chart looks the same as the chart that was saved.

  • Change the chart type, theme, data and/or formatting in order to see the changes restored later.
  • Click "Save chart" to persist a model of the visible chart into a local variable.
  • Click "Clear chart" to destroy the existing chart.
  • Click "Restore chart" to restore the previously saved chart.

API Reference Copy Link

A chart model that represent all the state information about the rendered charts can be obtained using getChartModels(). These models are returned in a format that can be easily used with the other API methods to later restore the chart.

getChartModelsCopy Link
Function
Returns a list of models with information about the charts that are currently rendered from the grid.

Properties available on the ChartModel interface.

versionCopy Link
string
string
modelTypeCopy Link
ChartModelType
ChartModelType
chartIdCopy Link
string
string
chartTypeCopy Link
ChartType
ChartType
cellRangeCopy Link
CellRangeParams
CellRangeParams
chartThemeNameCopy Link
string
string
AgChartThemeOverrides
AgChartThemePalette
suppressChartRangesCopy Link
boolean
boolean
switchCategorySeriesCopy Link
boolean
boolean
string | IAggFunc
unlinkChartCopy Link
boolean
boolean
seriesChartTypesCopy Link
SeriesChartType[]
SeriesChartType[]
seriesGroupTypeCopy Link
SeriesGroupType
SeriesGroupType

These models can then be supplied to the following grid api method to restore the charts:

restoreChartCopy Link
Function
Restores a chart using the ChartModel that was previously obtained from getChartModels().

Note that an optional chartContainer can be specified when restoring a chart.

Next Up Copy Link

Continue to the next section to learn about Chart Image Export.