GraphConfig structure, this guide will help you migrate to the new config schema.
This page documents the helper exported by @graphysdk/core:
This function is intended for migrating configs that you have already persisted (e.g. in a database). Rather than calling it on-the-fly every time you render a graph, we recommend running the migration once on your stored data and saving the result in the new format.
Key differences
| Aspect | Legacy config | New config |
|---|---|---|
| Data structure | data (array of rows) + datasetConfig (columns) | data with columns and rows |
| Chart type | visualisationConfig.type | type (top-level) |
| Chart options | Scattered across visualisationConfig | Grouped in options |
| Text content | titleDocument, caption, sourceLabel, sourceUrl | Grouped in content |
| Number formatting | numberFormat (top-level) | appearance.numberFormat |
| Annotations | annotations | annotations (flatter structure) |
Inputs
The migration function accepts a set of props for the old version ofGraphProvider:
Your existing legacy config object.
Skip this if you were not previously passing a
theme prop to GraphProvider.Skip this if you were not previously passing a
customPalettes prop to GraphProvider.Outputs
The return value is a new set ofGraphProvider props:
The migrated config in the new format. Always present.
Only present if
visualisationConfig.locale was set in your legacy config.Only present if
visualisationConfig.locale was set in your legacy config.Only present if
fontList was set in your legacy config. The legacy config persisted this inside config. The new version expects it as a separate GraphProvider prop instead.Full example
Property mapping reference
This table shows how legacy config properties map to the new structure:Data
| Legacy | New |
|---|---|
data (array of rows) | data.rows |
datasetConfig.properties | data.columns |
datasetConfig.properties[].key | data.columns[].key |
datasetConfig.properties[].label | data.columns[].label |
datasetConfig.properties[].isHidden | data.columns[]._metadata.isHidden |
datasetConfig.dateFormat | data._metadata.parsingLocale |
datasetConfig.isDataHorizontal | data._metadata.isDataTransposed |
datasetConfig.shouldAggregate | data._metadata.isAggregated |
Chart type and options
| Legacy | New |
|---|---|
visualisationConfig.type | type |
visualisationConfig.curveType | options.isSmoothLine |
visualisationConfig.lineThickness | options.lineThickness |
visualisationConfig.showPoints | options.showPoints |
visualisationConfig.treatEmptyValues | options.missingValues |
visualisationConfig.sortBars | options.sortBars |
visualisationConfig.pointSize | options.pointSize |
visualisationConfig.comboPlotType | options.comboType |
visualisationConfig.pieTotalPosition | options.pieTotalPosition |
Axes
| Legacy | New |
|---|---|
visualisationConfig.topAxisLabel .rightAxisLabel .bottomAxisLabel .leftAxisLabel | axes.x.label / axes.y.label |
visualisationConfig.hideMainAxis | axes.x.isHidden / axes.y.isHidden |
visualisationConfig.hideCrossAxis | axes.y.isHidden / axes.x.isHidden |
visualisationConfig.useLogScale | axes.y.scaleType / axes.x.scaleType |
visualisationConfig.customYAxisStartFrom | axes.y.min / axes.x.min |
visualisationConfig.customYAxisEndAt | axes.y.max / axes.x.max |
visualisationConfig.hasGridLines | axes.showGridLines |
visualisationConfig.comboPlotAxisCount | axes.hasDualYAxis |
Content
| Legacy | New |
|---|---|
titleDocument (first node) | content.title |
titleDocument (remaining nodes) | content.subtitle |
caption | content.caption |
sourceLabel | content.source.label |
sourceUrl | content.source.url |
customAppearanceConfig.shouldHideTitle | content.isTitleHidden |
customAppearanceConfig.shouldHideSubtitle | content.isSubtitleHidden |
customAppearanceConfig.shouldHideCaption | content.isCaptionHidden |
customAppearanceConfig.shouldHideSourceSection | content.isSourceHidden |
Appearance
| Legacy | New |
|---|---|
customAppearanceConfig.theme | appearance.palette / appearance.paletteId |
customAppearanceConfig.seriesConfig | appearance.seriesStyles |
customAppearanceConfig.shouldTintBackground | appearance.backgroundModifier |
customAppearanceConfig.borderType | appearance.border.style |
customAppearanceConfig.borderColor | appearance.border.color |
customAppearanceConfig.borderStroke | appearance.border.width |
customAppearanceConfig.hasRoundedCorners | appearance.hasRoundedCorners |
customAppearanceConfig.font | appearance.textStyle |
customAppearanceConfig.textScale | appearance.textScale |
customAppearanceConfig.highlightStyle | appearance.highlightStyle |
customAppearanceConfig.shouldHideLogo | appearance.isLogoHidden |
numberFormat | appearance.numberFormat |
customAppearanceConfig.disableTooltips | appearance.showTooltips (inverted) |
customAppearanceConfig.disableAnimation | appearance.animateTransitions (inverted) |
Data labels and headline numbers
| Legacy | New |
|---|---|
visualisationConfig.showDataLabels | dataLabels.showDataLabels |
visualisationConfig.showPercentageLabels | dataLabels.dataLabelFormat |
visualisationConfig.showStackTotals | dataLabels.showStackTotals |
visualisationConfig.showCategoryLabels | dataLabels.showCategoryLabels |
visualisationConfig.headlineMetric | headlineNumbers.show |
visualisationConfig.headlineMetricComparisonValue | headlineNumbers.compareWith |
visualisationConfig.headlineMetricSize | headlineNumbers.size |
Reference lines
| Legacy | New |
|---|---|
visualisationConfig.customPowerUp (goal) | referenceLines.goalLine |
visualisationConfig.yGoalValue | referenceLines.goalLine.target |
visualisationConfig.xGoalValue | referenceLines.goalLine.marker |
visualisationConfig.presetPowerUp (trendline) | referenceLines.trendline |
visualisationConfig.trendLineType | referenceLines.trendline |
visualisationConfig.presetPowerUp (average) | referenceLines.averageLine |
visualisationConfig.averageLineSeriesKey | referenceLines.averageLine.columnKey |
Related
- GraphConfig schema - Complete schema reference for the new config
- GraphProvider - All available props