@cdc/dashboard 4.25.3 → 4.25.6-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 (63) hide show
  1. package/Dynamic_Data.md +79 -0
  2. package/Override_Data.md +39 -0
  3. package/dist/cdcdashboard.js +76052 -77984
  4. package/examples/legend-issue-data.json +1874 -0
  5. package/examples/legend-issue.json +749 -0
  6. package/examples/map.json +628 -0
  7. package/examples/special-classes.json +54340 -0
  8. package/index.html +1 -26
  9. package/package.json +10 -15
  10. package/src/CdcDashboardComponent.tsx +65 -216
  11. package/src/_stories/Dashboard.stories.tsx +2 -0
  12. package/src/_stories/_mock/api-filter-map.json +43 -1
  13. package/src/components/CollapsibleVisualizationRow.tsx +4 -6
  14. package/src/components/DashboardEditors.tsx +143 -0
  15. package/src/components/DashboardFilters/DashboardFilters.tsx +205 -205
  16. package/src/components/DashboardFilters/DashboardFiltersEditor/DashboardFiltersEditor.tsx +286 -287
  17. package/src/components/DashboardFilters/DashboardFiltersEditor/components/APIModal.tsx +129 -0
  18. package/src/components/DashboardFilters/DashboardFiltersEditor/components/FilterEditor.tsx +680 -652
  19. package/src/components/DashboardFilters/DashboardFiltersWrapper.tsx +198 -198
  20. package/src/components/DataDesignerModal.tsx +33 -14
  21. package/src/components/Header/Header.tsx +7 -9
  22. package/src/components/MultiConfigTabs/multiconfigtabs.styles.css +3 -0
  23. package/src/components/Row.tsx +2 -24
  24. package/src/components/VisualizationRow.tsx +191 -214
  25. package/src/helpers/getVizConfig.ts +93 -80
  26. package/src/helpers/getVizRowColumnLocator.ts +0 -1
  27. package/src/helpers/reloadURLHelpers.ts +11 -6
  28. package/src/helpers/shouldLoadAllFilters.ts +30 -30
  29. package/src/index.tsx +2 -1
  30. package/src/scss/main.scss +0 -5
  31. package/src/store/dashboard.actions.ts +61 -62
  32. package/src/store/dashboard.reducer.ts +15 -11
  33. package/src/types/ConfigRow.ts +0 -1
  34. package/src/types/Dashboard.ts +1 -1
  35. package/src/types/DashboardConfig.ts +1 -1
  36. package/src/types/SharedFilter.ts +2 -0
  37. package/examples/private/DEV-10120.json +0 -1294
  38. package/examples/private/DEV-10527.json +0 -845
  39. package/examples/private/DEV-10586.json +0 -54319
  40. package/examples/private/DEV-10856.json +0 -54319
  41. package/examples/private/DEV-9199.json +0 -606
  42. package/examples/private/DEV-9644.json +0 -20092
  43. package/examples/private/DEV-9684.json +0 -2135
  44. package/examples/private/DEV-9932.json +0 -95
  45. package/examples/private/DEV-9989.json +0 -229
  46. package/examples/private/art-dashboard.json +0 -18174
  47. package/examples/private/art-scratch.json +0 -2406
  48. package/examples/private/bird-flu-2.json +0 -440
  49. package/examples/private/bird-flu.json +0 -413
  50. package/examples/private/dashboard-config-ehdi.json +0 -29915
  51. package/examples/private/dashboard-map-filter.json +0 -815
  52. package/examples/private/dashboard-margins.js +0 -15
  53. package/examples/private/dataset.json +0 -1452
  54. package/examples/private/dev-10856-2.json +0 -1348
  55. package/examples/private/ehdi-data.json +0 -29502
  56. package/examples/private/exposure-source-h5-data.csv +0 -26
  57. package/examples/private/fatal-data.csv +0 -3159
  58. package/examples/private/feelings.json +0 -1
  59. package/examples/private/gaza-issue.json +0 -1214
  60. package/examples/private/markup.json +0 -115
  61. package/examples/private/nhis.json +0 -1792
  62. package/examples/private/workforce.json +0 -2041
  63. package/src/types/DataSet.ts +0 -11
