@cdc/map 4.25.6 → 4.25.7-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.
@@ -0,0 +1,427 @@
1
+ {
2
+ "general": {
3
+ "geoType": "us",
4
+ "geoBorderColor": "darkGray",
5
+ "showTitle": false,
6
+ "showSidebar": true,
7
+ "showDownloadButton": false,
8
+ "showDownloadMediaButton": false,
9
+ "displayAsHex": true,
10
+ "displayStateLabels": false,
11
+ "territoriesLabel": "Territories",
12
+ "language": "en",
13
+ "hasRegions": false,
14
+ "expandDataTable": false,
15
+ "fullBorder": false,
16
+ "type": "data",
17
+ "palette": {
18
+ "isReversed": true
19
+ },
20
+ "geoLabelOverride": "",
21
+ "convertFipsCodes": true,
22
+ "allowMapZoom": true,
23
+ "hideGeoColumnInTooltip": false,
24
+ "hidePrimaryColumnInTooltip": false,
25
+ "superTitle": "",
26
+ "equalNumberOptIn": true,
27
+ "navigationTarget": "_self",
28
+ "noStateFoundMessage": "Map Unavailable",
29
+ "annotationDropdownText": "Annotations",
30
+ "headerColor": "theme-blue",
31
+ "title": "",
32
+ "territoriesAlwaysShow": false,
33
+ "statePicked": {
34
+ "fipsCode": "01",
35
+ "stateName": "Alabama"
36
+ }
37
+ },
38
+ "type": "map",
39
+ "customColors": [
40
+ "gray",
41
+ "#edf8fb",
42
+ "gray",
43
+ "#b3cde3",
44
+ "gray",
45
+ "#8c96c6",
46
+ "#8856a7",
47
+ "#810f7c"
48
+ ],
49
+ "columns": {
50
+ "geo": {
51
+ "name": "state",
52
+ "label": "Location",
53
+ "tooltip": false,
54
+ "dataTable": true
55
+ },
56
+ "primary": {
57
+ "dataTable": true,
58
+ "tooltip": true,
59
+ "prefix": "",
60
+ "suffix": "%",
61
+ "name": "value",
62
+ "label": "",
63
+ "roundToPlace": 1
64
+ },
65
+ "navigate": {
66
+ "name": ""
67
+ },
68
+ "latitude": {
69
+ "name": ""
70
+ },
71
+ "longitude": {
72
+ "name": ""
73
+ }
74
+ },
75
+ "legend": {
76
+ "descriptions": {},
77
+ "specialClasses": [
78
+ {
79
+ "key": "value",
80
+ "value": "",
81
+ "label": "No data"
82
+ }
83
+ ],
84
+ "unified": false,
85
+ "singleColumn": false,
86
+ "dynamicDescription": false,
87
+ "type": "equalnumber",
88
+ "numberOfItems": 5,
89
+ "position": "side",
90
+ "title": "Legend",
91
+ "singleRow": false,
92
+ "verticalSorted": false,
93
+ "showSpecialClassesLast": true,
94
+ "categoryValuesOrder": [
95
+ "No",
96
+ "Yes"
97
+ ]
98
+ },
99
+ "filters": [],
100
+ "table": {
101
+ "wrapColumns": false,
102
+ "label": "Data Table",
103
+ "expanded": false,
104
+ "limitHeight": false,
105
+ "height": "",
106
+ "caption": "",
107
+ "showDownloadUrl": false,
108
+ "showDataTableLink": false,
109
+ "showFullGeoNameInCSV": false,
110
+ "forceDisplay": false,
111
+ "download": true,
112
+ "indexLabel": "",
113
+ "showDownloadLinkBelow": true,
114
+ "cellMinWidth": "0"
115
+ },
116
+ "tooltips": {
117
+ "appearanceType": "hover",
118
+ "linkLabel": "Learn More",
119
+ "capitalizeLabels": true,
120
+ "opacity": 90
121
+ },
122
+ "visual": {
123
+ "minBubbleSize": 1,
124
+ "maxBubbleSize": 20,
125
+ "extraBubbleBorder": false,
126
+ "cityStyle": "circle",
127
+ "cityStyleLabel": "",
128
+ "showBubbleZeros": false,
129
+ "additionalCityStyles": [],
130
+ "geoCodeCircleSize": 8
131
+ },
132
+ "mapPosition": {
133
+ "coordinates": [
134
+ 0,
135
+ 30
136
+ ],
137
+ "zoom": 1
138
+ },
139
+ "map": {
140
+ "layers": [],
141
+ "patterns": []
142
+ },
143
+ "filterBehavior": "Filter Change",
144
+ "dataTable": {
145
+ "title": "Data Table",
146
+ "forceDisplay": true,
147
+ "caption": "Lorem Ipsum - Text added to Data Table Caption",
148
+ "limitHeight": true,
149
+ "height": "100"
150
+ },
151
+ "orientation": null,
152
+ "visualizationSubType": null,
153
+ "validated": "4.24.3",
154
+ "version": "4.24.12",
155
+ "data": [
156
+ {
157
+ "state": "Alaska",
158
+ "stratification": "Total",
159
+ "value": "33.3"
160
+ },
161
+ {
162
+ "state": "Alabama",
163
+ "stratification": "Total",
164
+ "value": "32.7"
165
+ },
166
+ {
167
+ "state": "Arkansas",
168
+ "stratification": "Total",
169
+ "value": "31.8"
170
+ },
171
+ {
172
+ "state": "Arizona",
173
+ "stratification": "Total",
174
+ "value": "34.5"
175
+ },
176
+ {
177
+ "state": "California",
178
+ "stratification": "Total",
179
+ "value": "36.4"
180
+ },
181
+ {
182
+ "state": "Colorado",
183
+ "stratification": "Total",
184
+ "value": "35.0"
185
+ },
186
+ {
187
+ "state": "Connecticut",
188
+ "stratification": "Total",
189
+ "value": "36.5"
190
+ },
191
+ {
192
+ "state": "District of Columbia",
193
+ "stratification": "Total",
194
+ "value": "33.5"
195
+ },
196
+ {
197
+ "state": "Delaware",
198
+ "stratification": "Total",
199
+ "value": "35.6"
200
+ },
201
+ {
202
+ "state": "Florida",
203
+ "stratification": "Total",
204
+ "value": "35.6"
205
+ },
206
+ {
207
+ "state": "Georgia",
208
+ "stratification": "Total",
209
+ "value": "33.7"
210
+ },
211
+ {
212
+ "state": "Guam",
213
+ "stratification": "Total",
214
+ "value": "34.9"
215
+ },
216
+ {
217
+ "state": "Hawaii",
218
+ "stratification": "Total",
219
+ "value": "34.4"
220
+ },
221
+ {
222
+ "state": "Iowa",
223
+ "stratification": "Total",
224
+ "value": "34.3"
225
+ },
226
+ {
227
+ "state": "Idaho",
228
+ "stratification": "Total",
229
+ "value": "35.7"
230
+ },
231
+ {
232
+ "state": "Illinois",
233
+ "stratification": "Total",
234
+ "value": "35.0"
235
+ },
236
+ {
237
+ "state": "Indiana",
238
+ "stratification": "Total",
239
+ "value": "33.3"
240
+ },
241
+ {
242
+ "state": "Kansas",
243
+ "stratification": "Total",
244
+ "value": "33.3"
245
+ },
246
+ {
247
+ "state": "Kentucky",
248
+ "stratification": "Total",
249
+ "value": ""
250
+ },
251
+ {
252
+ "state": "Louisiana",
253
+ "stratification": "Total",
254
+ "value": "32.1"
255
+ },
256
+ {
257
+ "state": "Massachusetts",
258
+ "stratification": "Total",
259
+ "value": "35.2"
260
+ },
261
+ {
262
+ "state": "Maryland",
263
+ "stratification": "Total",
264
+ "value": "34.7"
265
+ },
266
+ {
267
+ "state": "Maine",
268
+ "stratification": "Total",
269
+ "value": "35.3"
270
+ },
271
+ {
272
+ "state": "Michigan",
273
+ "stratification": "Total",
274
+ "value": "33.4"
275
+ },
276
+ {
277
+ "state": "Minnesota",
278
+ "stratification": "Total",
279
+ "value": "34.2"
280
+ },
281
+ {
282
+ "state": "Missouri",
283
+ "stratification": "Total",
284
+ "value": "34.3"
285
+ },
286
+ {
287
+ "state": "Mississippi",
288
+ "stratification": "Total",
289
+ "value": "31.6"
290
+ },
291
+ {
292
+ "state": "Montana",
293
+ "stratification": "Total",
294
+ "value": "35.2"
295
+ },
296
+ {
297
+ "state": "North Carolina",
298
+ "stratification": "Total",
299
+ "value": "35.0"
300
+ },
301
+ {
302
+ "state": "North Dakota",
303
+ "stratification": "Total",
304
+ "value": "35.8"
305
+ },
306
+ {
307
+ "state": "Nebraska",
308
+ "stratification": "Total",
309
+ "value": "34.8"
310
+ },
311
+ {
312
+ "state": "New Hampshire",
313
+ "stratification": "Total",
314
+ "value": "35.6"
315
+ },
316
+ {
317
+ "state": "New Jersey",
318
+ "stratification": "Total",
319
+ "value": "35.9"
320
+ },
321
+ {
322
+ "state": "New Mexico",
323
+ "stratification": "Total",
324
+ "value": "33.9"
325
+ },
326
+ {
327
+ "state": "Nevada",
328
+ "stratification": "Total",
329
+ "value": "35.6"
330
+ },
331
+ {
332
+ "state": "New York",
333
+ "stratification": "Total",
334
+ "value": "36.1"
335
+ },
336
+ {
337
+ "state": "Ohio",
338
+ "stratification": "Total",
339
+ "value": "33.2"
340
+ },
341
+ {
342
+ "state": "Oklahoma",
343
+ "stratification": "Total",
344
+ "value": "31.9"
345
+ },
346
+ {
347
+ "state": "Oregon",
348
+ "stratification": "Total",
349
+ "value": "33.4"
350
+ },
351
+ {
352
+ "state": "Pennsylvania",
353
+ "stratification": "Total",
354
+ "value": ""
355
+ },
356
+ {
357
+ "state": "Puerto Rico",
358
+ "stratification": "Total",
359
+ "value": "35.1"
360
+ },
361
+ {
362
+ "state": "Rhode Island",
363
+ "stratification": "Total",
364
+ "value": "34.8"
365
+ },
366
+ {
367
+ "state": "South Carolina",
368
+ "stratification": "Total",
369
+ "value": "33.9"
370
+ },
371
+ {
372
+ "state": "South Dakota",
373
+ "stratification": "Total",
374
+ "value": "34.3"
375
+ },
376
+ {
377
+ "state": "Tennessee",
378
+ "stratification": "Total",
379
+ "value": "33.1"
380
+ },
381
+ {
382
+ "state": "Texas",
383
+ "stratification": "Total",
384
+ "value": "35.0"
385
+ },
386
+ {
387
+ "state": "Utah",
388
+ "stratification": "Total",
389
+ "value": "34.3"
390
+ },
391
+ {
392
+ "state": "Virginia",
393
+ "stratification": "Total",
394
+ "value": "34.3"
395
+ },
396
+ {
397
+ "state": "Virgin Islands",
398
+ "stratification": "Total",
399
+ "value": "38.2"
400
+ },
401
+ {
402
+ "state": "Vermont",
403
+ "stratification": "Total",
404
+ "value": "34.8"
405
+ },
406
+ {
407
+ "state": "Washington",
408
+ "stratification": "Total",
409
+ "value": "35.2"
410
+ },
411
+ {
412
+ "state": "Wisconsin",
413
+ "stratification": "Total",
414
+ "value": "34.1"
415
+ },
416
+ {
417
+ "state": "West Virginia",
418
+ "stratification": "Total",
419
+ "value": "32.0"
420
+ },
421
+ {
422
+ "state": "Wyoming",
423
+ "stratification": "Total",
424
+ "value": "35.7"
425
+ }
426
+ ]
427
+ }
package/index.html CHANGED
@@ -34,6 +34,15 @@
34
34
 
