@cdc/core 4.24.5 → 4.24.9

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.
Files changed (109) hide show
  1. package/assets/icon-gear-multi.svg +23 -0
  2. package/components/AdvancedEditor/AdvancedEditor.tsx +93 -0
  3. package/components/AdvancedEditor/advanced-editor-styles.css +3 -0
  4. package/components/AdvancedEditor/index.ts +1 -0
  5. package/components/Alert/components/Alert.styles.css +15 -0
  6. package/components/Alert/components/Alert.tsx +39 -0
  7. package/components/Alert/index.tsx +3 -0
  8. package/components/DataTable/DataTable.tsx +127 -32
  9. package/components/DataTable/DataTableStandAlone.tsx +4 -25
  10. package/components/DataTable/components/DataTableEditorPanel.tsx +4 -4
  11. package/components/DataTable/components/ExpandCollapse.tsx +1 -1
  12. package/components/DataTable/helpers/chartCellMatrix.tsx +6 -12
  13. package/components/DataTable/helpers/getChartCellValue.ts +9 -5
  14. package/components/DataTable/helpers/getDataSeriesColumns.ts +10 -7
  15. package/components/DataTable/helpers/getRowType.ts +6 -0
  16. package/components/DataTable/helpers/mapCellMatrix.tsx +3 -3
  17. package/components/DataTable/types/TableConfig.ts +2 -1
  18. package/components/EditorPanel/ColumnsEditor.tsx +3 -30
  19. package/components/EditorPanel/DataTableEditor.tsx +66 -22
  20. package/components/EditorPanel/FieldSetWrapper.tsx +51 -0
  21. package/components/EditorPanel/FootnotesEditor.tsx +77 -0
  22. package/components/EditorPanel/Inputs.tsx +13 -4
  23. package/components/EditorPanel/VizFilterEditor/NestedDropdownEditor.tsx +268 -0
  24. package/components/EditorPanel/VizFilterEditor/VizFilterEditor.tsx +306 -0
  25. package/components/EditorPanel/VizFilterEditor/components/FilterOrder.tsx +40 -0
  26. package/components/EditorPanel/VizFilterEditor/index.ts +1 -0
  27. package/components/EditorWrapper/EditorWrapper.tsx +3 -4
  28. package/components/EditorWrapper/index.ts +1 -0
  29. package/components/Filters.tsx +520 -0
  30. package/components/Footnotes/Footnotes.tsx +25 -0
  31. package/components/Footnotes/FootnotesStandAlone.tsx +45 -0
  32. package/components/Footnotes/footnotes.css +5 -0
  33. package/components/Footnotes/index.ts +1 -0
  34. package/components/Layout/components/Responsive.tsx +14 -4
  35. package/components/Layout/components/Sidebar/components/Sidebar.tsx +14 -5
  36. package/components/Layout/components/Sidebar/components/sidebar.styles.scss +23 -20
  37. package/components/Layout/components/Visualization/index.tsx +19 -6
  38. package/components/Layout/components/Visualization/visualizations.scss +32 -26
  39. package/components/Layout/styles/editor.scss +0 -8
  40. package/components/Legend/Legend.Gradient.tsx +133 -0
  41. package/components/LegendShape.tsx +28 -0
  42. package/components/MultiSelect/MultiSelect.tsx +41 -11
  43. package/components/MultiSelect/multiselect.styles.css +0 -3
  44. package/components/NestedDropdown/NestedDropdown.tsx +47 -52
  45. package/components/NestedDropdown/nesteddropdown.styles.css +19 -25
  46. package/components/Table/Table.tsx +8 -5
  47. package/components/Table/components/Cell.tsx +2 -2
  48. package/components/Table/components/Row.tsx +25 -7
  49. package/components/_stories/Footnotes.stories.tsx +17 -0
  50. package/components/_stories/Layout.Debug.stories.tsx +91 -0
  51. package/components/_stories/_mocks/bar-chart-suppressed.json +474 -0
  52. package/components/_stories/styles.scss +14 -1
  53. package/components/createBarElement.jsx +4 -4
  54. package/components/inputs/InputSelect.tsx +17 -6
  55. package/components/ui/Icon.tsx +22 -16
  56. package/components/ui/Title/Title.scss +0 -8
  57. package/helpers/DataTransform.ts +2 -2
  58. package/helpers/addValuesToFilters.ts +135 -0
  59. package/helpers/cove/accessibility.ts +17 -4
  60. package/helpers/cove/fontSettings.ts +2 -0
  61. package/helpers/coveUpdateWorker.ts +30 -9
  62. package/helpers/filterVizData.ts +49 -0
  63. package/helpers/formatConfigBeforeSave.ts +95 -0
  64. package/helpers/gatherQueryParams.ts +14 -7
  65. package/helpers/getGradientLegendWidth.ts +15 -0
  66. package/helpers/getTextWidth.ts +18 -0
  67. package/helpers/lineChartHelpers.js +2 -1
  68. package/helpers/pivotData.ts +18 -0
  69. package/helpers/queryStringUtils.ts +29 -0
  70. package/helpers/scaling.ts +7 -0
  71. package/helpers/tests/addValuesToFilters.test.ts +55 -0
  72. package/helpers/tests/filterVizData.test.ts +31 -0
  73. package/helpers/tests/invertValue.test.ts +35 -0
  74. package/helpers/tests/updateFieldFactory.test.ts +1 -0
  75. package/helpers/updateFieldFactory.ts +1 -1
  76. package/helpers/updatePaletteNames.ts +19 -0
  77. package/helpers/{useDataVizClasses.js → useDataVizClasses.ts} +3 -2
  78. package/helpers/ver/4.24.5.ts +3 -3
  79. package/helpers/ver/4.24.7.ts +123 -0
  80. package/helpers/ver/4.24.9.ts +63 -0
  81. package/helpers/ver/tests/4.24.9.test.ts +22 -0
  82. package/helpers/ver/versionNeedsUpdate.ts +9 -0
  83. package/package.json +6 -4
  84. package/styles/_button-section.scss +7 -2
  85. package/styles/_data-table.scss +0 -1
  86. package/styles/_global.scss +6 -2
  87. package/styles/base.scss +4 -0
  88. package/styles/filters.scss +4 -0
  89. package/styles/v2/themes/_color-definitions.scss +1 -0
  90. package/types/Annotation.ts +46 -0
  91. package/types/Axis.ts +3 -2
  92. package/types/ConfigureData.ts +1 -1
  93. package/types/Dimensions.ts +1 -0
  94. package/types/Footnotes.ts +17 -0
  95. package/types/General.ts +5 -0
  96. package/types/Runtime.ts +2 -7
  97. package/types/Table.ts +6 -0
  98. package/types/Visualization.ts +31 -9
  99. package/types/VizFilter.ts +39 -7
  100. package/LICENSE +0 -201
  101. package/components/AdvancedEditor.jsx +0 -74
  102. package/components/EditorPanel/VizFilterEditor.tsx +0 -234
  103. package/components/Filters.jsx +0 -461
  104. package/components/LegendCircle.jsx +0 -17
  105. package/helpers/queryStringUtils.js +0 -26
  106. package/helpers/updatePaletteNames.js +0 -16
  107. package/types/BaseVisualizationType.ts +0 -1
  108. /package/components/{Waiting.jsx → Waiting.tsx} +0 -0
  109. /package/helpers/ver/{4.23.4.ts → 4.24.4.ts} +0 -0
