@cdc/dashboard 4.25.1 → 4.25.3-6
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/dist/cdcdashboard.js +53114 -52737
- package/examples/all-components.json +529 -4607
- package/examples/dashboard-gallery.json +397 -397
- package/examples/private/DEV-10527.json +845 -0
- package/examples/private/DEV-10586.json +54319 -0
- package/examples/private/DEV-10856.json +54319 -0
- package/examples/private/DEV-9932.json +95 -0
- package/examples/private/dashboard-map-filter.json +815 -0
- package/examples/private/dev-10856-2.json +1348 -0
- package/examples/private/feelings.json +1 -0
- package/examples/private/markup.json +115 -0
- package/examples/private/nhis.json +1792 -0
- package/index.html +4 -3
- package/package.json +9 -9
- package/src/CdcDashboard.tsx +5 -8
- package/src/CdcDashboardComponent.tsx +58 -56
- package/src/_stories/Dashboard.stories.tsx +31 -0
- package/src/_stories/_mock/dashboard-filter-asc.json +551 -0
- package/src/components/CollapsibleVisualizationRow.tsx +1 -1
- package/src/components/DashboardFilters/DashboardFilters.tsx +10 -5
- package/src/components/DashboardFilters/DashboardFiltersEditor/DashboardFiltersEditor.tsx +22 -5
- package/src/components/DashboardFilters/DashboardFiltersEditor/components/DeleteFilterModal.tsx +13 -3
- package/src/components/DashboardFilters/DashboardFiltersEditor/components/FilterEditor.tsx +129 -40
- package/src/components/DashboardFilters/DashboardFiltersEditor/components/NestedDropDownDashboard.tsx +10 -7
- package/src/components/DashboardFilters/DashboardFiltersWrapper.tsx +11 -12
- package/src/components/DashboardFilters/dashboardfilter.styles.css +0 -2
- package/src/components/VisualizationRow.tsx +29 -15
- package/src/helpers/addValuesToDashboardFilters.ts +6 -5
- package/src/helpers/apiFilterHelpers.ts +10 -5
- package/src/helpers/changeFilterActive.ts +17 -4
- package/src/helpers/getFilteredData.ts +13 -4
- package/src/helpers/getUpdateConfig.ts +11 -4
- package/src/helpers/loadAPIFilters.ts +6 -4
- package/src/helpers/tests/updatesChildFilters.test.ts +56 -0
- package/src/helpers/updateChildFilters.ts +50 -0
- package/src/scss/main.scss +0 -3
- package/src/store/dashboard.reducer.ts +46 -24
- package/src/types/SharedFilter.ts +1 -1
package/index.html
CHANGED
|
@@ -21,16 +21,17 @@
|
|
|
21
21
|
</head>
|
|
22
22
|
|
|
23
23
|
<body>
|
|
24
|
-
|
|
24
|
+
<div class="react-container" data-config="/examples/private/nhis.json"></div>
|
|
25
|
+
<!-- <div class="react-container" data-config="/examples/private/bird-flu.json"></div> -->
|
|
25
26
|
<!-- <div class="react-container" data-config="/examples/bump-chart.json"></div> -->
|
|
26
27
|
<!-- <div class="react-container" data-config="/examples/full-dashboard.json"></div> -->
|
|
27
|
-
|
|
28
|
+
<div class="react-container" data-config="/examples/dashboard-gallery.json"></div>
|
|
28
29
|
<!-- <div class="react-container" data-config="/examples/dev-8332.json"></div> -->
|
|
29
30
|
<!-- <div class="react-container" data-config="/examples/default-multi-dataset.json"></div> -->
|
|
30
31
|
<!-- <div class="react-container" data-config="/examples/dev-8332.json"></div> -->
|
|
31
32
|
<!-- <div class="react-container" data-config="/examples/dashboard-gallery.json"></div> -->
|
|
32
33
|
<!-- <div class="react-container" data-config="/examples/filtered-dash.json"></div> -->
|
|
33
|
-
<div class="react-container" data-config="/examples/private/art-dashboard.json"></div>
|
|
34
|
+
<!-- <div class="react-container" data-config="/examples/private/art-dashboard.json"></div> -->
|
|
34
35
|
<!-- <div class="react-container" data-config="/examples/sankey.json"></div> -->
|
|
35
36
|
<!-- <div class="react-container" data-config="/examples/DEV-6574.json"></div> -->
|
|
36
37
|
<!-- <div class="react-container" data-config="/examples/default-multi-dataset-2.json"></div> -->
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdc/dashboard",
|
|
3
|
-
"version": "4.25.
|
|
3
|
+
"version": "4.25.3-6",
|
|
4
4
|
"description": "React component for combining multiple visualizations into a single dashboard",
|
|
5
5
|
"moduleName": "CdcDashboard",
|
|
6
6
|
"main": "dist/cdcdashboard",
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
},
|
|
28
28
|
"license": "Apache-2.0",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@cdc/chart": "^4.25.
|
|
31
|
-
"@cdc/core": "^4.25.
|
|
32
|
-
"@cdc/data-bite": "^4.25.
|
|
33
|
-
"@cdc/filtered-text": "^4.25.
|
|
34
|
-
"@cdc/map": "^4.25.
|
|
35
|
-
"@cdc/markup-include": "^4.25.
|
|
36
|
-
"@cdc/waffle-chart": "^4.25.
|
|
30
|
+
"@cdc/chart": "^4.25.3-6",
|
|
31
|
+
"@cdc/core": "^4.25.3-6",
|
|
32
|
+
"@cdc/data-bite": "^4.25.3-6",
|
|
33
|
+
"@cdc/filtered-text": "^4.25.3-6",
|
|
34
|
+
"@cdc/map": "^4.25.3-6",
|
|
35
|
+
"@cdc/markup-include": "^4.25.3-6",
|
|
36
|
+
"@cdc/waffle-chart": "^4.25.3-6",
|
|
37
37
|
"html-react-parser": "^3.0.8",
|
|
38
38
|
"js-base64": "^2.5.2",
|
|
39
39
|
"papaparse": "^5.3.0",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"react": "^18.2.0",
|
|
50
50
|
"react-dom": "^18.2.0"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "d83d8555c1500ff0cad9d2c5c3486324afa15ec6"
|
|
53
53
|
}
|
package/src/CdcDashboard.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react'
|
|
1
|
+
import { useContext, useEffect, useState } from 'react'
|
|
2
2
|
import CdcDashboard from './CdcDashboardComponent'
|
|
3
3
|
import { MultiDashboardConfig } from './types/MultiDashboard'
|
|
4
4
|
import Loading from '@cdc/core/components/Loading'
|
|
@@ -13,19 +13,16 @@ import { DashboardConfig } from './types/DashboardConfig'
|
|
|
13
13
|
import { coveUpdateWorker } from '@cdc/core/helpers/coveUpdateWorker'
|
|
14
14
|
import _ from 'lodash'
|
|
15
15
|
import { getQueryParams } from '@cdc/core/helpers/queryStringUtils'
|
|
16
|
+
import EditorContext from '../../editor/src/ConfigContext'
|
|
16
17
|
|
|
17
18
|
type MultiDashboardProps = Omit<WCMSProps, 'configUrl'> & {
|
|
18
19
|
configUrl?: string
|
|
19
20
|
config?: MultiDashboardConfig
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
const MultiDashboardWrapper: React.FC<MultiDashboardProps> = ({
|
|
23
|
-
configUrl,
|
|
24
|
-
config: editorConfig,
|
|
25
|
-
isEditor,
|
|
26
|
-
isDebug
|
|
27
|
-
}) => {
|
|
23
|
+
const MultiDashboardWrapper: React.FC<MultiDashboardProps> = ({ configUrl, isEditor, isDebug, config }) => {
|
|
28
24
|
const [initial, setInitial] = useState<InitialState>(undefined)
|
|
25
|
+
const editorContext = useContext(EditorContext)
|
|
29
26
|
|
|
30
27
|
const getSelectedConfig = (config: MultiDashboardConfig): number | null => {
|
|
31
28
|
if (!config.multiDashboards) return null
|
|
@@ -48,7 +45,7 @@ const MultiDashboardWrapper: React.FC<MultiDashboardProps> = ({
|
|
|
48
45
|
}
|
|
49
46
|
|
|
50
47
|
const loadConfig = async () => {
|
|
51
|
-
const _config: MultiDashboardConfig =
|
|
48
|
+
const _config: MultiDashboardConfig = config || editorContext.config || (await (await fetch(configUrl)).json())
|
|
52
49
|
const selected = getSelectedConfig(_config)
|
|
53
50
|
|
|
54
51
|
const { newConfig, datasets } =
|
|
@@ -521,6 +521,8 @@ export default function CdcDashboard({ initialState, isEditor = false, isDebug =
|
|
|
521
521
|
const { config } = state
|
|
522
522
|
const { title, description } = config.dashboard || {}
|
|
523
523
|
|
|
524
|
+
const filteredRows = config.rows && config.rows.filter(row => row.columns.filter(col => col.widget).length !== 0)
|
|
525
|
+
|
|
524
526
|
body = (
|
|
525
527
|
<>
|
|
526
528
|
{isEditor && <Header />}
|
|
@@ -544,62 +546,62 @@ export default function CdcDashboard({ initialState, isEditor = false, isDebug =
|
|
|
544
546
|
{/* Description */}
|
|
545
547
|
{description && <div className='subtext mb-3'>{parse(description)}</div>}
|
|
546
548
|
{/* Visualizations */}
|
|
547
|
-
{
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
const
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
{
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
549
|
+
{filteredRows &&
|
|
550
|
+
filteredRows.map((row, index) => {
|
|
551
|
+
if (row.multiVizColumn && (isPreview || !isEditor)) {
|
|
552
|
+
const filteredData = getFilteredData(state, _.cloneDeep(state.data))
|
|
553
|
+
const data = filteredData[index] ?? row.formattedData
|
|
554
|
+
const dataGroups = {}
|
|
555
|
+
data.forEach(d => {
|
|
556
|
+
const groupKey = d[row.multiVizColumn]
|
|
557
|
+
if (!dataGroups[groupKey]) dataGroups[groupKey] = []
|
|
558
|
+
dataGroups[groupKey].push(d)
|
|
559
|
+
})
|
|
560
|
+
return (
|
|
561
|
+
<>
|
|
562
|
+
{/* Expand/Collapse All */}
|
|
563
|
+
{!inNoDataState && row.expandCollapseAllButtons === true && (
|
|
564
|
+
<ExpandCollapseButtons setAllExpanded={setAllExpanded} />
|
|
565
|
+
)}
|
|
566
|
+
{Object.keys(dataGroups).map(groupName => {
|
|
567
|
+
const dataValue = dataGroups[groupName]
|
|
568
|
+
return (
|
|
569
|
+
<VisualizationRow
|
|
570
|
+
key={`row__${index}__${groupName}`}
|
|
571
|
+
allExpanded={allExpanded}
|
|
572
|
+
filteredDataOverride={dataValue}
|
|
573
|
+
groupName={groupName}
|
|
574
|
+
row={row}
|
|
575
|
+
rowIndex={index}
|
|
576
|
+
setSharedFilter={setSharedFilter}
|
|
577
|
+
updateChildConfig={updateChildConfig}
|
|
578
|
+
apiFilterDropdowns={apiFilterDropdowns}
|
|
579
|
+
currentViewport={currentViewport}
|
|
580
|
+
inNoDataState={inNoDataState}
|
|
581
|
+
isLastRow={index === filteredRows.length - 1}
|
|
582
|
+
/>
|
|
583
|
+
)
|
|
584
|
+
})}
|
|
585
|
+
</>
|
|
586
|
+
)
|
|
587
|
+
} else {
|
|
588
|
+
return (
|
|
589
|
+
<VisualizationRow
|
|
590
|
+
key={`row__${index}`}
|
|
591
|
+
allExpanded={false}
|
|
592
|
+
groupName={''}
|
|
593
|
+
row={row}
|
|
594
|
+
rowIndex={index}
|
|
595
|
+
setSharedFilter={setSharedFilter}
|
|
596
|
+
updateChildConfig={updateChildConfig}
|
|
597
|
+
apiFilterDropdowns={apiFilterDropdowns}
|
|
598
|
+
currentViewport={currentViewport}
|
|
599
|
+
inNoDataState={inNoDataState}
|
|
600
|
+
isLastRow={index === filteredRows.length - 1}
|
|
601
|
+
/>
|
|
602
|
+
)
|
|
603
|
+
}
|
|
604
|
+
})}
|
|
603
605
|
|
|
604
606
|
{inNoDataState ? <div className='mt-5'>Please complete your selection to continue.</div> : <></>}
|
|
605
607
|
|
|
@@ -29,6 +29,16 @@ import TopSpacing_2 from './_mock/data-bite-dash-test_1.json'
|
|
|
29
29
|
import TopSpacing_3 from './_mock/data-bite-dash-test_1_1.json'
|
|
30
30
|
import TopSpacing_4 from './_mock/data-bite-dash-test_1_1_1.json'
|
|
31
31
|
|
|
32
|
+
// Dashboard Filter Updates for Ascending, Descending, and Custom Order
|
|
33
|
+
import DashboardFilterAsc from './_mock/dashboard-filter-asc.json'
|
|
34
|
+
const DashboardFilterDesc = _.cloneDeep(DashboardFilterAsc)
|
|
35
|
+
const DashboardFilterCust = _.cloneDeep(DashboardFilterAsc)
|
|
36
|
+
DashboardFilterDesc.dashboard.sharedFilters[0].order = 'desc'
|
|
37
|
+
DashboardFilterCust.dashboard.sharedFilters[0].order = 'cust'
|
|
38
|
+
|
|
39
|
+
// On DashboardFilterCust change the sharedFilters[0].values and orderedValues to be in a custom order
|
|
40
|
+
const customOrder = ['American Samoa', 'Alaska', 'Alabama', 'Arizona', 'Arkansas']
|
|
41
|
+
|
|
32
42
|
const meta: Meta<typeof Dashboard> = {
|
|
33
43
|
title: 'Components/Pages/Dashboard',
|
|
34
44
|
component: Dashboard
|
|
@@ -36,6 +46,27 @@ const meta: Meta<typeof Dashboard> = {
|
|
|
36
46
|
|
|
37
47
|
type Story = StoryObj<typeof Dashboard>
|
|
38
48
|
|
|
49
|
+
export const Dashboard_Filter_Asc: Story = {
|
|
50
|
+
args: {
|
|
51
|
+
config: DashboardFilterAsc,
|
|
52
|
+
isEditor: false
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const Dashboard_Filter_Desc: Story = {
|
|
57
|
+
args: {
|
|
58
|
+
config: DashboardFilterDesc,
|
|
59
|
+
isEditor: false
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const Dashboard_Filter_Cust: Story = {
|
|
64
|
+
args: {
|
|
65
|
+
config: DashboardFilterCust,
|
|
66
|
+
isEditor: false
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
39
70
|
export const Example_1: Story = {
|
|
40
71
|
args: {
|
|
41
72
|
config: ExampleConfig_1,
|