@cdc/core 4.25.7 → 4.25.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/AdvancedEditor/AdvancedEditor.tsx +29 -8
- package/components/DataTable/DataTable.tsx +63 -11
- package/components/DataTable/DataTableStandAlone.tsx +4 -1
- package/components/DataTable/components/ChartHeader.tsx +58 -9
- package/components/DataTable/components/ExpandCollapse.tsx +21 -1
- package/components/DataTable/components/MapHeader.tsx +35 -7
- package/components/DataTable/data-table.css +6 -0
- package/components/DataTable/helpers/chartCellMatrix.tsx +11 -8
- package/components/DataTable/helpers/mapCellMatrix.tsx +19 -1
- package/components/DownloadButton.tsx +42 -13
- package/components/EditorPanel/DataTableEditor.tsx +10 -1
- package/components/EditorPanel/components/MarkupHighlightedTextField.tsx +227 -0
- package/components/EditorPanel/components/MarkupVariablesEditor.tsx +411 -0
- package/components/EditorPanel/components/PanelMarkup.tsx +59 -0
- package/components/ErrorBoundary.jsx +3 -1
- package/components/Filters/Filters.tsx +35 -11
- package/components/Filters/components/Tabs.tsx +1 -0
- package/components/Footnotes/FootnotesStandAlone.tsx +2 -1
- package/components/Legend/Legend.Gradient.tsx +3 -6
- package/components/LegendShape.tsx +121 -3
- package/components/{MediaControls.jsx → MediaControls.tsx} +80 -16
- package/components/PaletteConversionModal.tsx +87 -0
- package/components/PaletteSelector/DeveloperPaletteRollback.tsx +114 -0
- package/components/PaletteSelector/PaletteSelector.css +51 -0
- package/components/PaletteSelector/PaletteSelector.tsx +112 -0
- package/components/PaletteSelector/index.ts +2 -0
- package/components/RichTooltip/RichTooltip.tsx +1 -0
- package/components/Table/Table.tsx +3 -1
- package/components/_stories/BlurStrokeTest.stories.tsx +1 -1
- package/components/_stories/DataTable.stories.tsx +1 -1
- package/components/_stories/Filters.stories.tsx +1 -1
- package/components/_stories/Footnotes.stories.tsx +1 -1
- package/components/_stories/Inputs.stories.tsx +1 -1
- package/components/_stories/MultiSelect.stories.tsx +3 -3
- package/components/_stories/NestedDropdown.stories.tsx +1 -1
- package/components/_stories/Table.stories.tsx +1 -1
- package/components/elements/_stories/Button.stories.tsx +1 -1
- package/components/elements/_stories/Card.stories.tsx +1 -1
- package/components/inputs/InputToggle.tsx +2 -0
- package/components/managers/DataDesigner.tsx +10 -9
- package/components/managers/_stories/DataDesigner.stories.tsx +1 -1
- package/components/ui/Tooltip.tsx +2 -1
- package/components/ui/_stories/Accordion.stories.tsx +1 -1
- package/components/ui/_stories/ColorPaletteMigration.stories.mdx +275 -0
- package/components/ui/_stories/Colors.stories.tsx +330 -0
- package/components/ui/_stories/IconGallery.stories.tsx +316 -0
- package/components/ui/_stories/Title.stories.tsx +1 -1
- package/contexts/EditorContext.ts +18 -0
- package/contexts/editor.actions.ts +28 -0
- package/contexts/editor.reducer.ts +94 -0
- package/data/chartColorPalettes.ts +118 -0
- package/data/colorPalettes.ts +9 -0
- package/data/mapColorPalettes.ts +45 -0
- package/data/sharedPalettes.ts +50 -0
- package/dist/cove-main.css +14 -13
- package/dist/cove-main.css.map +1 -1
- package/generateViteConfig.js +80 -0
- package/helpers/addValuesToFilters.ts +2 -3
- package/helpers/cloneConfig.ts +31 -0
- package/helpers/configDataHelpers.ts +128 -0
- package/helpers/configHelpers.ts +27 -0
- package/helpers/constants.ts +5 -2
- package/helpers/cove/number.ts +6 -2
- package/helpers/coveUpdateWorker.ts +15 -3
- package/helpers/events.ts +32 -0
- package/helpers/filterColorPalettes.ts +152 -0
- package/helpers/generateColorsArray.ts +13 -0
- package/helpers/getColorPaletteVersion.ts +33 -0
- package/helpers/getPaletteAccessor.ts +18 -0
- package/helpers/markupProcessor.ts +205 -0
- package/helpers/metrics/helpers.ts +75 -0
- package/helpers/metrics/types.ts +82 -0
- package/helpers/metrics/utils.ts +34 -0
- package/helpers/palettes/colorDistributions.ts +56 -0
- package/helpers/palettes/migratePaletteName.ts +150 -0
- package/helpers/palettes/standardizePaletteNames.ts +77 -0
- package/helpers/palettes/utils.ts +267 -0
- package/helpers/queryStringUtils.ts +13 -0
- package/helpers/testing.ts +345 -0
- package/helpers/tests/addValuesToFilters.test.ts +1 -2
- package/helpers/tests/generateColorsArray.test.ts +24 -0
- package/helpers/tests/markupProcessor.test.ts +538 -0
- package/helpers/tests/testStandaloneBuild.ts +44 -0
- package/helpers/useMarkupVariables.ts +31 -0
- package/helpers/vegaConfig.ts +0 -1
- package/helpers/ver/4.24.10.ts +2 -1
- package/helpers/ver/4.24.11.ts +2 -1
- package/helpers/ver/4.24.3.ts +2 -1
- package/helpers/ver/4.24.4.ts +2 -1
- package/helpers/ver/4.24.5.ts +2 -1
- package/helpers/ver/4.24.7.ts +2 -1
- package/helpers/ver/4.24.9.ts +2 -1
- package/helpers/ver/4.25.1.ts +2 -1
- package/helpers/ver/4.25.10.ts +36 -0
- package/helpers/ver/4.25.3.ts +2 -1
- package/helpers/ver/4.25.4.ts +2 -1
- package/helpers/ver/4.25.6.ts +2 -1
- package/helpers/ver/4.25.7.ts +2 -1
- package/helpers/ver/4.25.8.ts +62 -0
- package/helpers/ver/4.25.9.ts +293 -0
- package/helpers/ver/tests/4.25.10.test.ts +204 -0
- package/helpers/ver/tests/4.25.8.test.ts +86 -0
- package/helpers/ver/tests/4.25.9.test.ts +51 -0
- package/helpers/viewports.ts +2 -0
- package/hooks/useColorPalette.ts +79 -0
- package/package.json +12 -4
- package/styles/_button-section.scss +0 -2
- package/styles/_global.scss +7 -5
- package/styles/base.scss +8 -5
- package/styles/v2/components/button.scss +4 -3
- package/styles/v2/components/editor.scss +2 -1
- package/styles/v2/layout/_data-table.scss +3 -2
- package/styles/v2/themes/_color-definitions.scss +18 -17
- package/testBuild.js +0 -0
- package/testing-setup.js +32 -0
- package/types/ForecastingSeriesKey.ts +0 -1
- package/types/MarkupInclude.ts +6 -1
- package/types/MarkupVariable.ts +19 -0
- package/types/Series.ts +4 -0
- package/types/Table.ts +1 -0
- package/types/VizFilter.ts +1 -0
- package/vitest.config.ts +16 -0
- package/components/ui/_stories/Colors.stories.mdx +0 -220
- package/components/ui/_stories/IconGallery.stories.mdx +0 -14
- package/data/colorPalettes.js +0 -171
- package/helpers/events.js +0 -14
- package/helpers/formatConfigBeforeSave.ts +0 -135
- package/helpers/tests/formatConfigBeforeSave.test.ts +0 -68
package/helpers/ver/4.24.7.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _ from 'lodash'
|
|
2
|
+
import cloneConfig from '../cloneConfig'
|
|
2
3
|
import { DashboardFilters } from '@cdc/dashboard/src/types/DashboardFilters'
|
|
3
4
|
import { MultiDashboardConfig } from '@cdc/dashboard/src/types/MultiDashboard'
|
|
4
5
|
import { AnyVisualization } from '../../types/Visualization'
|
|
@@ -130,7 +131,7 @@ const updateLogarithmicConfig = newConfig => {
|
|
|
130
131
|
const update_4_24_7 = config => {
|
|
131
132
|
const ver = '4.24.7'
|
|
132
133
|
|
|
133
|
-
const newConfig =
|
|
134
|
+
const newConfig = cloneConfig(config)
|
|
134
135
|
|
|
135
136
|
mapUpdates(newConfig)
|
|
136
137
|
dashboardFiltersMigrate(newConfig)
|
package/helpers/ver/4.24.9.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _ from 'lodash'
|
|
2
|
+
import cloneConfig from '../cloneConfig'
|
|
2
3
|
import { AnyVisualization } from '../../types/Visualization'
|
|
3
4
|
import { VizFilter } from '../../types/VizFilter'
|
|
4
5
|
import versionNeedsUpdate from './versionNeedsUpdate'
|
|
@@ -49,7 +50,7 @@ const supportLineStyledLegend = newConfig => {
|
|
|
49
50
|
|
|
50
51
|
const update_4_24_9 = config => {
|
|
51
52
|
const ver = '4.24.9'
|
|
52
|
-
const newConfig =
|
|
53
|
+
const newConfig = cloneConfig(config)
|
|
53
54
|
patchSingleStateZoom(newConfig)
|
|
54
55
|
addIdsToVisFilters(newConfig)
|
|
55
56
|
supportLineStyledLegend(config)
|
package/helpers/ver/4.25.1.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _ from 'lodash'
|
|
2
|
+
import cloneConfig from '../cloneConfig'
|
|
2
3
|
|
|
3
4
|
const removeTerritoriesLabel = config => {
|
|
4
5
|
if (config.general?.territoriesLabel) {
|
|
@@ -9,7 +10,7 @@ const removeTerritoriesLabel = config => {
|
|
|
9
10
|
|
|
10
11
|
const update_4_25_1 = config => {
|
|
11
12
|
const ver = '4.25.1'
|
|
12
|
-
const newConfig =
|
|
13
|
+
const newConfig = cloneConfig(config)
|
|
13
14
|
removeTerritoriesLabel(newConfig)
|
|
14
15
|
newConfig.version = ver
|
|
15
16
|
return newConfig
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import cloneConfig from '../cloneConfig'
|
|
2
|
+
import { DashboardConfig } from '@cdc/dashboard/src/types/DashboardConfig'
|
|
3
|
+
|
|
4
|
+
const migrateMarkupVariables = config => {
|
|
5
|
+
if (config.type === 'markup-include') {
|
|
6
|
+
// Move markupVariables from contentEditor to root level
|
|
7
|
+
if (config.contentEditor?.markupVariables) {
|
|
8
|
+
config.markupVariables = config.contentEditor.markupVariables
|
|
9
|
+
delete config.contentEditor.markupVariables
|
|
10
|
+
// Enable markup variables if any were found
|
|
11
|
+
if (config.markupVariables.length > 0) {
|
|
12
|
+
config.enableMarkupVariables = true
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
// Ensure markupVariables exists at root level
|
|
16
|
+
if (!config.markupVariables) {
|
|
17
|
+
config.markupVariables = []
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (config.type === 'dashboard') {
|
|
22
|
+
Object.values((config as DashboardConfig).visualizations).forEach(visualization => {
|
|
23
|
+
migrateMarkupVariables(visualization)
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const update_4_25_10 = config => {
|
|
29
|
+
const ver = '4.25.10'
|
|
30
|
+
const newConfig = cloneConfig(config)
|
|
31
|
+
migrateMarkupVariables(newConfig)
|
|
32
|
+
newConfig.version = ver
|
|
33
|
+
return newConfig
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default update_4_25_10
|
package/helpers/ver/4.25.3.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _ from 'lodash'
|
|
2
|
+
import cloneConfig from '../cloneConfig'
|
|
2
3
|
|
|
3
4
|
const remapTableDownloadCSV = config => {
|
|
4
5
|
if (config.general?.showDownloadButton !== undefined) {
|
|
@@ -32,7 +33,7 @@ const migrateAreaChart = config => {
|
|
|
32
33
|
|
|
33
34
|
const update_4_25_3 = config => {
|
|
34
35
|
const ver = '4.25.3'
|
|
35
|
-
const newConfig =
|
|
36
|
+
const newConfig = cloneConfig(config)
|
|
36
37
|
handleVisualizations(newConfig)
|
|
37
38
|
remapTableDownloadCSV(newConfig)
|
|
38
39
|
migrateAreaChart(newConfig)
|
package/helpers/ver/4.25.4.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _ from 'lodash'
|
|
2
|
+
import cloneConfig from '../cloneConfig'
|
|
2
3
|
|
|
3
4
|
export const makeChartLegendsUnified = config => {
|
|
4
5
|
if (config.type === 'chart') {
|
|
@@ -99,7 +100,7 @@ export const moveFootnotesToVizLevel = config => {
|
|
|
99
100
|
|
|
100
101
|
const update_4_25_4 = config => {
|
|
101
102
|
const ver = '4.25.4'
|
|
102
|
-
const newConfig =
|
|
103
|
+
const newConfig = cloneConfig(config)
|
|
103
104
|
makeChartLegendsUnified(newConfig)
|
|
104
105
|
migrateTableGeneralSettings(newConfig)
|
|
105
106
|
moveFootnotesToVizLevel(newConfig)
|
package/helpers/ver/4.25.6.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _ from 'lodash'
|
|
2
|
+
import cloneConfig from '../cloneConfig'
|
|
2
3
|
|
|
3
4
|
// *NOTE: This ends support for only showing the top prefix
|
|
4
5
|
export const changeOnlyShowTopSuffixToInlineLabel = config => {
|
|
@@ -27,7 +28,7 @@ export const changeOnlyShowTopSuffixToInlineLabel = config => {
|
|
|
27
28
|
|
|
28
29
|
const update_4_25_6 = config => {
|
|
29
30
|
const ver = '4.25.6'
|
|
30
|
-
const newConfig =
|
|
31
|
+
const newConfig = cloneConfig(config)
|
|
31
32
|
changeOnlyShowTopSuffixToInlineLabel(newConfig)
|
|
32
33
|
newConfig.version = ver
|
|
33
34
|
return newConfig
|
package/helpers/ver/4.25.7.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _ from 'lodash'
|
|
2
|
+
import cloneConfig from '../cloneConfig'
|
|
2
3
|
|
|
3
4
|
export const updatePreliminaryDataSeriesKeys = config => {
|
|
4
5
|
if (config.type === 'chart') {
|
|
@@ -17,7 +18,7 @@ export const updatePreliminaryDataSeriesKeys = config => {
|
|
|
17
18
|
|
|
18
19
|
const update_4_25_7 = config => {
|
|
19
20
|
const ver = '4.25.7'
|
|
20
|
-
const newConfig =
|
|
21
|
+
const newConfig = cloneConfig(config)
|
|
21
22
|
updatePreliminaryDataSeriesKeys(newConfig)
|
|
22
23
|
newConfig.version = ver
|
|
23
24
|
return newConfig
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import _ from 'lodash'
|
|
2
|
+
import cloneConfig from '../cloneConfig'
|
|
3
|
+
|
|
4
|
+
export const updateAxisColors = config => {
|
|
5
|
+
if (config.type === 'chart') {
|
|
6
|
+
if (config.xAxis) {
|
|
7
|
+
;['labelColor', 'tickLabelColor', 'tickColor'].forEach(k => {
|
|
8
|
+
if (config.xAxis[k] === '#333') {
|
|
9
|
+
config.xAxis[k] = '#1c1d1f'
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
}
|
|
13
|
+
if (config.yAxis) {
|
|
14
|
+
;[
|
|
15
|
+
'labelColor',
|
|
16
|
+
'tickLabelColor',
|
|
17
|
+
'tickColor',
|
|
18
|
+
'rightAxisLabelColor',
|
|
19
|
+
'rightAxisTickLabelColor',
|
|
20
|
+
'rightAxisTickColor'
|
|
21
|
+
].forEach(k => {
|
|
22
|
+
if (config.yAxis[k] === '#333') {
|
|
23
|
+
config.yAxis[k] = '#1c1d1f'
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
} else if (config.type === 'dashboard') {
|
|
28
|
+
Object.values(config.visualizations).forEach(visualization => {
|
|
29
|
+
updateAxisColors(visualization)
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const updateStatePickedToStatesPicked = config => {
|
|
35
|
+
if (config.type === 'map') {
|
|
36
|
+
if (config.general?.statePicked) {
|
|
37
|
+
config.general.statesPicked = [{ ...config.general.statePicked }]
|
|
38
|
+
delete config.general.statePicked
|
|
39
|
+
}
|
|
40
|
+
// Also migrate the property name for filter controls
|
|
41
|
+
if (config.general?.filterControlsStatePicked) {
|
|
42
|
+
config.general.filterControlsStatesPicked = config.general.filterControlsStatePicked
|
|
43
|
+
delete config.general.filterControlsStatePicked
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (config.type === 'dashboard') {
|
|
47
|
+
Object.values(config.visualizations).forEach(visualization => {
|
|
48
|
+
updateStatePickedToStatesPicked(visualization)
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const update_4_25_8 = config => {
|
|
54
|
+
const ver = '4.25.8'
|
|
55
|
+
const newConfig = cloneConfig(config)
|
|
56
|
+
updateAxisColors(newConfig)
|
|
57
|
+
updateStatePickedToStatesPicked(newConfig)
|
|
58
|
+
newConfig.version = ver
|
|
59
|
+
return newConfig
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default update_4_25_8
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import _ from 'lodash'
|
|
2
|
+
import { getFallbackColorPalette } from '../palettes/utils'
|
|
3
|
+
import { newChartPaletteNames, newMapPaletteNames } from '../palettes/standardizePaletteNames'
|
|
4
|
+
import cloneConfig from '../cloneConfig'
|
|
5
|
+
import { DashboardConfig } from '@cdc/dashboard/src/types/DashboardConfig'
|
|
6
|
+
|
|
7
|
+
const addMissingDataFormatFields = (config) => {
|
|
8
|
+
if (config.type === 'chart' && config.visualizationType === 'Pie') {
|
|
9
|
+
// if we're missing the show pie percent field
|
|
10
|
+
if (config.data?.showPiePercent === undefined) {
|
|
11
|
+
config.data = config.data || {}
|
|
12
|
+
config.data.showPiePercent = false
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (config.type === 'dashboard') {
|
|
17
|
+
Object.values(config.visualizations).forEach(visualization => {
|
|
18
|
+
addMissingDataFormatFields(visualization)
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const renameOriginalMapPalettes = config => {
|
|
24
|
+
if (config.general?.palette?.name && newMapPaletteNames[config.general.palette.name]) {
|
|
25
|
+
config.general.palette.name = newMapPaletteNames[config.general.palette.name]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const renameOriginalChartPalettes = config => {
|
|
30
|
+
if (config.general?.palette?.name && newChartPaletteNames[config.general.palette.name]) {
|
|
31
|
+
config.general.palette.name = newChartPaletteNames[config.general.palette.name]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const saveBackup = config => {
|
|
36
|
+
config.general = config.general || {}
|
|
37
|
+
config.general.palette = config.general.palette || {}
|
|
38
|
+
|
|
39
|
+
if (!config.general.palette) {
|
|
40
|
+
config.general = config.general || {}
|
|
41
|
+
config.general.palette = config.general.palette || {}
|
|
42
|
+
config.general.backups = config.general.palette.backups || []
|
|
43
|
+
config.general.palette.version = ''
|
|
44
|
+
}
|
|
45
|
+
const version = config?.general?.palette?.version || '1.0'
|
|
46
|
+
// Save a backup and set version to 1.0 for legacy palette names
|
|
47
|
+
if (version === '1.0' || !version) {
|
|
48
|
+
config.general.palette.version = '1.0'
|
|
49
|
+
config.general.palette.backups = config.general.palette.backups || []
|
|
50
|
+
config.general.palette.backups.push({
|
|
51
|
+
name: config.general.palette.name,
|
|
52
|
+
version: '1.0',
|
|
53
|
+
isReversed: config.general.palette.isReversed
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// On maps move config.color to config.general.colorPalettes.colorName
|
|
59
|
+
const movePaletteName = config => {
|
|
60
|
+
if (config.type === 'map') {
|
|
61
|
+
// Move config.color to a normalized area...
|
|
62
|
+
if (config.color) {
|
|
63
|
+
config.general = config.general || {}
|
|
64
|
+
config.general.palette = config.general.palette || {}
|
|
65
|
+
config.general.palette.name = config.color
|
|
66
|
+
const version = config.general.palette.version
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Rename default palette names to new standardized names in mapColorPalettes.ts
|
|
70
|
+
renameOriginalMapPalettes(config)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (config.type === 'chart') {
|
|
74
|
+
config.general = config.general || {}
|
|
75
|
+
config.general.palette = config.general.palette || {}
|
|
76
|
+
|
|
77
|
+
// Only set palette name if it doesn't already exist (avoid overriding new configs)
|
|
78
|
+
if (!config.general.palette.name) {
|
|
79
|
+
config.general.palette.name = config.palette || config.color || getFallbackColorPalette(config)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
renameOriginalChartPalettes(config)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (config.type === 'dashboard') {
|
|
86
|
+
Object.values(config.visualizations).forEach(visualization => {
|
|
87
|
+
movePaletteName(visualization)
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Move config.customColors to config.general.palette.customColors
|
|
93
|
+
const updateCustomColorsMigration = config => {
|
|
94
|
+
if (config.customColors) {
|
|
95
|
+
config.general = config.general || {}
|
|
96
|
+
config.general.palette = config.general.palette || {}
|
|
97
|
+
config.general.palette.customColors = config.customColors
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (config.type === 'dashboard') {
|
|
101
|
+
Object.values(config.visualizations).forEach(visualization => {
|
|
102
|
+
updateCustomColorsMigration(visualization)
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const addDefaultPaletteVersion = config => {
|
|
108
|
+
if (config.type === 'map' || config.type === 'chart') {
|
|
109
|
+
config.general = config.general || {}
|
|
110
|
+
config.general.palette = config.general.palette || {}
|
|
111
|
+
if (!config.general.palette.version || config.general.palette.version === '1.0') {
|
|
112
|
+
config.general.palette.version = '1.0'
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (config.type === 'dashboard') {
|
|
116
|
+
Object.values(config.visualizations).forEach(visualization => {
|
|
117
|
+
addDefaultPaletteVersion(visualization)
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export const changeSingleStateMapNoDataMessage = config => {
|
|
123
|
+
const changeMessage = config => {
|
|
124
|
+
const currentMessage = config.general.noStateFoundMessage || config.runtime?.noStateFoundMessage
|
|
125
|
+
delete config.general.noStateFoundMessage
|
|
126
|
+
delete config.runtime?.noStateFoundMessage
|
|
127
|
+
const isDefaultMessage = currentMessage === 'Map Unavailable'
|
|
128
|
+
// if message was customized, keep it.
|
|
129
|
+
config.general.noDataMessage = isDefaultMessage ? 'No State Selected' : currentMessage
|
|
130
|
+
}
|
|
131
|
+
if (config.type === 'map') {
|
|
132
|
+
changeMessage(config)
|
|
133
|
+
}
|
|
134
|
+
if (config.type === 'dashboard') {
|
|
135
|
+
Object.values((config as DashboardConfig).visualizations).forEach(visualization => {
|
|
136
|
+
if (visualization.type === 'map') {
|
|
137
|
+
changeMessage(visualization)
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Migration mapping for two-color palettes to divergent palettes
|
|
144
|
+
const twoColorPaletteMapping = {
|
|
145
|
+
'monochrome-1': 'divergent_blue_purple',
|
|
146
|
+
'monochrome-2': 'divergent_blue_purple',
|
|
147
|
+
'monochrome-3': 'divergent_blue_purple',
|
|
148
|
+
'monochrome-4': 'divergent_blue_purple',
|
|
149
|
+
'monochrome-5': 'divergent_green_orange',
|
|
150
|
+
'cool-1': 'divergent_blue_cyan',
|
|
151
|
+
'cool-2': 'divergent_blue_cyan',
|
|
152
|
+
'cool-3': 'divergent_blue_cyan',
|
|
153
|
+
'cool-4': 'divergent_blue_cyan',
|
|
154
|
+
'cool-5': 'divergent_blue_cyan',
|
|
155
|
+
'warm-1': 'divergent_green_orange',
|
|
156
|
+
'complementary-1': 'divergent_blue_orange',
|
|
157
|
+
'complementary-2': 'divergent_blue_orange',
|
|
158
|
+
'complementary-3': 'divergent_blue_orange',
|
|
159
|
+
'complementary-4': 'divergent_blue_orange',
|
|
160
|
+
'complementary-5': 'divergent_blue_orange'
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Migrate two-color palettes for paired bar and deviation charts
|
|
164
|
+
const migrateTwoColorPalettes = config => {
|
|
165
|
+
if (
|
|
166
|
+
config.type === 'chart' &&
|
|
167
|
+
(config.visualizationType === 'Paired Bar' || config.visualizationType === 'Deviation Bar')
|
|
168
|
+
) {
|
|
169
|
+
if (config.twoColor?.palette && twoColorPaletteMapping[config.twoColor.palette]) {
|
|
170
|
+
// Update general palette from twoColor settings
|
|
171
|
+
config.general = config.general || {}
|
|
172
|
+
config.general.palette = config.general.palette || {}
|
|
173
|
+
config.general.palette.name = twoColorPaletteMapping[config.twoColor.palette]
|
|
174
|
+
config.general.palette.isReversed = config.twoColor.isPaletteReversed || false
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (config.type === 'dashboard') {
|
|
179
|
+
Object.values(config.visualizations).forEach(visualization => {
|
|
180
|
+
migrateTwoColorPalettes(visualization)
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const normalizeForecastStageColors = config => {
|
|
186
|
+
if (config.type === 'chart' && config.series) {
|
|
187
|
+
const paletteVersion = config.general?.palette?.version === '2.0' ? 2 : 1
|
|
188
|
+
|
|
189
|
+
// Forecast palette migration map for v1 → v2 names (all lowercase-hyphen format)
|
|
190
|
+
const forecastPaletteMigrationMap = {
|
|
191
|
+
// Sequential Blue variants → sequential-blue
|
|
192
|
+
'sequential-blue': 'sequential-blue',
|
|
193
|
+
'sequential-blue-two': 'sequential-blue',
|
|
194
|
+
'sequential-blue-three': 'sequential-blue',
|
|
195
|
+
'sequential-blue-2-(mpx)': 'sequential-blue',
|
|
196
|
+
'sequential-blue-2-mpx': 'sequential-blue',
|
|
197
|
+
// Sequential Orange variants → sequential-orange
|
|
198
|
+
'sequential-orange': 'sequential-orange',
|
|
199
|
+
'sequential-orange-two': 'sequential-orange',
|
|
200
|
+
'sequential-orange-(mpx)': 'sequential-orange',
|
|
201
|
+
'sequential-orange-mpx': 'sequential-orange',
|
|
202
|
+
// Other sequential palettes (no variants, just normalize)
|
|
203
|
+
'sequential-green': 'sequential-green',
|
|
204
|
+
'sequential-purple': 'sequential-purple',
|
|
205
|
+
'sequential-teal': 'sequential-teal',
|
|
206
|
+
// Reverse variants - Sequential Blue
|
|
207
|
+
'sequential-bluereverse': 'sequential-bluereverse',
|
|
208
|
+
'sequential-blue-reverse': 'sequential-bluereverse',
|
|
209
|
+
'sequential-blue-tworeverse': 'sequential-bluereverse',
|
|
210
|
+
'sequential-blue-two-reverse': 'sequential-bluereverse',
|
|
211
|
+
'sequential-blue-threereverse': 'sequential-bluereverse',
|
|
212
|
+
'sequential-blue-three-reverse': 'sequential-bluereverse',
|
|
213
|
+
'sequential-blue-2-(mpx)reverse': 'sequential-bluereverse',
|
|
214
|
+
'sequential-blue-2-(mpx)-reverse': 'sequential-bluereverse',
|
|
215
|
+
'sequential-blue-2-mpxreverse': 'sequential-bluereverse',
|
|
216
|
+
'sequential-blue-2-mpx-reverse': 'sequential-bluereverse',
|
|
217
|
+
// Reverse variants - Sequential Orange
|
|
218
|
+
'sequential-orangereverse': 'sequential-orangereverse',
|
|
219
|
+
'sequential-orange-reverse': 'sequential-orangereverse',
|
|
220
|
+
'sequential-orange-tworeverse': 'sequential-orangereverse',
|
|
221
|
+
'sequential-orange-two-reverse': 'sequential-orangereverse',
|
|
222
|
+
'sequential-orange-(mpx)reverse': 'sequential-orangereverse',
|
|
223
|
+
'sequential-orange-(mpx)-reverse': 'sequential-orangereverse',
|
|
224
|
+
'sequential-orange-mpxreverse': 'sequential-orangereverse',
|
|
225
|
+
'sequential-orange-mpx-reverse': 'sequential-orangereverse',
|
|
226
|
+
// Reverse variants - Other sequential palettes
|
|
227
|
+
'sequential-greenreverse': 'sequential-greenreverse',
|
|
228
|
+
'sequential-green-reverse': 'sequential-greenreverse',
|
|
229
|
+
'sequential-purplereverse': 'sequential-purplereverse',
|
|
230
|
+
'sequential-purple-reverse': 'sequential-purplereverse',
|
|
231
|
+
'sequential-tealreverse': 'sequential-tealreverse',
|
|
232
|
+
'sequential-teal-reverse': 'sequential-tealreverse'
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
config.series.forEach(series => {
|
|
236
|
+
if (series.type === 'Forecasting' && series.stages) {
|
|
237
|
+
series.stages.forEach(stage => {
|
|
238
|
+
if (stage.color) {
|
|
239
|
+
// First, normalize to lowercase-hyphen format
|
|
240
|
+
let normalized = stage.color.toLowerCase().replace(/ /g, '-').replace(/_/g, '-')
|
|
241
|
+
// Then, migrate v1 palette names to v2 equivalents if applicable
|
|
242
|
+
stage.color = forecastPaletteMigrationMap[normalized] || normalized
|
|
243
|
+
}
|
|
244
|
+
})
|
|
245
|
+
}
|
|
246
|
+
})
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (config.type === 'dashboard') {
|
|
250
|
+
Object.values(config.visualizations).forEach(visualization => {
|
|
251
|
+
normalizeForecastStageColors(visualization)
|
|
252
|
+
})
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const cleanConfig = config => {
|
|
257
|
+
// remove config.palette
|
|
258
|
+
if (config.palette) {
|
|
259
|
+
delete config.palette
|
|
260
|
+
}
|
|
261
|
+
// remove config.color
|
|
262
|
+
if (config.color) {
|
|
263
|
+
delete config.color
|
|
264
|
+
}
|
|
265
|
+
// remove config.customColors
|
|
266
|
+
if (config.customColors) {
|
|
267
|
+
delete config.customColors
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (config.type === 'dashboard') {
|
|
271
|
+
Object.values(config.visualizations).forEach(visualization => {
|
|
272
|
+
cleanConfig(visualization)
|
|
273
|
+
})
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const update_4_25_9 = config => {
|
|
278
|
+
const ver = '4.25.9'
|
|
279
|
+
const newConfig = cloneConfig(config)
|
|
280
|
+
movePaletteName(newConfig)
|
|
281
|
+
updateCustomColorsMigration(newConfig)
|
|
282
|
+
migrateTwoColorPalettes(newConfig)
|
|
283
|
+
saveBackup(newConfig)
|
|
284
|
+
addDefaultPaletteVersion(newConfig)
|
|
285
|
+
normalizeForecastStageColors(newConfig)
|
|
286
|
+
cleanConfig(newConfig)
|
|
287
|
+
changeSingleStateMapNoDataMessage(newConfig)
|
|
288
|
+
addMissingDataFormatFields(newConfig)
|
|
289
|
+
newConfig.version = ver
|
|
290
|
+
return newConfig
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export default update_4_25_9
|