@cdc/dashboard 4.23.2 → 4.23.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdc/dashboard",
3
- "version": "4.23.2",
3
+ "version": "4.23.4",
4
4
  "description": "React component for combining multiple visualizations into a single dashboard",
5
5
  "moduleName": "CdcDashboard",
6
6
  "main": "dist/cdcdashboard",
@@ -10,7 +10,9 @@
10
10
  "build": "vite build",
11
11
  "preview": "vite preview",
12
12
  "graph": "nx graph",
13
- "prepublishOnly": "lerna run --scope @cdc/dashboard build"
13
+ "prepublishOnly": "lerna run --scope @cdc/dashboard build",
14
+ "test": "vitest watch --reporter verbose",
15
+ "test:ui": "vitest --ui"
14
16
  },
15
17
  "repository": {
16
18
  "type": "git",
@@ -23,13 +25,13 @@
23
25
  },
24
26
  "license": "Apache-2.0",
25
27
  "dependencies": {
26
- "@cdc/chart": "^4.23.2",
27
- "@cdc/core": "^4.23.2",
28
- "@cdc/data-bite": "^4.23.2",
29
- "@cdc/filtered-text": "^4.23.2",
30
- "@cdc/map": "^4.23.2",
31
- "@cdc/markup-include": "^4.23.2",
32
- "@cdc/waffle-chart": "^4.23.2",
28
+ "@cdc/chart": "^4.23.4",
29
+ "@cdc/core": "^4.23.4",
30
+ "@cdc/data-bite": "^4.23.4",
31
+ "@cdc/filtered-text": "^4.23.4",
32
+ "@cdc/map": "^4.23.4",
33
+ "@cdc/markup-include": "^4.23.4",
34
+ "@cdc/waffle-chart": "^4.23.4",
33
35
  "html-react-parser": "^3.0.8",
34
36
  "js-base64": "^2.5.2",
35
37
  "papaparse": "^5.3.0",
@@ -45,5 +47,5 @@
45
47
  "react": "^18.2.0",
46
48
  "react-dom": "^18.2.0"
47
49
  },
48
- "gitHead": "cd4216f47b1c41bfbc1de3b704f70c52cc7293c2"
50
+ "gitHead": "dcd395d76f70b2d113f2b4c6fe50a52522655cd1"
49
51
  }
@@ -101,7 +101,7 @@ const VisualizationsPanel = () => (
101
101
  </div>
102
102
  )
103
103
 
