@cdc/editor 1.4.4 → 4.22.10-alpha.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.
- package/LICENSE +201 -0
- package/dist/cdceditor.js +70 -52
- package/example/supported-cities.csv +107 -0
- package/example/valid-data-map.csv +2 -1
- package/package.json +9 -9
- package/src/CdcEditor.js +67 -6
- package/src/components/ChooseTab.js +49 -38
- package/src/components/DataImport.js +330 -335
- package/src/scss/configure-tab.scss +4 -1
- package/src/scss/data-import.scss +32 -55
- package/src/scss/main.scss +11 -1
- package/src/assets/icons/dashboard.svg +0 -8
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
City,Longitude,Latitude,Value
|
|
2
|
+
Albuquerque,-106.650421,35.084385,1
|
|
3
|
+
Anaheim,-117.914299,33.836594,2
|
|
4
|
+
Anchorage,-149.900284,61.218056,3
|
|
5
|
+
Arlington,-97.108063,32.735687,4
|
|
6
|
+
Atlanta,-84.387985,33.748997,5
|
|
7
|
+
Aurora,-93.717979,36.97089,6
|
|
8
|
+
Austin,-97.743057,30.267153,7
|
|
9
|
+
Bakersfield,-119.018715,35.373291,8
|
|
10
|
+
Baltimore,-76.61219,39.290386,9
|
|
11
|
+
Baton Rouge,-91.187149,30.451468,10
|
|
12
|
+
Boise,-116.202316,43.615021,11
|
|
13
|
+
Boston,-71.058884,42.360081,12
|
|
14
|
+
Buffalo,-78.878372,42.886448,13
|
|
15
|
+
Chandler,-111.841248,33.30616,14
|
|
16
|
+
Charlotte,-80.843124,35.227085,15
|
|
17
|
+
Chesapeake,-76.287491,36.768208,16
|
|
18
|
+
Chicago,-87.629799,41.878113,17
|
|
19
|
+
Chula Vista,-117.084198,32.640053,18
|
|
20
|
+
Cincinnati,-84.512016,39.103119,19
|
|
21
|
+
Cleveland,-81.694359,41.499321,20
|
|
22
|
+
Colorado Springs,-104.821365,38.833881,21
|
|
23
|
+
Columbus,-82.998795,39.961178,22
|
|
24
|
+
Corpus Christi,-97.396378,27.800583,23
|
|
25
|
+
Dallas,-96.796989,32.776665,24
|
|
26
|
+
Denver,-104.99025,39.739235,25
|
|
27
|
+
Detroit,-83.045753,42.331429,26
|
|
28
|
+
District of Columbia,-77.036873,38.907192,27
|
|
29
|
+
Durham,-78.898621,35.994034,28
|
|
30
|
+
El Paso,-106.485023,31.761877,29
|
|
31
|
+
Fort Wayne,-85.139351,41.079273,30
|
|
32
|
+
Ft Wayne,-85.139351,41.079273,31
|
|
33
|
+
Fort Worth,-97.330765,32.755489,32
|
|
34
|
+
Fremont,-121.988571,37.548271,33
|
|
35
|
+
Fresno,-119.787125,36.737797,34
|
|
36
|
+
Garland,-96.638885,32.912624,35
|
|
37
|
+
Gilbert,-111.789024,33.352825,36
|
|
38
|
+
Glendale,-118.255074,34.142509,37
|
|
39
|
+
Greensboro,-79.791977,36.072636,38
|
|
40
|
+
Henderson,-114.98172,36.039524,39
|
|
41
|
+
Hialeah,-80.278107,25.857595,40
|
|
42
|
+
Honolulu,-157.858337,21.306944,41
|
|
43
|
+
Houston,-95.358421,29.749907,42
|
|
44
|
+
Indianapolis,-86.158066,39.768402,43
|
|
45
|
+
Irvine,-117.826508,33.684566,44
|
|
46
|
+
Irving,-96.948891,32.814018,45
|
|
47
|
+
Jacksonville,-81.655647,30.332184,46
|
|
48
|
+
Jersey City,-74.077644,40.728157,47
|
|
49
|
+
Kansas City,-94.578568,39.099728,48
|
|
50
|
+
Laredo,-99.507553,27.503561,49
|
|
51
|
+
Las Vegas,-115.139832,36.169941,50
|
|
52
|
+
Lexington,-84.503716,38.040585,51
|
|
53
|
+
Lincoln,-95.262955,37.346134,52
|
|
54
|
+
Long Beach,-118.193741,33.77005,53
|
|
55
|
+
Los Angeles,-118.243683,34.052235,54
|
|
56
|
+
Los Angeles County,-118.229362,34.058762,55
|
|
57
|
+
Louisville,-85.758453,38.252666,56
|
|
58
|
+
Lubbock,-101.855164,33.577862,57
|
|
59
|
+
Madison,-89.40123,43.073051,58
|
|
60
|
+
"Marion County, Indiana",-86.136543,39.781029,59
|
|
61
|
+
Memphis,-90.048981,35.149532,60
|
|
62
|
+
Mesa,-111.831474,33.415184,61
|
|
63
|
+
Miami,-80.191788,25.761681,62
|
|
64
|
+
Milwaukee,-87.906471,43.038902,63
|
|
65
|
+
Minneapolis,-93.265015,44.977753,64
|
|
66
|
+
"Montgomery County, Maryland",-77.199406,39.153515,65
|
|
67
|
+
Nashville,-86.781601,36.162663,66
|
|
68
|
+
New Orleans,-90.071533,29.951065,67
|
|
69
|
+
New York City,-74.005974,40.712776,68
|
|
70
|
+
Newark,-95.582733,37.443188,69
|
|
71
|
+
Norfolk,-76.285873,36.850769,70
|
|
72
|
+
North Las Vegas,-115.114571,36.19585,71
|
|
73
|
+
Oakland,-122.271111,37.804363,72
|
|
74
|
+
Oklahoma City,-97.516426,35.46756,73
|
|
75
|
+
Omaha,-95.934502,41.256538,74
|
|
76
|
+
Orlando,-81.379234,28.538336,75
|
|
77
|
+
Philadelphia,-75.165222,39.952583,76
|
|
78
|
+
Phoenix,-112.074036,33.448376,77
|
|
79
|
+
Pittsburgh,-79.995888,40.440624,78
|
|
80
|
+
Plano,-96.698883,33.019844,79
|
|
81
|
+
Portland,-122.658722,45.51223,80
|
|
82
|
+
Raleigh,-78.638176,35.779591,81
|
|
83
|
+
Reno,-119.813805,39.529633,82
|
|
84
|
+
Richmond,-77.43605,37.540726,83
|
|
85
|
+
Riverside,-117.375496,33.980602,84
|
|
86
|
+
Sacramento,-121.4944,38.581573,85
|
|
87
|
+
Saint Paul,-93.089958,44.953705,86
|
|
88
|
+
San Antonio,-98.493629,29.424122,87
|
|
89
|
+
San Diego,-117.161087,32.715736,88
|
|
90
|
+
San Francisco,-122.419418,37.774929,89
|
|
91
|
+
San Jose,-121.88633,37.338207,90
|
|
92
|
+
Santa Ana,-117.867653,33.745472,91
|
|
93
|
+
Scottsdale,-111.926048,33.494171,92
|
|
94
|
+
Seattle,-122.332069,47.606209,93
|
|
95
|
+
Spokane,-117.426048,47.658779,94
|
|
96
|
+
St. Louis,-90.199402,38.627003,95
|
|
97
|
+
St. Petersburg,-82.640289,27.767601,96
|
|
98
|
+
Stockton,-121.290779,37.957703,97
|
|
99
|
+
Tampa,-82.457176,27.950575,98
|
|
100
|
+
Toledo,-83.537865,41.652805,99
|
|
101
|
+
Tucson,-110.974709,32.222607,100
|
|
102
|
+
Tuscon,-110.974709,32.222607,101
|
|
103
|
+
Tulsa,-95.992775,36.15398,102
|
|
104
|
+
Virginia Beach,-75.977982,36.852924,103
|
|
105
|
+
Wichita,-97.330055,37.687176,104
|
|
106
|
+
Winston Salem,-80.244217,36.099861,105
|
|
107
|
+
Winston–Salem,-80.244217,36.099861,106
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdc/editor",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.22.10-alpha.1",
|
|
4
4
|
"main": "dist/cdceditor",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/CDCgov/cdc-open-viz/issues"
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@babel/runtime": "^7.12.5",
|
|
21
|
-
"@cdc/chart": "^
|
|
22
|
-
"@cdc/core": "^
|
|
23
|
-
"@cdc/dashboard": "^
|
|
24
|
-
"@cdc/data-bite": "^
|
|
25
|
-
"@cdc/map": "^
|
|
26
|
-
"@cdc/markup-include": "^
|
|
27
|
-
"@cdc/waffle-chart": "^
|
|
21
|
+
"@cdc/chart": "^9.22.9",
|
|
22
|
+
"@cdc/core": "^4.22.10",
|
|
23
|
+
"@cdc/dashboard": "^4.22.10-alpha.1",
|
|
24
|
+
"@cdc/data-bite": "^4.22.10",
|
|
25
|
+
"@cdc/map": "^4.22.10-alpha.1",
|
|
26
|
+
"@cdc/markup-include": "^4.22.10",
|
|
27
|
+
"@cdc/waffle-chart": "^4.22.10",
|
|
28
28
|
"axios": "^0.21.1",
|
|
29
29
|
"d3": "^7.0.0",
|
|
30
30
|
"html-react-parser": "1.4.9",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"resolutions": {
|
|
41
41
|
"@types/react": "17.x"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "bc6f9efd741e5b22140edc58c7a7f9e5efc43d1e"
|
|
44
44
|
}
|
package/src/CdcEditor.js
CHANGED
|
@@ -33,6 +33,54 @@ export default function CdcEditor({ config: configObj = {newViz: true}, hostname
|
|
|
33
33
|
startingTab = 2
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
// Legacy support - dashboards using a single dataset
|
|
37
|
+
if(config.type === 'dashboard'){
|
|
38
|
+
let legacyUpdateNeeded = false;
|
|
39
|
+
let newConfig;
|
|
40
|
+
|
|
41
|
+
if(config.data || config.dataUrl){
|
|
42
|
+
legacyUpdateNeeded = true;
|
|
43
|
+
newConfig = {...config};
|
|
44
|
+
|
|
45
|
+
newConfig.datasets = {};
|
|
46
|
+
newConfig.datasets[config.dataFileName || 'dataset-1'] = {
|
|
47
|
+
data: config.data,
|
|
48
|
+
dataUrl: config.dataUrl,
|
|
49
|
+
dataFileName: config.dataFileName || 'dataset-1',
|
|
50
|
+
dataFileSourceType: config.dataFileSourceType
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
Object.keys(newConfig.visualizations).forEach(vizKey => {
|
|
54
|
+
newConfig.visualizations[vizKey].dataKey = config.dataFileName || 'dataset-1';
|
|
55
|
+
newConfig.visualizations[vizKey].dataDescription = newConfig.dataDescription;
|
|
56
|
+
newConfig.visualizations[vizKey].formattedData = newConfig.formattedData;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
delete newConfig.data;
|
|
60
|
+
delete newConfig.dataUrl;
|
|
61
|
+
delete newConfig.dataFileName;
|
|
62
|
+
delete newConfig.dataFileSourceType;
|
|
63
|
+
delete newConfig.dataDescription;
|
|
64
|
+
delete newConfig.formattedData;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if(config.dashboard && config.dashboard.filters){
|
|
68
|
+
legacyUpdateNeeded = true;
|
|
69
|
+
newConfig = {...config};
|
|
70
|
+
|
|
71
|
+
newConfig.dashboard.sharedFilters = newConfig.dashboard.sharedFilters || [];
|
|
72
|
+
newConfig.dashboard.filters.forEach(filter => {
|
|
73
|
+
newConfig.dashboard.sharedFilters.push({...filter, key: filter.label, showDropdown: true, usedBy: Object.keys(newConfig.visualizations)});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
delete newConfig.dashboard.filters;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if(legacyUpdateNeeded){
|
|
80
|
+
setConfig(newConfig);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
36
84
|
const [globalActive, setGlobalActive] = useState(startingTab);
|
|
37
85
|
|
|
38
86
|
const resizeObserver = new ResizeObserver(([ container ]) => {
|
|
@@ -101,18 +149,31 @@ export default function CdcEditor({ config: configObj = {newViz: true}, hostname
|
|
|
101
149
|
sharepath
|
|
102
150
|
}
|
|
103
151
|
|
|
152
|
+
let configureDisabled = true;
|
|
153
|
+
|
|
154
|
+
if(config.type !== 'dashboard'){
|
|
155
|
+
if(config.formattedData){
|
|
156
|
+
configureDisabled = false;
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
if(config.datasets && Object.keys(config.datasets).length > 0){
|
|
160
|
+
configureDisabled = false;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
104
164
|
return (
|
|
105
165
|
<GlobalContextProvider>
|
|
106
166
|
<GlobalState.Provider value={state}>
|
|
107
|
-
<div className={`cdc-open-viz-module cdc-editor ${currentViewport}`} ref={outerContainerRef}
|
|
167
|
+
<div className={`cdc-open-viz-module cdc-editor ${currentViewport}`} ref={outerContainerRef}>
|
|
108
168
|
<Tabs className="top-level" startingTab={globalActive}>
|
|
109
|
-
<TabPane title="1.
|
|
110
|
-
<DataImport />
|
|
111
|
-
</TabPane>
|
|
112
|
-
<TabPane title="2. Choose Visualization Type" className="choose-type" disableRule={!config.data && !config.formattedData}>
|
|
169
|
+
<TabPane title="1. Choose Visualization Type" className="choose-type">
|
|
113
170
|
<ChooseTab />
|
|
114
171
|
</TabPane>
|
|
115
|
-
<TabPane title="
|
|
172
|
+
<TabPane title="2. Import Data" className="data-designer" disableRule={!config.type}>
|
|
173
|
+
<DataImport />
|
|
174
|
+
</TabPane>
|
|
175
|
+
|
|
176
|
+
<TabPane title="3. Configure" className="configure" disableRule={configureDisabled}>
|
|
116
177
|
<ConfigureTab containerEl={containerEl }/>
|
|
117
178
|
</TabPane>
|
|
118
179
|
</Tabs>
|
|
@@ -4,19 +4,18 @@ import '../scss/choose-vis-tab.scss'
|
|
|
4
4
|
import GlobalState from '../context'
|
|
5
5
|
import Tooltip from '@cdc/core/components/ui/Tooltip'
|
|
6
6
|
|
|
7
|
-
import DashboardIcon from '
|
|
8
|
-
import BarIcon from '@cdc/core/assets/chart-bar
|
|
9
|
-
import LineIcon from '@cdc/core/assets/chart-line
|
|
10
|
-
import PieIcon from '@cdc/core/assets/chart-pie
|
|
11
|
-
import GlobeIcon from '@cdc/core/assets/world
|
|
12
|
-
import UsaIcon from '@cdc/core/assets/usa
|
|
7
|
+
import DashboardIcon from '@cdc/core/assets/icon-dashboard.svg'
|
|
8
|
+
import BarIcon from '@cdc/core/assets/icon-chart-bar.svg'
|
|
9
|
+
import LineIcon from '@cdc/core/assets/icon-chart-line.svg'
|
|
10
|
+
import PieIcon from '@cdc/core/assets/icon-chart-pie.svg'
|
|
11
|
+
import GlobeIcon from '@cdc/core/assets/icon-map-world.svg'
|
|
12
|
+
import UsaIcon from '@cdc/core/assets/icon-map-usa.svg'
|
|
13
13
|
import UsaRegionIcon from '@cdc/core/assets/usa-region-graphic.svg'
|
|
14
|
-
import DataBiteIcon from '@cdc/core/assets/
|
|
14
|
+
import DataBiteIcon from '@cdc/core/assets/icon-databite.svg'
|
|
15
15
|
import WaffleChartIcon from '@cdc/core/assets/icon-grid.svg'
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import HorizontalStackIcon from '@cdc/core/assets/horizontal-stacked-bar.svg'
|
|
16
|
+
import AlabamaGraphic from '@cdc/core/assets/icon-map-alabama.svg'
|
|
17
|
+
import PairedBarIcon from '@cdc/core/assets/icon-chart-bar-paired.svg'
|
|
18
|
+
import HorizontalStackIcon from '@cdc/core/assets/icon-chart-bar-stacked.svg'
|
|
20
19
|
|
|
21
20
|
export default function ChooseTab() {
|
|
22
21
|
const { config, setConfig, setGlobalActive, tempConfig, setTempConfig } = useContext(GlobalState)
|
|
@@ -31,7 +30,7 @@ export default function ChooseTab() {
|
|
|
31
30
|
/**
|
|
32
31
|
* IconButton component
|
|
33
32
|
*/
|
|
34
|
-
const IconButton = ({ icon, label, type, subType, barType, orientation, stacked = false }) => {
|
|
33
|
+
const IconButton = ({ icon, label, type, subType, barType, orientation, stacked = false, generalType = "data" }) => {
|
|
35
34
|
let isSubType = false
|
|
36
35
|
let isHorizontalStackedChart = false
|
|
37
36
|
let classNames;
|
|
@@ -46,7 +45,7 @@ export default function ChooseTab() {
|
|
|
46
45
|
isHorizontalStackedChart = (orientation === config.orientation && stacked === true)
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
if
|
|
48
|
+
if(type === 'dashboard' || type === 'data-bite' || type === 'waffle-chart' || type === 'markup-include') isSubType = true;
|
|
50
49
|
|
|
51
50
|
// TODO: sorry, we should refactor this at some point.
|
|
52
51
|
// trying to get this out for 4.22.5 - this is so stacked horizontal and bar charts aren't highlighted at the same time.
|
|
@@ -63,34 +62,36 @@ export default function ChooseTab() {
|
|
|
63
62
|
|
|
64
63
|
|
|
65
64
|
let setTypes = () => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
dataFileName: config.dataFileName,
|
|
70
|
-
dataFileSourceType: config.dataFileSourceType,
|
|
71
|
-
dataDescription: config.dataDescription,
|
|
72
|
-
dataUrl: config.dataUrl,
|
|
73
|
-
newViz: true,
|
|
74
|
-
type,
|
|
75
|
-
orientation: orientation ? orientation : null,
|
|
76
|
-
visualizationSubType: label === 'Horizontal Bar (Stacked)' ? 'stacked' : null
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (config.formattedData) {
|
|
80
|
-
newConfig.formattedData = config.formattedData
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (type === 'map') {
|
|
84
|
-
newConfig.general = {
|
|
85
|
-
...newConfig.general,
|
|
86
|
-
geoType: subType
|
|
65
|
+
if(type === config.type){
|
|
66
|
+
if(subType !== config.visualizationType){
|
|
67
|
+
setConfig({...config, newViz: true, visualizationType: subType})
|
|
87
68
|
}
|
|
69
|
+
|
|
70
|
+
setGlobalActive(1)
|
|
88
71
|
} else {
|
|
89
|
-
|
|
72
|
+
let confirmation = !config.type || window.confirm('Changing visualization type will clear configuration settings. Do you want to continue?');
|
|
73
|
+
|
|
74
|
+
if(confirmation){
|
|
75
|
+
let newConfig = {
|
|
76
|
+
newViz: true,
|
|
77
|
+
datasets: {},
|
|
78
|
+
type
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if(type === 'map') {
|
|
82
|
+
newConfig.general = {
|
|
83
|
+
...newConfig.general,
|
|
84
|
+
geoType: subType,
|
|
85
|
+
type: generalType
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
newConfig.visualizationType = subType
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
setConfig(newConfig);
|
|
92
|
+
setGlobalActive(1)
|
|
93
|
+
}
|
|
90
94
|
}
|
|
91
|
-
|
|
92
|
-
setConfig(newConfig)
|
|
93
|
-
setGlobalActive(2)
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
return (<button className={classNames} onClick={() => setTypes()} aria-label={label}>{icon}<span
|
|
@@ -237,6 +238,16 @@ export default function ChooseTab() {
|
|
|
237
238
|
</Tooltip.Content>
|
|
238
239
|
</Tooltip>
|
|
239
240
|
</li>
|
|
241
|
+
<li>
|
|
242
|
+
<Tooltip>
|
|
243
|
+
<Tooltip.Target>
|
|
244
|
+
<IconButton label="U.S. Geocode" type="map" subType="us-county" generalType="us-geocode" icon={<UsaIcon />}/>
|
|
245
|
+
</Tooltip.Target>
|
|
246
|
+
<Tooltip.Content>
|
|
247
|
+
United States GeoCode
|
|
248
|
+
</Tooltip.Content>
|
|
249
|
+
</Tooltip>
|
|
250
|
+
</li>
|
|
240
251
|
</ul>
|
|
241
252
|
</div>
|
|
242
253
|
)
|