@cdc/dashboard 4.24.5 → 4.24.9-1

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 (86) hide show
  1. package/dist/cdcdashboard.js +147572 -128223
  2. package/examples/custom/css/respiratory.css +236 -0
  3. package/examples/custom/js/respiratory.js +242 -0
  4. package/examples/default-multi-dataset-shared-filter.json +1729 -0
  5. package/examples/ed-visits-county-file.json +618 -0
  6. package/examples/filtered-dash.json +6 -21
  7. package/examples/single-state-dashboard-filters.json +421 -0
  8. package/examples/state-level.json +90136 -0
  9. package/examples/state-points.json +10474 -0
  10. package/examples/test-file.json +147 -0
  11. package/examples/testing.json +94456 -0
  12. package/index.html +25 -4
  13. package/package.json +12 -11
  14. package/src/CdcDashboard.tsx +5 -1
  15. package/src/CdcDashboardComponent.tsx +250 -327
  16. package/src/DashboardContext.tsx +15 -1
  17. package/src/_stories/Dashboard.stories.tsx +158 -40
  18. package/src/_stories/_mock/api-filter-chart.json +11 -35
  19. package/src/_stories/_mock/api-filter-map.json +17 -31
  20. package/src/_stories/_mock/bump-chart.json +3554 -0
  21. package/src/_stories/_mock/methodology.json +412 -0
  22. package/src/_stories/_mock/methodologyAPI.ts +90 -0
  23. package/src/_stories/_mock/multi-viz.json +3 -4
  24. package/src/_stories/_mock/pivot-filter.json +14 -12
  25. package/src/_stories/_mock/single-state-dashboard-filters.json +390 -0
  26. package/src/components/CollapsibleVisualizationRow.tsx +44 -0
  27. package/src/components/Column.tsx +1 -1
  28. package/src/components/DashboardFilters/DashboardFilters.tsx +102 -0
  29. package/src/components/DashboardFilters/DashboardFiltersEditor/DashboardFiltersEditor.tsx +218 -0
  30. package/src/components/DashboardFilters/DashboardFiltersEditor/components/DeleteFilterModal.tsx +48 -0
  31. package/src/components/DashboardFilters/DashboardFiltersEditor/components/FilterEditor.tsx +477 -0
  32. package/src/components/DashboardFilters/DashboardFiltersEditor/index.ts +1 -0
  33. package/src/components/DashboardFilters/DashboardFiltersWrapper.tsx +191 -0
  34. package/src/components/DashboardFilters/index.ts +3 -0
  35. package/src/components/DataDesignerModal.tsx +9 -9
  36. package/src/components/ExpandCollapseButtons.tsx +20 -0
  37. package/src/components/Header/Header.tsx +1 -102
  38. package/src/components/MultiConfigTabs/MultiConfigTabs.tsx +24 -12
  39. package/src/components/Row.tsx +52 -19
  40. package/src/components/Toggle/Toggle.tsx +2 -4
  41. package/src/components/VisualizationRow.tsx +169 -30
  42. package/src/components/VisualizationsPanel/VisualizationsPanel.tsx +116 -0
  43. package/src/components/VisualizationsPanel/index.ts +1 -0
  44. package/src/components/VisualizationsPanel/visualizations-panel-styles.css +12 -0
  45. package/src/components/Widget.tsx +27 -90
  46. package/src/helpers/FilterBehavior.ts +4 -0
  47. package/src/helpers/addValuesToDashboardFilters.ts +49 -0
  48. package/src/helpers/apiFilterHelpers.ts +103 -0
  49. package/src/helpers/changeFilterActive.ts +39 -0
  50. package/src/helpers/filterData.ts +10 -48
  51. package/src/helpers/generateValuesForFilter.ts +1 -1
  52. package/src/helpers/getAutoLoadVisualization.ts +11 -0
  53. package/src/helpers/getFilteredData.ts +7 -5
  54. package/src/helpers/getVizConfig.ts +23 -2
  55. package/src/helpers/getVizRowColumnLocator.ts +2 -1
  56. package/src/helpers/hasDashboardApplyBehavior.ts +5 -0
  57. package/src/helpers/iconHash.tsx +5 -3
  58. package/src/helpers/loadAPIFilters.ts +74 -0
  59. package/src/helpers/mapDataToConfig.ts +29 -0
  60. package/src/helpers/processData.ts +2 -3
  61. package/src/helpers/reloadURLHelpers.ts +102 -0
  62. package/src/helpers/tests/addValuesToDashboardFilters.test.ts +44 -0
  63. package/src/helpers/tests/apiFilterHelpers.test.ts +155 -0
  64. package/src/helpers/tests/filterData.test.ts +1 -93
  65. package/src/helpers/tests/getFilteredData.test.ts +86 -0
  66. package/src/helpers/tests/loadAPIFiltersWrapper.test.ts +220 -0
  67. package/src/helpers/tests/reloadURLHelpers.test.ts +232 -0
  68. package/src/scss/editor-panel.scss +1 -1
  69. package/src/scss/grid.scss +34 -27
  70. package/src/scss/main.scss +41 -3
  71. package/src/scss/variables.scss +4 -0
  72. package/src/store/dashboard.actions.ts +12 -4
  73. package/src/store/dashboard.reducer.ts +30 -4
  74. package/src/types/APIFilter.ts +1 -5
  75. package/src/types/ConfigRow.ts +2 -0
  76. package/src/types/Dashboard.ts +1 -1
  77. package/src/types/DashboardConfig.ts +2 -4
  78. package/src/types/DashboardFilters.ts +7 -0
  79. package/src/types/InitialState.ts +1 -1
  80. package/src/types/MultiDashboard.ts +2 -2
  81. package/src/types/SharedFilter.ts +4 -6
  82. package/src/types/Tab.ts +1 -1
  83. package/src/components/Filters.tsx +0 -88
  84. package/src/components/Header/FilterModal.tsx +0 -510
  85. package/src/components/VisualizationsPanel.tsx +0 -95
  86. package/src/helpers/getApiFilterKey.ts +0 -5
