@cdc/editor 4.24.2 → 4.24.3

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/editor",
3
- "version": "4.24.2",
3
+ "version": "4.24.3",
4
4
  "description": "React component for generating a new component entry",
5
5
  "moduleName": "CdcEditor",
6
6
  "main": "dist/cdceditor",
@@ -24,13 +24,13 @@
24
24
  },
25
25
  "license": "Apache-2.0",
26
26
  "dependencies": {
27
- "@cdc/chart": "^4.24.2",
28
- "@cdc/core": "^4.24.2",
29
- "@cdc/dashboard": "^4.24.2",
30
- "@cdc/data-bite": "^4.24.2",
31
- "@cdc/map": "^4.24.2",
32
- "@cdc/markup-include": "^4.24.2",
33
- "@cdc/waffle-chart": "^4.24.2",
27
+ "@cdc/chart": "^4.24.3",
28
+ "@cdc/core": "^4.24.3",
29
+ "@cdc/dashboard": "^4.24.3",
30
+ "@cdc/data-bite": "^4.24.3",
31
+ "@cdc/map": "^4.24.3",
32
+ "@cdc/markup-include": "^4.24.3",
33
+ "@cdc/waffle-chart": "^4.24.3",
34
34
  "axios": "^1.6.0",
35
35
  "d3": "^7.0.0",
36
36
  "html-react-parser": "^3.0.8",
@@ -43,5 +43,5 @@
43
43
  "react": "^18.2.0",
44
44
  "react-dom": "^18.2.0"
45
45
  },
46
- "gitHead": "edde49c96dee146de5e3a4537880b1bcf4dbee08"
46
+ "gitHead": "9c7ef7ca74f2d2a1e04d923b133fe0fc557a62bf"
47
47
  }
@@ -1,5 +1,8 @@
1
1
  import { Meta, StoryObj } from '@storybook/react'
2
2
  import CdcEditor from '../CdcEditor'
3
+ import StandAloneTableConfig from './_mock/standalone-table.json'
4
+ import BlankConfig from './_mock/blank-config.json'
5
+ import PivotFilterConfig from './_mock/pivot-filter.json'
3
6
 