104
- export default function CdcDashboard({ configUrl = '', config: configObj = undefined, isEditor = false, setConfig: setParentConfig }) {
104
+ export default function CdcDashboard({ configUrl = '', config: configObj = undefined, isEditor = false, isDebug = false, setConfig: setParentConfig }) {
105
105
  const [config, setConfig] = useState(configObj ?? {})
106
106
  const [data, setData] = useState([])
107
107
  const [filteredData, setFilteredData] = useState()
@@ -119,7 +119,7 @@ export default function CdcDashboard({ configUrl = '', config: configObj = undef
119
119
  let dataset = config.formattedData || config.data
120
120
 
121
121
  if (config.dataUrl) {
122
- dataset = fetchRemoteData(`${config.dataUrl}?v=${cacheBustingString()}`)
122
+ dataset = await fetchRemoteData(`${config.dataUrl}?v=${cacheBustingString()}`)
123
123
 
124
124
  if (dataset && config.dataDescription) {
125
125
  try {
@@ -145,6 +145,14 @@ export default function CdcDashboard({ configUrl = '', config: configObj = undef
145
145
  datasets[key] = await processData(response.datasets[key])
146
146
  })
147
147
  )
148
+
149
+ Object.keys(newConfig.visualizations).forEach(vizKey => {
150
+ newConfig.visualizations[vizKey].formattedData = datasets[newConfig.visualizations[vizKey].dataKey]
151
+ })
152
+
153
+ Object.keys(datasets).forEach(key => {
154
+ newConfig.datasets[key].data = datasets[key]
155
+ })
148
156
  } else {
149
157
  let dataKey = newConfig.dataFileName || 'backwards-compatibility'
150
158
  datasets[dataKey] = await processData(response)
@@ -335,7 +343,7 @@ export default function CdcDashboard({ configUrl = '', config: configObj = undef
335
343
  setFilteredData(newFilteredData)
336
344
  }
337
345
 
338
- const announceChange = text => { }
346
+ const announceChange = text => {}
339
347
 
340
348
  return config.dashboard.sharedFilters.map((singleFilter, index) => {
341
349
  if (!singleFilter.showDropdown) return <></>
@@ -436,7 +444,7 @@ export default function CdcDashboard({ configUrl = '', config: configObj = undef
436
444
  body = (
437
445
  <>
438
446
  <Header tabSelected={tabSelected} setTabSelected={setTabSelected} back={back} subEditor='Chart' />
439
- <CdcChart key={visualizationKey} config={visualizationConfig} isEditor={true} setConfig={updateConfig} setSharedFilter={setsSharedFilter ? setSharedFilter : undefined} isDashboard={true} />
447
+ <CdcChart key={visualizationKey} config={visualizationConfig} isEditor={true} isDebug={isDebug} setConfig={updateConfig} setSharedFilter={setsSharedFilter ? setSharedFilter : undefined} isDashboard={true} />
440
448
  </>
441
449
  )
442
450
  break
@@ -444,7 +452,7 @@ export default function CdcDashboard({ configUrl = '', config: configObj = undef
444
452
  body = (
445
453
  <>
446
454
  <Header tabSelected={tabSelected} setTabSelected={setTabSelected} back={back} subEditor='Map' />
447
- <CdcMap key={visualizationKey} config={visualizationConfig} isEditor={true} setConfig={updateConfig} setSharedFilter={setsSharedFilter ? setSharedFilter : undefined} setSharedFilterValue={setSharedFilterValue} isDashboard={true} />
455
+ <CdcMap key={visualizationKey} config={visualizationConfig} isEditor={true} isDebug={isDebug} setConfig={updateConfig} setSharedFilter={setsSharedFilter ? setSharedFilter : undefined} setSharedFilterValue={setSharedFilterValue} isDashboard={true} />
448
456
  </>
449
457
  )
450
458
  break
@@ -551,7 +559,11 @@ export default function CdcDashboard({ configUrl = '', config: configObj = undef
551
559
 
552
560
  const setsSharedFilter = config.dashboard.sharedFilters && config.dashboard.sharedFilters.filter(sharedFilter => sharedFilter.setBy === col.widget).length > 0
553
561
  const setSharedFilterValue = setsSharedFilter ? config.dashboard.sharedFilters.filter(sharedFilter => sharedFilter.setBy === col.widget)[0].active : undefined
554
- const tableLink = <a href={`#data-table-${visualizationConfig.dataKey}`}>{visualizationConfig.dataKey} (Go to Table)</a>
562
+ const tableLink = (
563
+ <a href={`#data-table-${visualizationConfig.dataKey}`} className='margin-left-href'>
564
+ {visualizationConfig.dataKey} (Go to Table)
565
+ </a>
566
+ )
555
567
 
556
568
  return (
557
569
  <React.Fragment key={`vis__${index}__${colIndex}`}>
@@ -566,7 +578,7 @@ export default function CdcDashboard({ configUrl = '', config: configObj = undef
566
578
  }}
567
579
  setSharedFilter={setsSharedFilter ? setSharedFilter : undefined}
568
580
  isDashboard={true}
569
- link={config.table && config.table.show && config.datasets ? tableLink : undefined}
581
+ link={config.table && config.table.show && config.datasets && visualizationConfig.table.showDataTableLink ? tableLink : undefined}
570
582
  />
571
583
  )}
572
584
  {visualizationConfig.type === 'map' && (
@@ -580,7 +592,7 @@ export default function CdcDashboard({ configUrl = '', config: configObj = undef
580
592
  setSharedFilter={setsSharedFilter ? setSharedFilter : undefined}
581
593
  setSharedFilterValue={setSharedFilterValue}
582
594
  isDashboard={true}
583
- link={config.table && config.table.show && config.datasets ? tableLink : undefined}
595
+ link={config.table && config.table.show && config.datasets && visualizationConfig.table.showDataTableLink ? tableLink : undefined}
584
596
  />
585
597
  )}
586
598
  {visualizationConfig.type === 'data-bite' && (
@@ -603,7 +615,7 @@ export default function CdcDashboard({ configUrl = '', config: configObj = undef
603
615
  updateChildConfig(col.widget, newConfig)
604
616
  }}
605
617
  isDashboard={true}
606
- link={config.table && config.table.show && config.datasets ? tableLink : undefined}
618
+ link={config.table && config.table.show && config.datasets && visualizationConfig.table.showDataTableLink ? tableLink : undefined}
607
619
  />
608
620
  )}
609
621
  {visualizationConfig.type === 'markup-include' && (
@@ -704,7 +716,8 @@ export default function CdcDashboard({ configUrl = '', config: configObj = undef
704
716
  updateConfig,
705
717
  setParentConfig,
706
718
  setPreview,
707
- outerContainerRef
719
+ outerContainerRef,
720
+ isDebug
708
721
  }
709
722
 
710
723
  const dashboardContainerClasses = ['cdc-open-viz-module', 'type-dashboard', `${currentViewport}`]
@@ -2,6 +2,7 @@ import React, { useState, useEffect, useContext } from 'react'
2
2
 
3
3
  import ConfigContext from '../ConfigContext'
4
4
 
5
+ import fetchRemoteData from '@cdc/core/helpers/fetchRemoteData'
5
6
  import { useGlobalContext } from '@cdc/core/components/GlobalContext'
6
7
  import Modal from '@cdc/core/components/ui/Modal'
7
8
 
@@ -320,7 +321,7 @@ const Header = ({ setPreview, tabSelected, setTabSelected, back, subEditor = nul
320
321
  <div className="wrap">
321
322
  <label>
322
323
  <input type='checkbox' defaultChecked={config.table.show} onChange={e => changeConfigValue('table', 'show', e.target.checked)} />
323
- Show Table
324
+ Show Data Table(s)
324
325
  </label><br />
325
326
 
326
327
  <label>
@@ -351,11 +352,11 @@ const Header = ({ setPreview, tabSelected, setTabSelected, back, subEditor = nul
351
352
  <div className="wrap">
352
353
  <label>
353
354
  <input type='checkbox' defaultChecked={config.table.download} onChange={e => changeConfigValue('table', 'download', e.target.checked)} />
354
- Show CSV Button
355
+ Show Download CSV Link
355
356
  </label>
356
357
  <label>
357
358
  <input type='checkbox' defaultChecked={config.table.showDownloadUrl} onChange={e => changeConfigValue('table', 'showDownloadUrl', e.target.checked)} />
358
- Show Link to Dataset
359
+ Show URL to Automatically Updated Data
359
360
  </label>
360
361
  </div>
361
362
  </>
package/src/index.jsx CHANGED
@@ -4,11 +4,12 @@ import ReactDOM from 'react-dom/client'
4
4
  import CdcDashboard from './CdcDashboard'
5
5
 
6
6
  let isEditor = window.location.href.includes('editor=true')
7
+ let isDebug = window.location.href.includes('debug=true')
7
8
 
8
9
  let domContainer = document.getElementsByClassName('react-container')[0]
9
10
 
10
11
  ReactDOM.createRoot(domContainer).render(
11
12
  <React.StrictMode>
12
- <CdcDashboard configUrl={domContainer.attributes['data-config'].value} isEditor={isEditor} />
13
- </React.StrictMode>,
13
+ <CdcDashboard configUrl={domContainer.attributes['data-config'].value} isEditor={isEditor} isDebug={isDebug} />
14
+ </React.StrictMode>
14
15
  )
@@ -48,7 +48,8 @@
48
48
  .wrap {
49
49
  display: inline-flex;
50
50
  flex-wrap: wrap;
51
- width: 20%;
51
+ width: 33%; // changed from 20% so that long checkbox name will fit without wrapping
52
+ font-size: 0.8em;
52
53
 
53
54
  .table-height-input {
54
55
  width: 100%;
@@ -62,9 +63,6 @@
62
63
  }
63
64
  }
64
65
 
65
- .heading-2 {
66
- }
67
-
68
66
  .heading-body {
69
67
  padding: 0.5em;
70
68
 
@@ -325,4 +323,4 @@
325
323
  display: block;
326
324
  margin: 1em 0;
327
325
  }
328
- }
326
+ }
@@ -0,0 +1,6 @@
1
+ // Placeholder test until we add them in.
2
+ describe('Dashboard', () => {
3
+ it('has a test.', async () => {
4
+ return true
5
+ })
6
+ })