35
35
  <noscript>You need to enable JavaScript to run this app.</noscript>
36
36
  <script type="module" src="./src/index.jsx"></script>
37
+ <!-- add cove_loaded listener -->
38
+ <!-- <script>
39
+ document.addEventListener('cove_loaded', function () {
40
+ // This is a temporary fix to ensure the map loads after Cove has loaded
41
+ // and the cdc-map-outer-container is available.
42
+ debugger
43
+ console.log('Cove has loaded, initializing map...');
44
+ });
45
+ </script> -->
37
46
  </body>
38
47
 
39
48
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdc/map",
3
- "version": "4.25.6",
3
+ "version": "4.25.7-2",
4
4
  "description": "React component for visualizing tabular data on a map of the United States or the world.",
5
5
  "moduleName": "CdcMap",
6
6
  "main": "dist/cdcmap",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "license": "Apache-2.0",
27
27
  "dependencies": {
28
- "@cdc/core": "^4.25.6",
28
+ "@cdc/core": "^4.25.7",
29
29
  "@googlemaps/markerclusterer": "^2.5.3",
30
30
  "@hello-pangea/dnd": "^16.2.0",
31
31
  "@react-google-maps/api": "^2.20.6",
@@ -45,5 +45,5 @@
45
45
  "react": "^18.2.0",
46
46
  "react-dom": "^18.2.0"
47
47
  },