@@ -43,7 +43,7 @@ export default function useDataVizClasses(config, viewport = null) {
43
43
  // Using short circuiting to check between charts & maps for now.
44
44
  const getListPosition = () => {
45
45
  if (legend?.position === 'side' && legend?.singleColumn) return 'legend-container__ul--single-column'
46
- if (legend?.position === 'bottom' && legend?.singleRow) return 'single-row'
46
+ if (legend?.position !== 'side' && legend?.singleRow) return 'single-row'
47
47
  if (legend?.verticalSorted && !legend?.singleRow) return 'vertical-sorted'
48
48
  return ''
49
49
  }
@@ -53,7 +53,8 @@ export default function useDataVizClasses(config, viewport = null) {
53
53
  ulClasses.push(getListPosition())
54
54
  return ulClasses
55
55
  }
56
- const legendOuterClasses = [`${legend?.position}`, `${getListPosition()}`, `cdcdataviz-sr-focusable`, `${viewport}`]
56
+ const hasBorder = config.legend?.hideBorder ? 'no-border' : ''
57
+ const legendOuterClasses = [`${legend?.position}`, `${getListPosition()}`, `cdcdataviz-sr-focusable`, `${viewport}`, `${hasBorder}`]
57
58
 
58
59
  const legendClasses = {
59
60
  aside: legendOuterClasses,
@@ -18,8 +18,8 @@ const migrateMarkupInclude = newConfig => {
18
18
  }
19
19
  }
20
20
 
21
- const update_4_24_4 = config => {
22
- const ver = '4.24.4'
21
+ const update_4_24_5 = config => {
22
+ const ver = '4.24.5'
23
23
 
24
24
  const newConfig = _.cloneDeep(config)
25
25
 
@@ -29,4 +29,4 @@ const update_4_24_4 = config => {
29
29
  return newConfig
30
30
  }
31
31
 
32
- export default update_4_24_4
32
+ export default update_4_24_5
@@ -0,0 +1,123 @@
1
+ import _ from 'lodash'
2
+ import { DashboardFilters } from '@cdc/dashboard/src/types/DashboardFilters'
3
+ import { MultiDashboardConfig } from '@cdc/dashboard/src/types/MultiDashboard'
4
+ import { AnyVisualization } from '../../types/Visualization'
5
+ import versionNeedsUpdate from './versionNeedsUpdate'
6
+
7
+ export const dashboardFiltersMigrate = config => {
8
+ if (!config.dashboard) return config
9
+ const dashboardConfig = config as MultiDashboardConfig
10
+ const newVisualizations = {}
11
+ // autoload was removed from APIFilter type
12
+ const newSharedFilters = (dashboardConfig.dashboard.sharedFilters || []).map(sf => {
13
+ if (sf.apiFilter?.autoLoad !== undefined) {
14
+ delete sf.apiFilter.autoLoad
15
+ }
16
+ if (sf.apiFilter?.defaultValue !== undefined) {
17
+ delete sf.apiFilter.defaultValue
18
+ }
19
+ return sf
20
+ })
21
+ config.dashboard.sharedFilters = newSharedFilters
22
+
23
+ Object.keys(dashboardConfig.visualizations).forEach(vizKey => {
24
+ const viz = dashboardConfig.visualizations[vizKey] as DashboardFilters
25
+ // hide was removed from visualizations
26
+ if (viz.hide !== undefined) {
27
+ viz.sharedFilterIndexes = newSharedFilters.map((_sf, i) => i).filter(i => !viz.hide.includes(i))
28
+ viz.type = 'dashboardFilters'
29
+ if (viz.autoLoad) {
30
+ viz.filterBehavior = 'Filter Change'
31
+ } else {
32
+ viz.filterBehavior = 'Apply Button'
33
+ }
34
+
35
+ delete viz.hide
36
+ }
37
+ // 'filter-dropdowns' was renamed to 'dashboardFilters' for clarity
38
+ if (viz.type === 'filter-dropdowns') {
39
+ viz.type = 'dashboardFilters'
40
+ viz.visualizationType = 'dashboardFilters'
41
+ if (!viz.sharedFilterIndexes) {
42
+ viz.sharedFilterIndexes = config.dashboard.sharedFilters.map((_sf, i) => i)
43
+ viz.filterBehavior = config.filterBehavior || 'Filter Change'
44
+ }
45
+ }
46
+
47
+ // Premature convertion to 4.24.7 made us add this fix
48
+ if (viz.type === 'dashboardFilters' && !viz.sharedFilterIndexes) {
49
+ viz.sharedFilterIndexes = config.dashboard.sharedFilters.map((_sf, i) => i)
50
+ viz.filterBehavior = config.filterBehavior || 'Filter Change'
51
+ }
52
+ newVisualizations[vizKey] = viz
53
+ })
54
+
55
+ if (config.dashboard.sharedFilters.length && !Object.values(newVisualizations).find((v: AnyVisualization) => v.type === 'dashboardFilters')) {
56
+ const newViz = {
57
+ type: 'dashboardFilters',
58
+ visualizationType: 'dashboardFilters',
59
+ sharedFilterIndexes: config.dashboard.sharedFilters.map((_sf, i) => i),
60
+ filterBehavior: config.filterBehavior || 'Filter Change'
61
+ }
62
+ const key = 'legacySharedFilters'
63
+ newVisualizations[key] = newViz
64
+ const newRow = {
65
+ columns: [
66
+ {
67
+ width: 12,
68
+ widget: key
69
+ }
70
+ ]
71
+ }
72
+ config.rows = [newRow, ...config.rows]
73
+ config.dashboard.sharedFilters = config.dashboard.sharedFilters.map(sf => {
74
+ if (sf.usedBy) {
75
+ // Fixes usedBy Rows
76
+ sf.usedBy = sf.usedBy.map(key => {
77
+ if (!(parseInt(key) > -1)) return key
78
+ return String(parseInt(key) + 1)
79
+ })
80
+ }
81
+ return sf
82
+ })
83
+ }
84
+ // if there's no dashboardFilters visualization but there are sharedFilters create a visualization and update rows.
85
+
86
+ config.visualizations = newVisualizations
87
+ delete config.filterBehavior // deprecated
88
+ }
89
+
90
+ const mapUpdates = newConfig => {
91
+ // When switching between old version of equal number, and the revised equal number opt in, roundToPlace needs to be set.
92
+ // There wasn't an initial value set for this, and legends would return NaN if it wasn't set. ie. 0 - NAN instead of 0 - 1
93
+ const equalNumberRoundingPatch = newConfig => {
94
+ if (newConfig.type === 'map') {
95
+ if (newConfig.columns.primary.roundToPlace === undefined) {
96
+ newConfig.columns.primary.roundToPlace = 0
97
+ }
98
+ }
99
+ }
100
+
101
+ equalNumberRoundingPatch(newConfig)
102
+
103
+ return newConfig
104
+ }
105
+
106
+ const updateLogarithmicConfig = newConfig => {
107
+ if (newConfig.useLogScale) {
108
+ newConfig.yAxis.type === 'logarithmic'
109
+ }
110
+ }
111
+
112
+ const update_4_24_7 = config => {
113
+ const ver = '4.24.7'
114
+
115
+ const newConfig = _.cloneDeep(config)
116
+
117
+ mapUpdates(newConfig)
118
+ dashboardFiltersMigrate(newConfig)
119
+ updateLogarithmicConfig(newConfig)
120
+ newConfig.version = versionNeedsUpdate(config.version, ver) ? ver : config.version
121
+ return newConfig
122
+ }
123
+ export default update_4_24_7
@@ -0,0 +1,63 @@
1
+ import { Legend } from './../../types/Legend'
2
+ import _ from 'lodash'
3
+ import { AnyVisualization } from '../../types/Visualization'
4
+ import { VizFilter } from '../../types/VizFilter'
5
+ import { AnyVisualization } from '../../types/Visualization'
6
+ import { VizFilter } from '../../types/VizFilter'
7
+ import versionNeedsUpdate from './versionNeedsUpdate'
8
+
9
+ /**
10
+ * Updates the configuration object to disable map zooming for single state maps in a dashboard.
11
+ * when the config is below version 4.24.9
12
+ */
13
+ const patchSingleStateZoom = config => {
14
+ if (config.type === 'dashboard') {
15
+ Object.values(config?.visualizations || {}).forEach((viz: AnyVisualization) => {
16
+ if (viz.type === 'map' && viz.general?.geoType === 'single-state') {
17
+ // if the version is less that 4.24.7 then allowMapZoom should be false
18
+ let allowZoom = versionNeedsUpdate(config.version, '4.24.9') ? false : viz.general.allowMapZoom
19
+ viz.general.allowMapZoom = allowZoom
20
+ }
21
+ })
22
+ }
23
+ if (config.type === 'map' && config.general?.geoType === 'single-state') {
24
+ // if the version is less that 4.24.7 then allowMapZoom should be false
25
+ let allowZoom = versionNeedsUpdate(config.version, '4.24.9') ? false : config.general.allowMapZoom
26
+ config.general.allowMapZoom = allowZoom
27
+ }
28
+ }
29
+
30
+ const doesNotHaveIds = (filters: VizFilter[]) => filters?.some(f => !f.id)
31
+
32
+ export const addIdsToVisFilters = config => {
33
+ if (config.type === 'dashboard') {
34
+ config.visualizations = Object.keys(config.visualizations).reduce((acc, curr) => {
35
+ const viz: AnyVisualization & { filters: VizFilter[] } = config.visualizations[curr]
36
+ if (viz.filters?.length && doesNotHaveIds(viz.filters)) {
37
+ acc[curr].filters = viz.filters.map((filter, i) => ({ ...filter, id: Date.now() + i }))
38
+ }
39
+ return acc
40
+ }, config.visualizations)
41
+ } else if (config.filters?.length && doesNotHaveIds(config.filters)) {
42
+ config.filters = config.filters.map((filter, i) => ({ ...filter, id: Date.now() + i }))
43
+ }
44
+ }
45
+
46
+ const supportLineStyledLegend = newConfig => {
47
+ // support for Charts
48
+ if (newConfig.legend?.lineMode) {
49
+ newConfig.legend.style = 'lines'
50
+ }
51
+ }
52
+
53
+ const update_4_24_9 = config => {
54
+ const ver = '4.24.9'
55
+ const newConfig = _.cloneDeep(config)
56
+ patchSingleStateZoom(newConfig)
57
+ addIdsToVisFilters(newConfig)
58
+ supportLineStyledLegend(config)
59
+ newConfig.version = ver
60
+ return newConfig
61
+ }
62
+
63
+ export default update_4_24_9
@@ -0,0 +1,22 @@
1
+ import { addIdsToVisFilters } from '../4.24.9'
2
+ import { coveUpdateWorker } from '../../coveUpdateWorker'
3
+ import { expect, describe, it } from 'vitest'
4
+
5
+ describe('addIdsToVisFilters', () => {
6
+ it('adds ids to vis filters on dashboards', () => {
7
+ const mockConfig = { type: 'dashboard', visualizations: { a: { filters: [{}] } } } as any
8
+ addIdsToVisFilters(mockConfig)
9
+ expect(mockConfig.visualizations.a.filters[0].id).toBeDefined()
10
+ })
11
+ it('adds ids to vis filters on non dashboards', () => {
12
+ const mockConfig = { filters: [{}] } as any
13
+ addIdsToVisFilters(mockConfig)
14
+ expect(mockConfig.filters[0].id).toBeDefined()
15
+ })
16
+ it('adds ids to nested multi-dashboards', () => {
17
+ const mockConfig = { type: 'dashboard', rows: [], visualizations: { a: { filters: [{}] } }, multiDashboards: [{ rows: [], visualizations: { a: { filters: [{}] } } }] }
18
+ const convertedConfig = coveUpdateWorker(mockConfig)
19
+ expect(convertedConfig.visualizations.a.filters[0].id).toBeDefined()
20
+ expect(convertedConfig.multiDashboards[0].visualizations.a.filters[0].id).toBeDefined()
21
+ })
22
+ })
@@ -0,0 +1,9 @@
1
+ export default function versionNeedsUpdate(previousVersion: string, currentVersion: string): boolean {
2
+ if (!previousVersion) return true
3
+ const [prevMajor, prevMinor, prevPatch] = previousVersion.split('.').map(Number)
4
+ const [currMajor, currMinor, currPatch] = currentVersion.split('.').map(Number)
5
+ if (currMajor > prevMajor) return true
6
+ if (currMajor === prevMajor && currMinor > prevMinor) return true
7
+ if (currMajor === prevMajor && currMinor === prevMinor && currPatch > prevPatch) return true
8
+ return false
9
+ }
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@cdc/core",
3
- "version": "4.24.5",
3
+ "version": "4.24.9",
4
4
  "description": "Core components, styles, hooks, and helpers, for the CDC Open Visualization project",
5
5
  "moduleName": "CdcCore",
6
6
  "main": "dist/cdccore",
7
7
  "scripts": {
8
- "test": "vitest watch --reporter verbose --globals true",
9
- "test:ui": "vitest --ui"
8
+ "test": "vitest run --environment jsdom --reporter verbose",
9
+ "test-watch": "vitest watch --reporter verbose",
10
+ "test-watch:ui": "vitest --ui"
10
11
  },
11
12
  "repository": {
12
13
  "type": "git",
@@ -20,6 +21,7 @@
20
21
  "license": "Apache-2.0",
21
22
  "dependencies": {
22
23
  "html2canvas": "^1.4.1",
24
+ "json-edit-react": "^1.12.0",
23
25
  "papaparse": "^5.3.0",
24
26
  "prop-types": "^15.8.1",
25
27
  "react-accessible-accordion": "^5.0.0",
@@ -31,5 +33,5 @@
31
33
  "react": "^18.2.0",
32
34
  "react-dom": "^18.2.0"
33
35
  },
34
- "gitHead": "def85aaf4cd9dc1983e80f2900199f35de82af95"
36
+ "gitHead": "c4b0402afe6ed209a85b7078711549b9fd7dae7d"
35
37
  }
@@ -14,13 +14,18 @@
14
14
 
15
15
  // links that appear above data tables
16
16
  .download-links {
17
- padding: 0px 1em;
18
17
  display: flex;
19
18
  justify-content: flex-end;
20
-
19
+ width: 100%;
20
+ &.brush-active {
21
+ margin-top: 2em;
22
+ }
21
23
  a:not(:last-child) {
22
24
  margin-right: 10px;
23
25
  }
26
+ & a {
27
+ font-size: 16px;
28
+ }
24
29
  }
25
30
 
26
31
  // odd wrapper thats different on dashboards
@@ -13,7 +13,6 @@ div.data-table-heading {
13
13
  background: rgba(0, 0, 0, 0.05);
14
14
  padding: 0.5em 0.7em;
15
15
  border: $lightGray 1px solid;
16
- border-bottom: 0;
17
16
  cursor: pointer;
18
17
 
19
18
  svg {
@@ -181,7 +181,11 @@ select {
181
181
  }
182
182
 
183
183
  section.introText {
184
- padding: 15px;
184
+ width: 100%;
185
+ margin-bottom: 25px;
186
+ &.legend_visible_top {
187
+ margin-bottom: 0;
188
+ }
185
189
  }
186
190
 
187
191
  section.footnotes {
@@ -191,7 +195,7 @@ section.footnotes {
191
195
  }
192
196
 
193
197
  .cdc-chart-inner-container .subtext {
194
- padding: 15px;
198
+ padding: 15px 0;
195
199
  }
196
200
 
197
201
  .margin-left-href {
package/styles/base.scss CHANGED
@@ -77,6 +77,10 @@ body.post-type-cdc_visualization .cdc-editor .configure .editor-panel {
77
77
  @import 'series-list';
78
78
  @import 'typography';
79
79
 
80
+ input[type='range'] {
81
+ appearance: auto !important;
82
+ }
83
+
80
84
  // Force printing chart images
81
85
  -webkit-print-color-adjust: exact !important; /* Chrome, Safari 6 – 15.3, Edge */
82
86
  color-adjust: exact !important; /* Firefox 48 – 96 */
@@ -28,6 +28,10 @@ section.filters-section {
28
28
  border-radius: 10px;
29
29
  margin-bottom: 10px;
30
30
  display: block !important;
31
+
32
+ &.legend_visible_top {
33
+ margin-bottom: 0px;
34
+ }
31
35
  }
32
36
 
33
37
  div.single-filters {
@@ -76,6 +76,7 @@ $theme: (
76
76
  .markup-include,
77
77
  .type-waffle-chart,
78
78
  .type-data-bite,
79
+ .type-filtered-text,
79
80
  .cdc-open-viz-module.type-chart.type-sparkline,
80
81
  .cove {
81
82
  @each $theme-name, $theme-colors in $theme {
@@ -0,0 +1,46 @@
1
+ export type Annotation = {
2
+ // background opacity of annotation
3
+ opacity: number
4
+ // HTML text string to display in annotation
5
+ text: string
6
+ // can the user edit/drag the annotation
7
+ edit: {
8
+ subject: boolean
9
+ label: boolean
10
+ }
11
+ // if the connectionType is curve - allow choosing a visx curve type
12
+ lineType: string
13
+ // anchor points for lines
14
+ anchor: {
15
+ horizontal: boolean
16
+ vertical: boolean
17
+ }
18
+ // x value for scaling
19
+ xKey: string
20
+ // y value for scaling
21
+ yKey: string
22
+ // orignal x value of subject
23
+ originalX: number
24
+ // x of subject
25
+ x: number
26
+ // y of object
27
+ y: number
28
+ // x offset of label from subject
29
+ dx: number
30
+ // y offset of label from subject
31
+ dy: number
32
+ // assigned series that the annotation should snap to
33
+ seriesKey: string
34
+ // if the dragged item should be snapped to the nearest point
35
+ snapToNearestPoint: boolean
36
+ // type of connecting line from label to subject
37
+ connectionType: 'line' | 'curve' | 'elbow' | 'none'
38
+ // marker type highlighting the subject
39
+ marker: 'arrow' | 'circle'
40
+ // should the item be snapped to the subject?
41
+ snapToSubject: boolean
42
+ // savedDimensions - the original dimensions of the svg when the svg was saved
43
+ savedDimensions: [width: number, height: number]
44
+ // displayDropdown - whether or not to show the mobile dropdown on desktop for annotations
45
+ displayDropdown?: boolean
46
+ }
package/types/Axis.ts CHANGED
@@ -5,6 +5,7 @@ export type Anchor = {
5
5
  }
6
6
 
7
7
  export type Axis = {
8
+ categories: [{ label: string; height: string; color: string }]
8
9
  scalePadding: number
9
10
  anchors?: Anchor[]
10
11
  dataKey: string
@@ -37,12 +38,12 @@ export type Axis = {
37
38
  sortDates?: boolean
38
39
  sortKey?: string
39
40
  showTargetLabel?: boolean
40
- showSuppressedLine: boolean
41
- showSuppressedSymbol: boolean
42
41
  size?: number
43
42
  target?: number
44
43
  targetLabel?: string
45
44
  tickRotation?: number
46
45
  tickWidthMax?: number
47
46
  type: string
47
+ axisBBox: number
48
+ maxValue: string
48
49
  }
@@ -2,7 +2,7 @@ import { DataDescription } from './DataDescription'
2
2
 
3
3
  export type ConfigureData = {
4
4
  dataDescription: Partial<DataDescription>
5
- data: Object[]
5
+ data?: Object[]
6
6
  formattedData?: Object[]
7
7
  dataKey: string // This is the key of the dataset in the config
8
8
  }
@@ -0,0 +1 @@
1
+ export type DimensionsType = [number, number]
@@ -0,0 +1,17 @@
1
+ import { Visualization } from './Visualization'
2
+
3
+ export type Footnote = {
4
+ symbol?: string
5
+ text: string
6
+ }
7
+
8
+ type Footnotes = Visualization & {
9
+ dynamicFootnotes?: {
10
+ symbolColumn?: string
11
+ textColumn: string
12
+ orderColumn?: string
13
+ }
14
+ staticFootnotes?: Footnote[]
15
+ }
16
+
17
+ export default Footnotes
package/types/General.ts CHANGED
@@ -6,4 +6,9 @@ export type General = {
6
6
  type: string
7
7
  showDownloadButton: boolean
8
8
  allowMapZoom?: boolean
9
+ showMissingDataLabel: boolean
10
+ showSuppressedSymbol: boolean
11
+ showAnnotationDropdown?: boolean
12
+ hideNullValue: boolean
13
+ title: string
9
14
  }
package/types/Runtime.ts CHANGED
@@ -7,13 +7,8 @@ export type ForecastingSeriesKey = {
7
7
  }[]
8
8
  }
9
9
 
10
- export type BarSeriesKey = {
11
- key: string
12
- color: string
13
- }
14
-
15
10
  export type Runtime = {
16
- barSeriesKeys?: BarSeriesKey[]
11
+ barSeriesKeys?: string[]
17
12
  forecastingSeriesKeys?: ForecastingSeriesKey[]
18
13
  originalXAxis: {
19
14
  dataKey: string
@@ -26,7 +21,7 @@ export type Runtime = {
26
21
  seriesLabels: Record<string, any>
27
22
  seriesLabelsAll: string[]
28
23
  editorErrorMessage: string
29
- lineSeriesKeys: any[]
24
+ lineSeriesKeys?: string[]
30
25
  horizontal: boolean
31
26
  uniqueId: number | string
32
27
  }
package/types/Table.ts CHANGED
@@ -1,3 +1,8 @@
1
+ type Pivot = {
2
+ columnName: string
3
+ valueColumn: string
4
+ }
5
+
1
6
  export type Table = {
2
7
  caption?: string
3
8
  cellMinWidth?: number
@@ -14,6 +19,7 @@ export type Table = {
14
19
  indexLabel?: string
15
20
  label?: string
16
21
  limitHeight?: boolean
22
+ pivot?: Pivot
17
23
  show?: boolean
18
24
  showDataTableLink?: boolean
19
25
  showDownloadImgButton?: boolean
@@ -4,40 +4,62 @@ import { Column } from './Column'
4
4
  import { Series } from './Series'
5
5
  import { Table } from './Table'
6
6
  import { ConfidenceInterval } from './ConfidenceInterval'
7
- import { BaseVisualizationType } from './BaseVisualizationType'
8
7
  import { ConfigureData } from './ConfigureData'
9
8
  import { VizFilter } from './VizFilter'
10
9
  import { FilterBehavior } from './FilterBehavior'
11
10
  import { General } from './General'
11
+ import { Runtime } from './Runtime'
12
+ import { DashboardFilters } from '@cdc/dashboard/src/types/DashboardFilters'
12
13
 
13
- export type Visualization = ConfigureData & {
14
- autoLoad: boolean
14
+ // This was originally created as a catchall for the different types of visualizations.
15
+ // Currently it includes properties that ares specific to one Visualization type.
16
+ // We should avoid adding any new property to this type unless it is used by all visualizations.
17
+ // We should refactor it also to remove properties that are not used by all visualizations.
18
+ // See AnyVisualization type below...
19
+ type DeprecatedVisualizationType = {
15
20
  columns: Record<string, Partial<Column>>
16
21
  confidenceKeys: ConfidenceInterval
17
22
  dataFileName: string
18
23
  dataFileSourceType: string
19
24
  dataFormat: any
20
25
  datasets: Record<string, any>
21
- editing: boolean
22
- filterBehavior: FilterBehavior
23
26
  filters: VizFilter[]
24
27
  general: General
25
- hide: any[]
26
28
  legend: Legend
27
29
  multiDashboards?: any[]
28
30
  newViz: boolean
29
31
  openModal: boolean
30
32
  orientation: 'vertical' | 'horizontal'
31
33
  originalFormattedData: any
34
+ runtime?: Runtime
32
35
  series: Series
33
- showEditorPanel: boolean
34
36
  table: Table
35
37
  theme: string
36
38
  title: string
37
- type: BaseVisualizationType
38
- uid: string // this is the actual key of the visualization object
39
+ type: 'dashboard' | 'chart' | 'footnotes' | 'map' | 'data-bite' | 'waffle-chart' | 'markup-include' | 'filtered-text' | 'table' | 'navigation'
39
40
  usesSharedFilter: any
40
41
  visualizationSubType: string
41
42
  visualizationType: string
42
43
  xAxis: Axis
44
+ preliminaryData: { type: 'effect' | 'suppression'; value: string }[]
45
+ }
46
+
47
+ type StatefulProperties = {
48
+ editing: boolean
49
+ newViz: boolean
43
50
  }
51
+
52
+ export type CommonVisualizationProperties = Partial<StatefulProperties> & {
53
+ showEditorPanel?: boolean
54
+ uid?: string // this is the actual key of the visualization object
55
+ visualizationType?: string
56
+ filterBehavior: FilterBehavior
57
+ } & Partial<ConfigureData>
58
+
59
+ export type Visualization = DeprecatedVisualizationType & CommonVisualizationProperties
60
+
61
+ // This type is used as a catchall for the different types of visualizations.
62
+ // We should create a specific type for each visualization type and add it to this list.
63
+ // We will remove Visualization from this list once we have all union types listed.
64
+ // All of the New types will extend CommonVisualizationProperties.
65
+ export type AnyVisualization = Visualization | DashboardFilters
@@ -1,13 +1,45 @@
1
- export type VizFilter = {
2
- active: string
1
+ export type OrderBy = 'asc' | 'desc' | 'cust'
2
+
3
+ export type FilterBase = {
3
4
  columnName: string
4
- filterStyle: 'tab' | 'pill' | 'tab bar' | 'dropdown'
5
+ values: string[]
6
+ showDropdown: boolean
7
+ id: number
8
+ parents: number[]
9
+ }
10
+
11
+ export type VizFilterStyle =
12
+ | 'tab'
13
+ | 'pill'
14
+ | 'tab bar'
15
+ | 'dropdown'
16
+ | 'dropdown bar'
17
+ | 'multi-select'
18
+ | 'nested-dropdown'
19
+ export type GeneralFilter = FilterBase & {
20
+ active: string
21
+ queuedActive: string
22
+ filterStyle: VizFilterStyle
5
23
  label: string
6
- order: 'asc' | 'desc' | 'cust'
7
- orderedValues?: string[]
24
+ order: OrderBy
25
+ orderedValues?: string[] // should only exist if the order is 'cust'
8
26
  queryParameter: string
9
27
  setByQueryParameter: string
10
- showDropdown: boolean
28
+ subGrouping: SubGrouping
11
29
  type: 'url'
12
- values: string[]
13
30
  }
31
+
32
+ export type MultiSelectFilter = {
33
+ active: string[]
34
+ selectLimit: number
35
+ } & Omit<GeneralFilter, 'active'>
36
+
37
+ export type SubGrouping = {
38
+ active: string
39
+ columnName: string
40
+ setByQueryParameter: string
41
+ order?: OrderBy
42
+ valuesLookup: Record<string, { orderedValues?: string[]; values: string[] }>
43
+ }
44
+
45
+ export type VizFilter = GeneralFilter | MultiSelectFilter