@@ -0,0 +1,79 @@
1
+ # Building an API for COVE
2
+
3
+ COVE's URL data sources are able to work along side dashboard URL Filters to dynamically generate query strings for API requests. These query strings are intendent to be flexible and generic so that they can work with different API structures, however most APIs built for COVE at the time of writing this follow the behavior of (Socrata)[https://dev.socrata.com/docs/queries/].
4
+
5
+ To triger a data source to pull dynamic data make sure a `dataUrl` is present in the config.
6
+
7
+ Example (1):
8
+
9
+ ```
10
+ "datasets": {
11
+ "cove_app_api": {
12
+ "dataFileSize": 1292219,
13
+ "dataFileName": "https://cdc.gov/cove_app_api",
14
+ "dataFileSourceType": "url",
15
+ "dataFileFormat": "JSON",
16
+ "dataUrl": "https://cdc.gov/cove_app_api"
17
+ }
18
+ }
19
+ ```
20
+
21
+ The `cove_app_api` data source can be mapped to a visualization or row using `cove_app_api` as the `dataKey`.
22
+
23
+ # Working with `urlfilter` type Filters
24
+
25
+ Dashboards have a section called `sharedFilters` that is mapped over to gather any relevant filter values to include in dynamic API calls. `urlfilter` types have an `apiEndpoint`, located in the `apiFilter` section, which is fetched to provide options for the filter. At runtime this data response uses the `valueSelector` in the `apiFilter` section to cache filter values in the sharedFilter item (optionaly `textSelector` can be configured show a different text to the user than the raw value).
26
+
27
+ After all required selections are made the `sharedFilters` are mapped over to gather query parameters to attach to the dynamic datasets. If the sharedFilter item has a list of `usedBy` identifiers the query parameters will only apply to datasets that are mapped to those respective visualizations or rows, conversly if there's now `usedBy` or the list is empty the sharedFilter item will apply it's query parameter(s) to all dynamic datasets used by the current dashboard.
28
+
29
+ Example (2):
30
+
31
+ ```
32
+ "sharedFilters": [
33
+ {
34
+ "key": "Dataset",
35
+ "showDropdown": true,
36
+ "tier": 1,
37
+ "type": "urlfilter",
38
+ "apiFilter": {
39
+ "apiEndpoint": "https://cdc.gov/cove_app_api?$select=DISTINCT%20Topic",
40
+ "valueSelector": "Topic",
41
+ "textSelector": ""
42
+ },
43
+ "resetLabel": "",
44
+ "setByQueryParameter": "",
45
+ "usedBy": []
46
+ }
47
+ ]
48
+ ```
49
+
50
+ If the sharedFilter in Example (2) was configured in the dashboard configuration as Example (1), after the user made a selection to a dropdown mapped to this sharedFilter, the value selected would be appended to the `dataUrl` in the dataset.
51
+
52
+ Example: `https://cdc.gov/cove_app_api?Topic="Some Topic"`
53
+
54
+ The resulting url will be fetched and the resulting data will be mapped to the respective visualizations or rows.
55
+
56
+ # Dynamic Data without a sharedFilter item
57
+
58
+ A `loadQueryParam` can be configured directly on the dataset.
59
+
60
+ Example (3):
61
+
62
+ ```
63
+ "datasets": {
64
+ "cove_app_api": {
65
+ "dataFileSize": 1292219,
66
+ "dataFileName": "https://cdc.gov/cove_app_api?Topic='Sample Topics'",
67
+ "dataFileSourceType": "url",
68
+ "dataFileFormat": "JSON",
69
+ "dataUrl": "https://cdc.gov/cove_app_api?Topic='Sample Topics'",
70
+ "loadQueryParam": "Topic"
71
+ }
72
+ }
73
+ ```
74
+
75
+ When the page is loaded COVE will look at the `window.location.search` to find any matching query parameters that match `Topic` if one is found it will replace the found browser param with any that are present in the `dataUrl` in the dataset. For Example if `window.location.search` has `?Topic="Some Topic"&SomethingElse="something"` the url fetched for the Example (3) dataset would be `https://cdc.gov/cove_app_api?Topic="Some Topic"`. Note: `Topic='Sample Topics'` is included in the `dataUrl` to provide sample data intended for the COVE editor, this data will load if no matching query param is present in `window.location.search`.
76
+
77
+ # Special Statement parameters
78
+
79
+ Any query parameter which begins with `$` will be treated as a special statement parameter. These are reserved words which will for the most part be ignored by COVE filters and simply passed to the API. Example: `https://cdc.gov/cove_app_api?$select=Topic,Location&Age=18+` here the 'Age' param can be manipulated by a `urlfilter` type Filter, however the '$select' param cannot.
@@ -0,0 +1,39 @@
1
+ # Manually Overriding Dashboard Data
2
+
3
+ It is possible to override any data which has been uploaded as a file.
4
+
5
+ ## Configure Visualization with Placeholder Data
6
+
7
+ 1. Upload either a .csv or .json dataset in the Import Data tab under the Upload File section. Record the Data Source Name as it will be used later.
8
+
9
+ 2. Map the data to a visualization. This will act as placeholder data allowing you to configure the visualization.
10
+
11
+ 3. Complete the COVE configuration and save.
12
+
13
+ ## Use CustomEvent to Override Data
14
+
15
+ 1. In an area on the page where you can input custom javascript code you will be able to dispatch a [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent) to reset the data in your visualization.
16
+
17
+ 2. You'll need to structure your data as an array of flat objects. Each object being a row of data. Each row should have the same columns as what was provided in the placeholder Data.
18
+
19
+ 3. Create an Object which will be the dataset Override for the placeholder data. Each Data Override will have a key which matches the placeholder data's Data Source Name, i.e. `sample_data.csv`, and a value equal to the new data greated.
20
+
21
+ ```
22
+ const dataOverride = {
23
+ "sample_data.csv": [{state: 'Alabama', rate: 123}, {state: 'Alaska', rate: 135}]
24
+ }
25
+ ```
26
+
27
+ 4. Now create a CustomEvent with the event type set to `cove_set_data` and the options detail set to the `dataOverride`
28
+
29
+ ```
30
+ const customEvent = new CustomEvent('cove_set_data', {detail: dataOverride})
31
+ ```
32
+
33
+ 5. dispatch the event to the document.
34
+
35
+ ```
36
+ document.dispatchEvent(customEvent)
37
+ ```
38
+
39
+ You should see the data update immediately. Note: you can add as many datasets as you want in the dataOverride and they will all be updated in the same event.