48
- "gitHead": "6097de1ff814001880d9ac64bd66becdc092d63c"
48
+ "gitHead": "432a2d1acab22915fafe793cb9da1f10318ff793"
49
49
  }
package/src/CdcMap.tsx CHANGED
@@ -6,6 +6,7 @@ import initialState from './data/initial-state'
6
6
  import coveUpdateWorker from '@cdc/core/helpers/coveUpdateWorker'
7
7
  import { addUIDs, validateFipsCodeLength } from './helpers'
8
8
  import EditorContext from '@cdc/editor/src/ConfigContext'
9
+ import { extractCoveData, updateVegaData } from '@cdc/core/helpers/vegaConfig'
9
10
  import { MapConfig } from './types/MapConfig'
10
11
  import _, { set } from 'lodash'
11
12
 
@@ -53,6 +54,10 @@ const CdcMap: React.FC<CdcMapProps> = ({
53
54
  if (newState.dataUrl) {
54
55
  let newData = await fetchRemoteData(newState.dataUrl, 'map')
55
56
 
57
+ if (newState.vegaConfig) {
58
+ newData = extractCoveData(updateVegaData(newState.vegaConfig, newData))
59
+ }
60
+
56
61
  if (newData && newState.dataDescription) {
57
62
  newData = transform.autoStandardize(newData)
58
63
  newData = transform.developerStandardize(newData, newState.dataDescription)
@@ -242,12 +242,39 @@ const CdcMapComponent: React.FC<CdcMapComponent> = ({
242
242
  }
243
243
  }
244
244
 
245
- useEffect(() => {
246
- if (config && !runtimeData.init && !coveLoadedHasRan && container) {
247
- publish('cove_loaded', { config: config })
245
+ /**
246
+ * Publishes 'cove_loaded' only after the map SVG is rendered in the DOM.
247
+ * Checks immediately, then uses a MutationObserver as a fallback for async rendering.
248
+ * Update the mapSvg ref if the map container changes.
249
+ */
250
+ const observeMapSvgLoaded = (mapSvgRef, config, coveLoadedHasRan, publish, dispatch) => {
251
+ // Immediate check in case SVG is already present
252
+ const svgEl = mapSvgRef.current?.querySelector('svg')
253
+ if (svgEl && svgEl.childNodes.length > 0) {
254
+ publish('cove_loaded', { config })
248
255
  dispatch({ type: 'SET_COVE_LOADED_HAS_RAN', payload: true })
256
+ return () => {}
249
257
  }
250
- }, [config, container, runtimeData.init])
258
+
259
+ // Fallback to observer for async SVG rendering
260
+ const observer = new MutationObserver(() => {
261
+ const svgEl = mapSvgRef.current?.querySelector('svg')
262
+ if (svgEl && svgEl.childNodes.length > 0) {
263
+ publish('cove_loaded', { config })
264
+ dispatch({ type: 'SET_COVE_LOADED_HAS_RAN', payload: true })
265
+ observer.disconnect()
266
+ }
267
+ })
268
+
269
+ observer.observe(mapSvgRef.current, { childList: true, subtree: true })
270
+
271
+ return () => observer.disconnect()
272
+ }
273
+
274
+ useEffect(() => {
275
+ if (!mapSvg.current || coveLoadedHasRan) return
276
+ return observeMapSvgLoaded(mapSvg, config, coveLoadedHasRan, publish, dispatch)
277
+ }, [config, loading, runtimeData, coveLoadedHasRan])
251
278
 
252
279
  useEffect(() => {
253
280
  // UID
@@ -1104,8 +1104,9 @@ const EditorPanel: React.FC<MapEditorPanelProps> = ({ datasets }) => {
1104
1104
  </span>
1105
1105
  <ul className='geo-buttons d-grid' style={{ gridTemplateColumns: 'repeat(2, 1fr)', gap: '8px' }}>
1106
1106
  <button
1107
- className={`${config.general.geoType === 'us' || config.general.geoType === 'us-county' ? 'active' : ''
1108
- } full-width`}
1107
+ className={`${
1108
+ config.general.geoType === 'us' || config.general.geoType === 'us-county' ? 'active' : ''
1109
+ } full-width`}
1109
1110
  onClick={e => {
1110
1111
  e.preventDefault()
1111
1112
  handleEditorChanges('geoType', 'us')
@@ -3110,19 +3111,19 @@ const EditorPanel: React.FC<MapEditorPanelProps> = ({ datasets }) => {
3110
3111
  )}
3111
3112
  {(config.general.geoType === 'world' ||
3112
3113
  (config.general.geoType === 'us' && config.general.type === 'bubble')) && (
3113
- <label className='checkbox'>
3114
- <input
3115
- type='checkbox'
3116
- checked={config.visual.showBubbleZeros}
3117
- onChange={event => {
3118
- const _newConfig = _.cloneDeep(config)
3119
- _newConfig.visual.showBubbleZeros = event.target.checked
3120
- setConfig(_newConfig)
3121
- }}
3122
- />
3123
- <span className='edit-label'>Show Data with Zero's on Bubble Map</span>
3124
- </label>
3125
- )}
3114
+ <label className='checkbox'>
3115
+ <input
3116
+ type='checkbox'
3117
+ checked={config.visual.showBubbleZeros}
3118
+ onChange={event => {
3119
+ const _newConfig = _.cloneDeep(config)
3120
+ _newConfig.visual.showBubbleZeros = event.target.checked
3121
+ setConfig(_newConfig)
3122
+ }}
3123
+ />
3124
+ <span className='edit-label'>Show Data with Zero's on Bubble Map</span>
3125
+ </label>
3126
+ )}
3126
3127
  {(config.general.geoType === 'world' || config.general.geoType === 'single-state') && (
3127
3128
  <label className='checkbox'>
3128
3129
  <input
@@ -3156,42 +3157,42 @@ const EditorPanel: React.FC<MapEditorPanelProps> = ({ datasets }) => {
3156
3157
  {(config.general.geoType === 'us' ||
3157
3158
  config.general.geoType === 'us-county' ||
3158
3159
  config.general.geoType === 'world') && (
3159
- <>
3160
- <label>
3161
- <span className='edit-label'>Default City Style</span>
3162
- <select
3163
- value={config.visual.cityStyle || false}
3164
- onChange={event => {
3165
- handleEditorChanges('handleCityStyle', event.target.value)
3166
- }}
3167
- >
3168
- <option value='circle'>Circle</option>
3169
- <option value='pin'>Pin</option>
3170
- <option value='square'>Square</option>
3171
- <option value='triangle'>Triangle</option>
3172
- <option value='diamond'>Diamond</option>
3173
- <option value='star'>Star</option>
3174
- </select>
3175
- </label>
3176
- <TextField
3177
- value={config.visual.cityStyleLabel}
3178
- section='visual'
3179
- fieldName='cityStyleLabel'
3180
- label='Label (Optional) '
3181
- updateField={updateField}
3182
- tooltip={
3183
- <Tooltip style={{ textTransform: 'none' }}>
3184
- <Tooltip.Target>
3185
- <Icon display='question' style={{ marginLeft: '0.5rem' }} />
3186
- </Tooltip.Target>
3187
- <Tooltip.Content>
3188
- <p>When a label is provided, the default city style will appear in the legend.</p>
3189
- </Tooltip.Content>
3190
- </Tooltip>
3191
- }
3192
- />
3193
- </>
3194
- )}
3160
+ <>
3161
+ <label>
3162
+ <span className='edit-label'>Default City Style</span>
3163
+ <select
3164
+ value={config.visual.cityStyle || false}
3165
+ onChange={event => {
3166
+ handleEditorChanges('handleCityStyle', event.target.value)
3167
+ }}
3168
+ >
3169
+ <option value='circle'>Circle</option>
3170
+ <option value='pin'>Pin</option>
3171
+ <option value='square'>Square</option>
3172
+ <option value='triangle'>Triangle</option>
3173
+ <option value='diamond'>Diamond</option>
3174
+ <option value='star'>Star</option>
3175
+ </select>
3176
+ </label>
3177
+ <TextField
3178
+ value={config.visual.cityStyleLabel}
3179
+ section='visual'
3180
+ fieldName='cityStyleLabel'
3181
+ label='Label (Optional) '
3182
+ updateField={updateField}
3183
+ tooltip={
3184
+ <Tooltip style={{ textTransform: 'none' }}>
3185
+ <Tooltip.Target>
3186
+ <Icon display='question' style={{ marginLeft: '0.5rem' }} />
3187
+ </Tooltip.Target>
3188
+ <Tooltip.Content>
3189
+ <p>When a label is provided, the default city style will appear in the legend.</p>
3190
+ </Tooltip.Content>
3191
+ </Tooltip>
3192
+ }
3193
+ />
3194
+ </>
3195
+ )}
3195
3196
  {/* <AdditionalCityStyles /> */}
3196
3197
  <>
3197
3198
  {config.visual.additionalCityStyles.length > 0 &&