@cdc/dashboard 4.25.11 → 4.26.2
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/Dynamic_Data.md +66 -0
- package/dist/cdcdashboard-8NmHlKRI.es.js +15 -0
- package/dist/cdcdashboard-BPoPzKPz.es.js +6 -0
- package/dist/cdcdashboard-Cf9_fbQf.es.js +6 -0
- package/dist/{cdcdashboard-dgT_1dIT.es.js → cdcdashboard-DQ00cQCm.es.js} +1 -20
- package/dist/cdcdashboard-jiQQPkty.es.js +6 -0
- package/dist/cdcdashboard.js +83537 -86913
- package/examples/api-dashboard-data.json +272 -0
- package/examples/api-dashboard-years.json +11 -0
- package/examples/api-geographies-data.json +11 -0
- package/examples/default.json +522 -133
- package/examples/nested-dropdown.json +6985 -0
- package/examples/private/abc.json +467 -0
- package/examples/private/cat-y.json +1235 -0
- package/examples/private/chronic-dash.json +1584 -0
- package/examples/private/dash.json +12696 -0
- package/examples/private/map-issue.json +2260 -0
- package/examples/private/mpinc-state-reports.json +2260 -0
- package/examples/private/npcr.json +1 -0
- package/examples/private/nwss/rsv.json +1240 -0
- package/examples/private/simple-dash.json +490 -0
- package/examples/private/test-dash.json +0 -0
- package/examples/private/test.json +125407 -0
- package/examples/private/test123.json +491 -0
- package/examples/private/timeline-data.json +4994 -0
- package/examples/private/timeline.json +1708 -0
- package/examples/test-api-filter-reset.json +8 -4
- package/examples/test-dashboard-simple.json +503 -0
- package/examples/tp5-gauges.json +196 -0
- package/examples/tp5-test.json +266 -0
- package/index.html +1 -30
- package/package.json +39 -40
- package/src/CdcDashboardComponent.tsx +18 -5
- package/src/_stories/Dashboard.DataSetup.stories.tsx +204 -0
- package/src/_stories/Dashboard.stories.tsx +407 -1
- package/src/_stories/_mock/dashboard-line-chart-angles.json +1030 -0
- package/src/_stories/_mock/filter-cascade.json +3350 -0
- package/src/_stories/_mock/gallery-data-bite-dashboard.json +3500 -0
- package/src/_stories/_mock/nested-parent-child-filters.json +392 -0
- package/src/_stories/_mock/parent-child-filters.json +233 -0
- package/src/_stories/_mock/tp5-test.json +267 -0
- package/src/components/DashboardFilters/DashboardFilters.tsx +20 -11
- package/src/components/DashboardFilters/DashboardFiltersEditor/DashboardFiltersEditor.tsx +92 -38
- package/src/components/DashboardFilters/DashboardFiltersEditor/components/FilterEditor.tsx +56 -30
- package/src/components/DashboardFilters/DashboardFiltersEditor/components/NestedDropDownDashboard.tsx +151 -10
- package/src/components/DashboardFilters/DashboardFiltersWrapper.tsx +11 -7
- package/src/components/DataDesignerModal.tsx +6 -1
- package/src/components/Header/Header.tsx +51 -20
- package/src/components/VisualizationRow.tsx +76 -5
- package/src/components/VisualizationsPanel/VisualizationsPanel.tsx +2 -20
- package/src/components/Widget/Widget.tsx +1 -1
- package/src/data/initial-state.js +1 -0
- package/src/helpers/addValuesToDashboardFilters.ts +30 -31
- package/src/helpers/apiFilterHelpers.ts +28 -32
- package/src/helpers/changeFilterActive.ts +67 -65
- package/src/helpers/formatConfigBeforeSave.ts +6 -5
- package/src/helpers/getUpdateConfig.ts +91 -91
- package/src/helpers/tests/addValuesToDashboardFilters.test.ts +141 -44
- package/src/helpers/tests/apiFilterHelpers.test.ts +523 -420
- package/src/helpers/tests/updatesChildFilters.test.ts +53 -22
- package/src/helpers/updateChildFilters.ts +50 -27
- package/src/scss/main.scss +144 -1
- package/src/test/CdcDashboard.test.jsx +9 -4
- package/src/types/Dashboard.ts +1 -0
- package/src/types/FilterStyles.ts +8 -7
- package/src/types/SharedFilter.ts +13 -0
- package/vite.config.js +7 -1
- package/LICENSE +0 -201
- package/dist/cdcdashboard-BnB1QM5d.es.js +0 -361528
- package/dist/cdcdashboard-Ct2SB0vL.es.js +0 -231049
- package/dist/cdcdashboard-D6CG2-Hb.es.js +0 -39377
- package/dist/cdcdashboard-MXgURbdZ.es.js +0 -39194
- package/examples/private/DEV-10538.json +0 -407
- package/examples/private/DEV-11072.json +0 -7591
- package/examples/private/DEV-11405.json +0 -39112
- package/examples/private/delete.json +0 -32919
- package/examples/private/pedro.json +0 -1
package/Dynamic_Data.md
CHANGED
|
@@ -26,6 +26,72 @@ Dashboards have a section called `sharedFilters` that is mapped over to gather a
|
|
|
26
26
|
|
|
27
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
28
|
|
|
29
|
+
## URL Filter Types: Query String vs File Name
|
|
30
|
+
|
|
31
|
+
URL filters support two different methods for modifying dataset URLs, specified by the `filterBy` property:
|
|
32
|
+
|
|
33
|
+
### Query String Filters (`filterBy: "Query String"`)
|
|
34
|
+
|
|
35
|
+
Query String filters append the filter value as a URL query parameter. This is the most common approach for REST APIs.
|
|
36
|
+
|
|
37
|
+
**Configuration:**
|
|
38
|
+
- `filterBy`: Set to `"Query String"`
|
|
39
|
+
- `queryParameter`: The name of the query parameter to append (e.g., `"geography"`, `"state"`)
|
|
40
|
+
- `datasetKey`: **Auto-populated** from the widgets specified in `usedBy` - you don't need to specify this manually
|
|
41
|
+
|
|
42
|
+
**Example:**
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"key": "Geography",
|
|
46
|
+
"type": "urlfilter",
|
|
47
|
+
"filterBy": "Query String",
|
|
48
|
+
"queryParameter": "geography",
|
|
49
|
+
"usedBy": ["chart1"],
|
|
50
|
+
"apiFilter": {
|
|
51
|
+
"apiEndpoint": "https://api.cdc.gov/states",
|
|
52
|
+
"valueSelector": "state",
|
|
53
|
+
"textSelector": "state_name"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
When a user selects "Alaska", the dataset URL `https://api.cdc.gov/data.json` becomes `https://api.cdc.gov/data.json?geography=Alaska`.
|
|
59
|
+
|
|
60
|
+
### File Name Filters (`filterBy: "File Name"`)
|
|
61
|
+
|
|
62
|
+
File Name filters replace the filename portion of the URL. This is useful for APIs that use path-based routing or file-based data sources.
|
|
63
|
+
|
|
64
|
+
**Configuration:**
|
|
65
|
+
- `filterBy`: Set to `"File Name"`
|
|
66
|
+
- `fileName`: Template for the new filename, use `${query}` placeholder for the filter value
|
|
67
|
+
- `datasetKey`: **Required** - specifies which dataset's filename should be modified
|
|
68
|
+
- `whitespaceReplacement`: How to handle spaces in the filter value (`"Keep Spaces"`, `"Remove Spaces"`, or `"Replace With Underscore"`)
|
|
69
|
+
|
|
70
|
+
**Example:**
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"key": "State",
|
|
74
|
+
"type": "urlfilter",
|
|
75
|
+
"filterBy": "File Name",
|
|
76
|
+
"fileName": "NSSPSubState${query}",
|
|
77
|
+
"datasetKey": "resp-data.json",
|
|
78
|
+
"whitespaceReplacement": "Remove Spaces",
|
|
79
|
+
"usedBy": ["chart1"],
|
|
80
|
+
"apiFilter": {
|
|
81
|
+
"apiEndpoint": "https://api.cdc.gov/states",
|
|
82
|
+
"valueSelector": "state"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
When a user selects "Alaska", the dataset URL `https://api.cdc.gov/data/default.json` becomes `https://api.cdc.gov/data/NSSPSubStateAlaska.json`.
|
|
88
|
+
|
|
89
|
+
### Dataset Key Behavior
|
|
90
|
+
|
|
91
|
+
- **Query String filters**: The `datasetKey` is automatically determined from the widgets specified in the `usedBy` array. The system looks at each widget's `dataKey` property to identify which datasets should receive the query parameter.
|
|
92
|
+
|
|
93
|
+
- **File Name filters**: The `datasetKey` must be explicitly specified to indicate which dataset's filename should be modified. This is required because filename transformations apply to specific URLs.
|
|
94
|
+
|
|
29
95
|
Example (2):
|
|
30
96
|
|
|
31
97
|
```
|