@@ -0,0 +1,412 @@
1
+ {
2
+ "dashboard": {
3
+ "theme": "theme-blue",
4
+ "sharedFilters": [
5
+ {
6
+ "key": "Year",
7
+ "showDropdown": true,
8
+ "type": "urlfilter",
9
+ "apiFilter": {
10
+ "apiEndpoint": "http://test.gov/methodology?$select=distinct year",
11
+ "valueSelector": "year"
12
+ },
13
+ "usedBy": ["none"],
14
+ "tier": 1
15
+ },
16
+ {
17
+ "key": "Methodology",
18
+ "showDropdown": false,
19
+ "type": "urlfilter",
20
+ "apiFilter": {
21
+ "apiEndpoint": "http://test.gov/methodology?$select=distinct methodology",
22
+ "valueSelector": "methodology"
23
+ },
24
+ "usedBy": ["chart1723488349579"],
25
+ "parents": ["Year"],
26
+ "tier": 2
27
+ }
28
+ ]
29
+ },
30
+ "rows": [
31
+ {
32
+ "columns": [
33
+ {
34
+ "width": 12,
35
+ "widget": "dashboardFilters1723488344936"
36
+ },
37
+ {},
38
+ {}
39
+ ]
40
+ },
41
+ {
42
+ "columns": [
43
+ {
44
+ "width": 12,
45
+ "widget": "dashboardFilters1723488344937"
46
+ },
47
+ {},
48
+ {}
49
+ ]
50
+ },
51
+ {
52
+ "columns": [
53
+ {
54
+ "width": 12,
55
+ "widget": "chart1723488349579"
56
+ }
57
+ ]
58
+ }
59
+ ],
60
+ "visualizations": {
61
+ "dashboardFilters1723488344936": {
62
+ "filters": [],
63
+ "filterBehavior": "Apply Button",
64
+ "openModal": true,
65
+ "uid": "dashboardFilters1723488344936",
66
+ "type": "dashboardFilters",
67
+ "sharedFilterIndexes": [0],
68
+ "visualizationType": "dashboardFilters"
69
+ },
70
+ "dashboardFilters1723488344937": {
71
+ "filters": [],
72
+ "filterBehavior": "Filter Change",
73
+ "openModal": true,
74
+ "autoLoad": true,
75
+ "uid": "dashboardFilters1723488344937",
76
+ "type": "dashboardFilters",
77
+ "sharedFilterIndexes": [1],
78
+ "visualizationType": "dashboardFilters"
79
+ },
80
+ "chart1723488349579": {
81
+ "annotations": [],
82
+ "type": "chart",
83
+ "debugSvg": false,
84
+ "chartMessage": {
85
+ "noData": "No Data Available"
86
+ },
87
+ "title": "",
88
+ "showTitle": true,
89
+ "showDownloadMediaButton": false,
90
+ "theme": "theme-blue",
91
+ "animate": false,
92
+ "fontSize": "medium",
93
+ "lineDatapointStyle": "hover",
94
+ "lineDatapointColor": "Same as Line",
95
+ "barHasBorder": "false",
96
+ "isLollipopChart": false,
97
+ "lollipopShape": "circle",
98
+ "lollipopColorStyle": "two-tone",
99
+ "visualizationSubType": "regular",
100
+ "barStyle": "",
101
+ "roundingStyle": "standard",
102
+ "tipRounding": "top",
103
+ "isResponsiveTicks": false,
104
+ "general": {
105
+ "annotationDropdownText": "Annotations",
106
+ "showDownloadButton": false,
107
+ "showMissingDataLabel": true,
108
+ "showSuppressedSymbol": true,
109
+ "showZeroValueDataLabel": true
110
+ },
111
+ "padding": {
112
+ "left": 5,
113
+ "right": 5
114
+ },
115
+ "preliminaryData": [],
116
+ "yAxis": {
117
+ "hideAxis": false,
118
+ "displayNumbersOnBar": false,
119
+ "hideLabel": false,
120
+ "hideTicks": false,
121
+ "size": 50,
122
+ "gridLines": false,
123
+ "enablePadding": false,
124
+ "min": "",
125
+ "max": "",
126
+ "labelColor": "#333",
127
+ "tickLabelColor": "#333",
128
+ "tickColor": "#333",
129
+ "rightHideAxis": true,
130
+ "rightAxisSize": 0,
131
+ "rightLabel": "",
132
+ "rightLabelOffsetSize": 0,
133
+ "rightAxisLabelColor": "#333",
134
+ "rightAxisTickLabelColor": "#333",
135
+ "rightAxisTickColor": "#333",
136
+ "numTicks": "",
137
+ "axisPadding": 0,
138
+ "scalePadding": 10,
139
+ "tickRotation": 0,
140
+ "anchors": [],
141
+ "shoMissingDataLabel": true,
142
+ "showMissingDataLine": true
143
+ },
144
+ "boxplot": {
145
+ "plots": [],
146
+ "borders": "true",
147
+ "firstQuartilePercentage": 25,
148
+ "thirdQuartilePercentage": 75,
149
+ "boxWidthPercentage": 40,
150
+ "plotOutlierValues": false,
151
+ "plotNonOutlierValues": true,
152
+ "legend": {
153
+ "showHowToReadText": false,
154
+ "howToReadText": ""
155
+ },
156
+ "labels": {
157
+ "q1": "Lower Quartile",
158
+ "q2": "q2",
159
+ "q3": "Upper Quartile",
160
+ "q4": "q4",
161
+ "minimum": "Minimum",
162
+ "maximum": "Maximum",
163
+ "mean": "Mean",
164
+ "median": "Median",
165
+ "sd": "Standard Deviation",
166
+ "iqr": "Interquartile Range",
167
+ "total": "Total",
168
+ "outliers": "Outliers",
169
+ "values": "Values",
170
+ "lowerBounds": "Lower Bounds",
171
+ "upperBounds": "Upper Bounds"
172
+ }
173
+ },
174
+ "topAxis": {
175
+ "hasLine": false
176
+ },
177
+ "isLegendValue": false,
178
+ "barThickness": 0.35,
179
+ "barHeight": 25,
180
+ "barSpace": 15,
181
+ "heights": {
182
+ "vertical": 300,
183
+ "horizontal": 750
184
+ },
185
+ "xAxis": {
186
+ "sortDates": false,
187
+ "anchors": [],
188
+ "type": "categorical",
189
+ "showTargetLabel": true,
190
+ "targetLabel": "Target",
191
+ "hideAxis": false,
192
+ "hideLabel": false,
193
+ "hideTicks": false,
194
+ "size": 75,
195
+ "tickRotation": 0,
196
+ "min": "",
197
+ "max": "",
198
+ "labelColor": "#333",
199
+ "tickLabelColor": "#333",
200
+ "tickColor": "#333",
201
+ "numTicks": "",
202
+ "labelOffset": 65,
203
+ "axisPadding": 200,
204
+ "target": 0,
205
+ "maxTickRotation": 0,
206
+ "dataKey": "state",
207
+ "tickWidthMax": 96
208
+ },
209
+ "table": {
210
+ "label": "Data Table",
211
+ "expanded": true,
212
+ "limitHeight": false,
213
+ "height": "",
214
+ "caption": "",
215
+ "showDownloadUrl": false,
216
+ "showDataTableLink": true,
217
+ "indexLabel": "",
218
+ "download": true,
219
+ "showVertical": true,
220
+ "dateDisplayFormat": "",
221
+ "showMissingDataLabel": true,
222
+ "showSuppressedSymbol": true,
223
+ "show": false
224
+ },
225
+ "orientation": "vertical",
226
+ "color": "pinkpurple",
227
+ "columns": {},
228
+ "legend": {
229
+ "hide": false,
230
+ "behavior": "isolate",
231
+ "axisAlign": true,
232
+ "singleRow": true,
233
+ "colorCode": "",
234
+ "reverseLabelOrder": false,
235
+ "description": "",
236
+ "dynamicLegend": false,
237
+ "dynamicLegendDefaultText": "Show All",
238
+ "dynamicLegendItemLimit": 5,
239
+ "dynamicLegendItemLimitMessage": "Dynamic Legend Item Limit Hit.",
240
+ "dynamicLegendChartMessage": "Select Options from the Legend",
241
+ "lineMode": false,
242
+ "verticalSorted": false,
243
+ "highlightOnHover": false,
244
+ "hideSuppressedLabels": false,
245
+ "seriesHighlight": []
246
+ },
247
+ "brush": {
248
+ "height": 25,
249
+ "active": false
250
+ },
251
+ "exclusions": {
252
+ "active": false,
253
+ "keys": []
254
+ },
255
+ "palette": "qualitative-bold",
256
+ "isPaletteReversed": false,
257
+ "twoColor": {
258
+ "palette": "monochrome-1",
259
+ "isPaletteReversed": false
260
+ },
261
+ "labels": false,
262
+ "dataFormat": {
263
+ "commas": false,
264
+ "prefix": "",
265
+ "suffix": "",
266
+ "abbreviated": false,
267
+ "bottomSuffix": "",
268
+ "bottomPrefix": "",
269
+ "bottomAbbreviated": false
270
+ },
271
+ "confidenceKeys": {},
272
+ "visual": {
273
+ "border": true,
274
+ "accent": true,
275
+ "background": true,
276
+ "verticalHoverLine": false,
277
+ "horizontalHoverLine": false
278
+ },
279
+ "useLogScale": false,
280
+ "filterBehavior": "Filter Change",
281
+ "highlightedBarValues": [],
282
+ "series": [
283
+ {
284
+ "dataKey": "value",
285
+ "type": "Bar",
286
+ "axis": "Left",
287
+ "tooltip": true
288
+ }
289
+ ],
290
+ "tooltips": {
291
+ "opacity": 90,
292
+ "singleSeries": false,
293
+ "dateDisplayFormat": ""
294
+ },
295
+ "forestPlot": {
296
+ "startAt": 0,
297
+ "colors": {
298
+ "line": "",
299
+ "shape": ""
300
+ },
301
+ "lineOfNoEffect": {
302
+ "show": true
303
+ },
304
+ "type": "",
305
+ "pooledResult": {
306
+ "diamondHeight": 5,
307
+ "column": ""
308
+ },
309
+ "estimateField": "",
310
+ "estimateRadius": "",
311
+ "shape": "square",
312
+ "rowHeight": 20,
313
+ "description": {
314
+ "show": true,
315
+ "text": "description",
316
+ "location": 0
317
+ },
318
+ "result": {
319
+ "show": true,
320
+ "text": "result",
321
+ "location": 100
322
+ },
323
+ "radius": {
324
+ "min": 2,
325
+ "max": 10,
326
+ "scalingColumn": ""
327
+ },
328
+ "regression": {
329
+ "lower": 0,
330
+ "upper": 0,
331
+ "estimateField": 0
332
+ },
333
+ "leftWidthOffset": 0,
334
+ "rightWidthOffset": 0,
335
+ "showZeroLine": false,
336
+ "leftLabel": "",
337
+ "rightLabel": ""
338
+ },
339
+ "area": {
340
+ "isStacked": false
341
+ },
342
+ "sankey": {
343
+ "title": {
344
+ "defaultColor": "black"
345
+ },
346
+ "iterations": 1,
347
+ "rxValue": 0.9,
348
+ "overallSize": {
349
+ "width": 900,
350
+ "height": 700
351
+ },
352
+ "margin": {
353
+ "margin_y": 25,
354
+ "margin_x": 0
355
+ },
356
+ "nodeSize": {
357
+ "nodeWidth": 26,
358
+ "nodeHeight": 40
359
+ },
360
+ "nodePadding": 55,
361
+ "nodeFontColor": "black",
362
+ "nodeColor": {
363
+ "default": "#ff8500",
364
+ "inactive": "#808080"
365
+ },
366
+ "linkColor": {
367
+ "default": "#ffc900",
368
+ "inactive": "#D3D3D3"
369
+ },
370
+ "opacity": {
371
+ "nodeOpacityDefault": 1,
372
+ "nodeOpacityInactive": 0.1,
373
+ "LinkOpacityDefault": 1,
374
+ "LinkOpacityInactive": 0.1
375
+ },
376
+ "storyNodeFontColor": "#006778",
377
+ "storyNodeText": [],
378
+ "nodeValueStyle": {
379
+ "textBefore": "(",
380
+ "textAfter": ")"
381
+ },
382
+ "data": []
383
+ },
384
+ "filters": [],
385
+ "openModal": true,
386
+ "uid": "chart1723488349579",
387
+ "visualizationType": "Bar",
388
+ "dataDescription": {
389
+ "horizontal": false,
390
+ "series": false
391
+ },
392
+ "dataKey": "hidden-methodology",
393
+ "version": "4.24.9",
394
+ "dynamicMarginTop": 0
395
+ }
396
+ },
397
+ "table": {
398
+ "label": "Data Table",
399
+ "show": true,
400
+ "showDownloadUrl": false,
401
+ "showVertical": true
402
+ },
403
+ "datasets": {
404
+ "hidden-methodology": {
405
+ "dataUrl": "http://test.gov/methodology"
406
+ }
407
+ },
408
+ "type": "dashboard",
409
+ "runtime": {},
410
+ "version": "4.24.9",
411
+ "uuid": 1723488346870
412
+ }
@@ -0,0 +1,90 @@
1
+ import _ from 'lodash'
2
+
3
+ export default function methodologyAPI(select: string, where?: [string, string | number]): Object[] {
4
+ const data = [
5
+ {
6
+ year: 1999,
7
+ methodology: 'a',
8
+ state: 'alabama',
9
+ value: '1'
10
+ },
11
+ {
12
+ year: 1999,
13
+ methodology: 'a',
14
+ state: 'alaska',
15
+ value: '2'
16
+ },
17
+ {
18
+ year: 1999,
19
+ methodology: 'a',
20
+ state: 'arizona',
21
+ value: '3'
22
+ },
23
+ {
24
+ year: 2012,
25
+ methodology: 'b',
26
+ state: 'new york',
27
+ value: '5'
28
+ },
29
+ {
30
+ year: 2012,
31
+ methodology: 'b',
32
+ state: 'new jersey',
33
+ value: '1'
34
+ },
35
+ {
36
+ year: 2012,
37
+ methodology: 'b',
38
+ state: 'new mexico',
39
+ value: '2'
40
+ },
41
+ {
42
+ year: 2000,
43
+ methodology: 'a',
44
+ state: 'alabama',
45
+ value: '4'
46
+ },
47
+ {
48
+ year: 2000,
49
+ methodology: 'a',
50
+ state: 'alaska',
51
+ value: '5'
52
+ },
53
+ {
54
+ year: 2000,
55
+ methodology: 'a',
56
+ state: 'arizona',
57
+ value: '6'
58
+ },
59
+ {
60
+ year: 2013,
61
+ methodology: 'b',
62
+ state: 'new york',
63
+ value: '6'
64
+ },
65
+ {
66
+ year: 2013,
67
+ methodology: 'b',
68
+ state: 'new jersey',
69
+ value: '7'
70
+ },
71
+ {
72
+ year: 2013,
73
+ methodology: 'b',
74
+ state: 'new mexico',
75
+ value: '8'
76
+ }
77
+ ]
78
+ const selectStatement = select.split(' ')
79
+ const distinct = selectStatement[0] === 'distinct'
80
+ const selectCol = selectStatement.length === 2 ? selectStatement[1] : selectStatement[0]
81
+ const rows = data
82
+ .filter(row => {
83
+ if (!where) return true
84
+ const [whereCol, whereVal] = where
85
+ return row[whereCol] === whereVal
86
+ })
87
+ .map(row => (selectCol === '*' ? row : { [selectCol]: row[selectCol] }))
88
+
89
+ return distinct ? _.uniqBy(rows, selectCol) : rows
90
+ }
@@ -3,7 +3,7 @@
3
3
  "theme": "theme-blue",