4
7
  const meta: Meta<typeof CdcEditor> = {
5
8
  title: 'Components/Pages/CdcEditor',
@@ -9,88 +12,20 @@ export default meta
9
12
 
10
13
  type Story = StoryObj<typeof CdcEditor>
11
14
 
12
- const config = {
13
- dashboard: {
14
- theme: 'theme-blue'
15
- },
16
- rows: [
17
- [
18
- {
19
- width: 12
20
- },
21
- {},
22
- {}
23
- ]
24
- ],
25
- visualizations: {},
26
- table: {
27
- label: 'Data Table',
28
- show: true,
29
- showDownloadUrl: false,
30
- showVertical: true
31
- },
32
- newViz: true,
33
- datasets: {
34
- 'https://data.cdc.gov/resource/vdgb-f9s3.json': {
35
- data: [
36
- {
37
- surveyname: 'American Indian Adult Tobacco Survey',
38
- surveynameabbrev: 'AI ATS',
39
- year: '2007',
40
- e_cigarettes: 'No',
41
- question: 'During the past 12 months, have you stopped smoking for one day or longer because you were trying to quit smoking?',
42
- responses: "Don't know/Not sure"
43
- },
44
- {
45
- surveyname: 'American Indian Adult Tobacco Survey',
46
- surveynameabbrev: 'AI ATS',
47
- year: '2007',
48
- e_cigarettes: 'No',
49
- question: 'During the past 12 months, have you stopped smoking for one day or longer because you were trying to quit smoking?',
50
- responses: 'Refused'
51
- },
52
- {
53
- surveyname: 'American Indian Adult Tobacco Survey',
54
- surveynameabbrev: 'AI ATS',
55
- year: '2007',
56
- e_cigarettes: 'No',
57
- question: 'During the past 12 months, have you stopped smoking for one day or longer because you were trying to quit smoking?',
58
- responses: 'No'
59
- }
60
- ]
61
- }
62
- },
63
- data: [
64
- {
65
- surveyname: 'American Indian Adult Tobacco Survey',
66
- surveynameabbrev: 'AI ATS',
67
- year: '2007',
68
- e_cigarettes: 'No',
69
- question: 'During the past 12 months, have you stopped smoking for one day or longer because you were trying to quit smoking?',
70
- responses: "Don't know/Not sure"
71
- },
72
- {
73
- surveyname: 'American Indian Adult Tobacco Survey',
74
- surveynameabbrev: 'AI ATS',
75
- year: '2007',
76
- e_cigarettes: 'No',
77
- question: 'During the past 12 months, have you stopped smoking for one day or longer because you were trying to quit smoking?',
78
- responses: 'Refused'
79
- },
80
- {
81
- surveyname: 'American Indian Adult Tobacco Survey',
82
- surveynameabbrev: 'AI ATS',
83
- year: '2007',
84
- e_cigarettes: 'No',
85
- question: 'During the past 12 months, have you stopped smoking for one day or longer because you were trying to quit smoking?',
86
- responses: 'No'
87
- }
88
- ],
89
- type: 'dashboard'
15
+ export const DefaultEditor: Story = {
16
+ args: {
17
+ config: BlankConfig
18
+ }
19
+ }
20
+
21
+ export const StandAloneTable: Story = {
22
+ args: {
23
+ config: StandAloneTableConfig
24
+ }
90
25
  }
91
26
 
92
- export const DashboardEditor: Story = {
27
+ export const PivotFilter: Story = {
93
28
  args: {
94
- config
29
+ config: PivotFilterConfig
95
30
  }
96
31
  }
@@ -0,0 +1,79 @@
1
+ {
2
+ "dashboard": {
3
+ "theme": "theme-blue"
4
+ },
5
+ "rows": [
6
+ [
7
+ {
8
+ "width": 12
9
+ },
10
+ {},
11
+ {}
12
+ ]
13
+ ],
14
+ "visualizations": {},
15
+ "table": {
16
+ "label": "Data Table",
17
+ "show": true,
18
+ "showDownloadUrl": false,
19
+ "showVertical": true
20
+ },
21
+ "newViz": true,
22
+ "datasets": {
23
+ "https://data.cdc.gov/resource/vdgb-f9s3.json": {
24
+ "data": [
25
+ {
26
+ "surveyname": "American Indian Adult Tobacco Survey",
27
+ "surveynameabbrev": "AI ATS",
28
+ "year": "2007",
29
+ "e_cigarettes": "No",
30
+ "question": "During the past 12 months, have you stopped smoking for one day or longer because you were trying to quit smoking?",
31
+ "responses": "Don't know/Not sure"
32
+ },
33
+ {
34
+ "surveyname": "American Indian Adult Tobacco Survey",
35
+ "surveynameabbrev": "AI ATS",
36
+ "year": "2007",
37
+ "e_cigarettes": "No",
38
+ "question": "During the past 12 months, have you stopped smoking for one day or longer because you were trying to quit smoking?",
39
+ "responses": "Refused"
40
+ },
41
+ {
42
+ "surveyname": "American Indian Adult Tobacco Survey",
43
+ "surveynameabbrev": "AI ATS",
44
+ "year": "2007",
45
+ "e_cigarettes": "No",
46
+ "question": "During the past 12 months, have you stopped smoking for one day or longer because you were trying to quit smoking?",
47
+ "responses": "No"
48
+ }
49
+ ]
50
+ }
51
+ },
52
+ "data": [
53
+ {
54
+ "surveyname": "American Indian Adult Tobacco Survey",
55
+ "surveynameabbrev": "AI ATS",
56
+ "year": "2007",
57
+ "e_cigarettes": "No",
58
+ "question": "During the past 12 months, have you stopped smoking for one day or longer because you were trying to quit smoking?",
59
+ "responses": "Don't know/Not sure"
60
+ },
61
+ {
62
+ "surveyname": "American Indian Adult Tobacco Survey",
63
+ "surveynameabbrev": "AI ATS",
64
+ "year": "2007",
65
+ "e_cigarettes": "No",
66
+ "question": "During the past 12 months, have you stopped smoking for one day or longer because you were trying to quit smoking?",
67
+ "responses": "Refused"
68
+ },
69
+ {
70
+ "surveyname": "American Indian Adult Tobacco Survey",
71
+ "surveynameabbrev": "AI ATS",
72
+ "year": "2007",
73
+ "e_cigarettes": "No",
74
+ "question": "During the past 12 months, have you stopped smoking for one day or longer because you were trying to quit smoking?",
75
+ "responses": "No"
76
+ }
77
+ ],
78
+ "type": "dashboard"
79
+ }
@@ -0,0 +1,135 @@
1
+ {
2
+ "dashboard": {
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
+ "values": ["Hispanic or Latino", "Non-Hispanic American Indian", "Non-Hispanic Black", "Non-Hispanic Asian or Pacific Islander", "Non-Hispanic White"],
12
+ "active": "Hispanic or Latino",
13
+ "tier": 1
14
+ }
15
+ ]
16
+ },
17
+ "rows": [
18
+ [
19
+ {
20
+ "width": 12,
21
+ "widget": "table1707935263149"
22
+ },
23
+ {},
24
+ {}
25
+ ]
26
+ ],
27
+ "visualizations": {
28
+ "table1707935263149": {
29
+ "newViz": true,
30
+ "openModal": false,
31
+ "uid": "table1707935263149",
32
+ "type": "table",
33
+ "table": {
34
+ "label": "Data Table",
35
+ "show": true,
36
+ "showDownloadUrl": false,
37
+ "showVertical": true,
38
+ "expanded": true
39
+ },
40
+ "columns": {},
41
+ "dataFormat": {},
42
+ "visualizationType": "table",
43
+ "dataDescription": {
44
+ "horizontal": false,
45
+ "series": false
46
+ },
47
+ "formattedData": [
48
+ {
49
+ "Race": "Hispanic or Latino",
50
+ "Age-adjusted rate": "644.2"
51
+ },
52
+ {
53
+ "Race": "Non-Hispanic American Indian",
54
+ "Age-adjusted rate": "636.1"
55
+ },
56
+ {
57
+ "Race": "Non-Hispanic Black",
58
+ "Age-adjusted rate": "563.7"
59
+ },
60
+ {
61
+ "Race": "Non-Hispanic Asian or Pacific Islander",
62
+ "Age-adjusted rate": "202.5"
63
+ },
64
+ {
65
+ "Race": "Non-Hispanic White",
66
+ "Age-adjusted rate": "183.6"
67
+ }
68
+ ],
69
+ "dataKey": "valid-data-chart.csv",
70
+ "data": [
71
+ {
72
+ "Race": "Hispanic or Latino",
73
+ "Age-adjusted rate": "644.2"
74
+ },
75
+ {
76
+ "Race": "Non-Hispanic American Indian",
77
+ "Age-adjusted rate": "636.1"
78
+ },
79
+ {
80
+ "Race": "Non-Hispanic Black",
81
+ "Age-adjusted rate": "563.7"
82
+ },
83
+ {
84
+ "Race": "Non-Hispanic Asian or Pacific Islander",
85
+ "Age-adjusted rate": "202.5"
86
+ },
87
+ {
88
+ "Race": "Non-Hispanic White",
89
+ "Age-adjusted rate": "183.6"
90
+ }
91
+ ]
92
+ }
93
+ },
94
+ "table": {
95
+ "label": "Data Table",
96
+ "show": true,
97
+ "showDownloadUrl": false,
98
+ "showVertical": true
99
+ },
100
+ "newViz": true,
101
+ "datasets": {
102
+ "valid-data-chart.csv": {
103
+ "data": [
104
+ {
105
+ "Race": "Hispanic or Latino",
106
+ "Age-adjusted rate": "644.2"
107
+ },
108
+ {
109
+ "Race": "Non-Hispanic American Indian",
110
+ "Age-adjusted rate": "636.1"
111
+ },
112
+ {
113
+ "Race": "Non-Hispanic Black",
114
+ "Age-adjusted rate": "563.7"
115
+ },
116
+ {
117
+ "Race": "Non-Hispanic Asian or Pacific Islander",
118
+ "Age-adjusted rate": "202.5"
119
+ },
120
+ {
121
+ "Race": "Non-Hispanic White",
122
+ "Age-adjusted rate": "183.6"
123
+ }
124
+ ],
125
+ "dataFileSize": 178,
126
+ "dataFileName": "valid-data-chart.csv",
127
+ "dataFileSourceType": "file",
128
+ "dataFileFormat": "CSV",
129
+ "preview": true
130
+ }
131
+ },
132
+ "type": "dashboard",
133
+ "runtime": {},
134
+ "data": [1, 2, 3]
135
+ }
@@ -0,0 +1,144 @@
1
+ {
2
+ "dashboard": {
3
+ "theme": "theme-blue"
4
+ },
5
+ "rows": [
6
+ [
7
+ {
8
+ "width": 12,
9
+ "widget": "table1707840146431"
10
+ },
11
+ {},
12
+ {}
13
+ ]
14
+ ],
15
+ "visualizations": {
16
+ "table1707840146431": {
17
+ "newViz": true,
18
+ "openModal": false,
19
+ "uid": "table1707840146431",
20
+ "table": {
21
+ "label": "Data Table",
22
+ "show": true,
23
+ "showDownloadUrl": false,
24
+ "showVertical": true,
25
+ "expanded": true
26
+ },
27
+ "type": "table",
28
+ "visualizationType": "table",
29
+ "dataDescription": {
30
+ "horizontal": false,
31
+ "series": false
32
+ },
33
+ "columns": {},
34
+ "dataFormat": {},
35
+ "formattedData": [
36
+ {
37
+ "Race": "Hispanic or Latino",
38
+ "Age-adjusted rate": "644.2"
39
+ },
40
+ {
41
+ "Race": "Non-Hispanic American Indian",
42
+ "Age-adjusted rate": "6360.1"
43
+ },
44
+ {
45
+ "Race": "Non-Hispanic Black",
46
+ "Age-adjusted rate": "563.7"
47
+ },
48
+ {
49
+ "Race": "Non-Hispanic Asian or Pacific Islander",
50
+ "Age-adjusted rate": "202.5"
51
+ },
52
+ {
53
+ "Race": "Non-Hispanic White",
54
+ "Age-adjusted rate": "183.6"
55
+ }
56
+ ],
57
+ "dataKey": "valid-data-chart.csv",
58
+ "data": [
59
+ {
60
+ "Race": "Hispanic or Latino",
61
+ "Age-adjusted rate": "644.2"
62
+ },
63
+ {
64
+ "Race": "Non-Hispanic American Indian",
65
+ "Age-adjusted rate": "6360.1"
66
+ },
67
+ {
68
+ "Race": "Non-Hispanic Black",
69
+ "Age-adjusted rate": "563.7"
70
+ },
71
+ {
72
+ "Race": "Non-Hispanic Asian or Pacific Islander",
73
+ "Age-adjusted rate": "202.5"
74
+ },
75
+ {
76
+ "Race": "Non-Hispanic White",
77
+ "Age-adjusted rate": "183.6"
78
+ }
79
+ ]
80
+ }
81
+ },
82
+ "table": {
83
+ "label": "Data Table",
84
+ "show": false,
85
+ "showDownloadUrl": false,
86
+ "showVertical": true
87
+ },
88
+ "newViz": true,
89
+ "datasets": {
90
+ "valid-data-chart.csv": {
91
+ "data": [
92
+ {
93
+ "Race": "Hispanic or Latino",
94
+ "Age-adjusted rate": "644.2"
95
+ },
96
+ {
97
+ "Race": "Non-Hispanic American Indian",
98
+ "Age-adjusted rate": "6360.1"
99
+ },
100
+ {
101
+ "Race": "Non-Hispanic Black",
102
+ "Age-adjusted rate": "563.7"
103
+ },
104
+ {
105
+ "Race": "Non-Hispanic Asian or Pacific Islander",
106
+ "Age-adjusted rate": "202.5"
107
+ },
108
+ {
109
+ "Race": "Non-Hispanic White",
110
+ "Age-adjusted rate": "183.6"
111
+ }
112
+ ],
113
+ "dataFileSize": 178,
114
+ "dataFileName": "valid-data-chart.csv",
115
+ "dataFileSourceType": "file",
116
+ "dataFileFormat": "CSV",
117
+ "preview": true
118
+ }
119
+ },
120
+ "data": [
121
+ {
122
+ "Race": "Hispanic or Latino",
123
+ "Age-adjusted rate": "644.2"
124
+ },
125
+ {
126
+ "Race": "Non-Hispanic American Indian",
127
+ "Age-adjusted rate": "6360.1"
128
+ },
129
+ {
130
+ "Race": "Non-Hispanic Black",
131
+ "Age-adjusted rate": "563.7"
132
+ },
133
+ {
134
+ "Race": "Non-Hispanic Asian or Pacific Islander",
135
+ "Age-adjusted rate": "202.5"
136
+ },
137
+ {
138
+ "Race": "Non-Hispanic White",
139
+ "Age-adjusted rate": "183.6"
140
+ }
141
+ ],
142
+ "type": "dashboard",
143
+ "runtime": {}
144
+ }
@@ -4,6 +4,7 @@ import '../scss/choose-vis-tab.scss'
4
4
  import ConfigContext, { EditorDispatchContext } from '../ConfigContext'
5
5
  import Tooltip from '@cdc/core/components/ui/Tooltip'
6
6
 
7
+ import InfoIcon from '@cdc/core/assets/icon-info.svg'
7
8
  import DashboardIcon from '@cdc/core/assets/icon-dashboard.svg'
8
9
  import BarIcon from '@cdc/core/assets/icon-chart-bar.svg'
9
10
  import LineIcon from '@cdc/core/assets/icon-chart-line.svg'
@@ -23,6 +24,7 @@ import GaugeChartIcon from '@cdc/core/assets/icon-linear-gauge.svg'
23
24
  import ForestPlotIcon from '@cdc/core/assets/icon-chart-forest-plot.svg'
24
25
  import ForecastIcon from '@cdc/core/assets/icon-chart-forecast.svg'
25
26
  import DeviationIcon from '@cdc/core/assets/icon-deviation-bar.svg'
27
+ import SankeyIcon from '@cdc/core/assets/icon-sankey.svg'
26
28
  import { Visualization } from '@cdc/core/types/Visualization'
27
29
 
28
30
  export default function ChooseTab() {
@@ -245,13 +247,22 @@ export default function ChooseTab() {
245
247
  </Tooltip>
246
248
  </li>
247
249
 
248
- <li>
250
+ {/* <li>
249
251
  <Tooltip>
250
252
  <Tooltip.Target>
251
253
  <IconButton label='Forest Plot' type='chart' subType='Forest Plot' orientation='vertical' icon={<ForestPlotIcon />} />
252
254
  </Tooltip.Target>
253
255
  <Tooltip.Content>Display a forest plot</Tooltip.Content>
254
256
  </Tooltip>
257
+ </li> */}
258
+
259
+ <li>
260
+ <Tooltip>
261
+ <Tooltip.Target>
262
+ <IconButton label='Sankey Diagram' type='chart' subType='Sankey' orientation='vertical' icon={<SankeyIcon />} />
263
+ </Tooltip.Target>
264
+ <Tooltip.Content>Display a sankey diagram</Tooltip.Content>
265
+ </Tooltip>
255
266
  </li>
256
267
  </ul>
257
268
 
@@ -101,7 +101,8 @@ const PreviewDataTable = ({ data }) => {
101
101
 
102
102
  let newData = [...data]
103
103
 
104
- newData = generateColumns(newData)
104
+ const isSankey = Object.keys(newData[0]).includes('tableData')
105
+ newData = generateColumns(isSankey ? newData[0].tableData : newData)
105
106
  validateFipsCodeLength(newData)
106
107
  setTableData(newData)
107
108
  }, [data, generateColumns])
@@ -2,18 +2,19 @@ import React, { useContext } from 'react'
2
2
  import SampleDataContext from '../samples/SampleDataContext'
3
3
 
4
4
  // Data Samples
5
- import validMapData from '../samples/valid-data-map.csv?raw'
6
- import validChartData from '../samples/valid-data-chart.csv?raw'
7
- import validCountyMapData from '../samples/valid-county-data.csv?raw'
8
- import validGeoPoint from '../samples/valid-geo-point.csv?raw'
9
- import validScatterPlot from '../samples/valid-scatterplot.csv?raw'
10
- import validBoxPlotData from '../samples/valid-boxplot.csv?raw'
11
- import validAreaChart from '../samples/valid-area-chart.json?raw'
12
- import validWorldGeocodeData from '../samples/valid-world-geocode.json?raw'
13
- import validForecastData from '../samples/valid-forecast-data.csv?raw'
14
- import validForestPlotData from '../samples/valid-forest-plot-data.csv?raw'
15
- import vaidWorldData from '../samples/valid-world-data.json?raw'
16
- import validRegionData from '../samples/valid-region-data.json?raw'
5
+ import validMapData from './../samples/valid-data-map.csv?raw'
6
+ import validChartData from './../samples/valid-data-chart.csv?raw'
7
+ import validCountyMapData from './../samples/valid-county-data.csv?raw'
8
+ import validGeoPoint from './../samples/valid-geo-point.csv?raw'
9
+ import validScatterPlot from './../samples/valid-scatterplot.csv?raw'
10
+ import validBoxPlotData from './../samples/valid-boxplot.csv?raw'
11
+ import validAreaChart from './../samples/valid-area-chart.json?raw'
12
+ import validWorldGeocodeData from './../samples/valid-world-geocode.json?raw'
13
+ import validForecastData from './../samples/valid-forecast-data.csv?raw'
14
+ import validForestPlotData from './../samples/valid-forest-plot-data.csv?raw'
15
+ import vaidWorldData from './../samples/valid-world-data.json?raw'
16
+ import validRegionData from './../samples/valid-region-data.json?raw'
17
+ import validSankeyData from './../samples/valid-sankey-data.json?raw'
17
18
 
18
19
  // Add additional data to samples
19
20
  const sampleData = {
@@ -43,10 +44,15 @@ const sampleData = {
43
44
  fileName: 'valid-forecast-data.csv',
44
45
  data: validForecastData
45
46
  },
47
+ // {
48
+ // text: 'Forest Plot Data',
49
+ // fileName: 'valid-forest-plot-data.csv',
50
+ // data: validForestPlotData
51
+ // },
46
52
  {
47
- text: 'Forest Plot Data',
48
- fileName: 'valid-forest-plot-data.csv',
49
- data: validForestPlotData
53
+ text: 'Sankey Chart Data',
54
+ fileName: 'valid-sankey-data.json',
55
+ data: validSankeyData
50
56
  }
51
57
  ],
52
58
  maps: [