4
4
  "sharedFilters": [
5
5
  {
6
- "key": "Dashboard Filter 1",
6
+ "key": "Category",
7
7
  "type": "datafilter",
8
8
  "columnName": "Sample Categories",
9
9
  "showDropdown": true,
@@ -164,7 +164,7 @@
164
164
  },
165
165
  "table": {
166
166
  "label": "Data Table",
167
- "expanded": true,
167
+ "expanded": false,
168
168
  "limitHeight": false,
169
169
  "height": "",
170
170
  "caption": "",
@@ -366,11 +366,10 @@
366
366
  },
367
367
  "table": {
368
368
  "label": "Data Table",
369
- "show": true,
369
+ "show": false,
370
370
  "showDownloadUrl": false,
371
371
  "showVertical": true
372
372
  },
373
- "newViz": true,
374
373
  "datasets": {},
375
374
  "type": "dashboard",
376
375
  "runtime": {},
@@ -1,16 +1,7 @@
1
1
  {
2
2
  "dashboard": {
3
3
  "theme": "theme-blue",
4
- "sharedFilters": [
5
- {
6
- "key": "Race",
7
- "type": "datafilter",
8
- "showDropdown": true,
9
- "columnName": "Race",
10
- "pivot": "Age-adjusted rate",
11
- "usedBy": ["table1707935263149"]
12
- }
13
- ]
4
+ "sharedFilters": []
14
5
  },
15
6
  "rows": [
16
7
  [
@@ -32,7 +23,11 @@
32
23
  "show": true,
33
24
  "showDownloadUrl": false,
34
25
  "showVertical": true,
35
- "expanded": true
26
+ "expanded": true,
27
+ "pivot": {
28
+ "columnName": "Race",
29
+ "valueColumn": "Age-adjusted rate"
30
+ }
36
31
  },
37
32
  "columns": {},
38
33
  "dataFormat": {},
@@ -41,7 +36,14 @@
41
36
  "horizontal": false,
42
37
  "series": false
43
38
  },
44
- "filters": [],
39
+ "filters": [
40
+ {
41
+ "filterStyle": "multi-select",
42
+ "label": "Race",
43
+ "columnName": "Race",
44
+ "showDropdown": true
45
+ }
46
+ ],
45
47
  "filterBehavior": "Filter Change",
46
48
  "formattedData": [
47
49
  {