@cdc/map 4.24.9 → 4.24.11
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/cdcmap.js +26371 -25867
- package/examples/private/DEV-9644.json +184 -0
- package/package.json +3 -3
- package/src/CdcMap.tsx +25 -12
- package/src/_stories/CdcMap.stories.tsx +2 -6
- package/src/_stories/CdcMapLegend.stories.tsx +86 -0
- package/src/_stories/_mock/usa-state-gradient.json +238 -0
- package/src/_stories/_mock/wastewater-map.json +208 -0
- package/src/components/Annotation/AnnotationDropdown.styles.css +0 -1
- package/src/components/CityList.tsx +55 -10
- package/src/components/DataTable.tsx +94 -17
- package/src/components/EditorPanel/components/EditorPanel.tsx +118 -64
- package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +27 -23
- package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +75 -16
- package/src/components/Legend/components/Legend.tsx +23 -19
- package/src/components/Legend/components/index.scss +23 -10
- package/src/components/UsaMap/components/HexIcon.tsx +7 -1
- package/src/components/UsaMap/components/Territory/Territory.Hexagon.tsx +56 -11
- package/src/components/UsaMap/components/Territory/Territory.Rectangle.tsx +88 -15
- package/src/components/UsaMap/components/Territory/TerritoryShape.ts +13 -0
- package/src/components/UsaMap/components/UsaMap.County.tsx +49 -48
- package/src/components/UsaMap/components/UsaMap.State.tsx +5 -4
- package/src/components/UsaMap/helpers/shapes.ts +207 -0
- package/src/coreStyles_map.scss +3 -0
- package/src/data/initial-state.js +1 -0
- package/src/index.jsx +7 -1
- package/src/scss/editor-panel.scss +5 -13
- package/src/scss/filters.scss +2 -7
- package/src/scss/main.scss +4 -9
- package/src/scss/map.scss +6 -6
- package/src/scss/mixins.scss +47 -0
- package/src/types/MapConfig.ts +6 -3
- package/src/types/MapContext.ts +0 -1
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
{
|
|
2
|
+
"annotations": [],
|
|
3
|
+
"general": {
|
|
4
|
+
"geoType": "us",
|
|
5
|
+
"noStateFoundMessage": "Map Unavailable",
|
|
6
|
+
"annotationDropdownText": "Annotations",
|
|
7
|
+
"geoBorderColor": "darkGray",
|
|
8
|
+
"headerColor": "theme-blue",
|
|
9
|
+
"title": "Number, percentage, and proportion of infants born with use of assisted reproductive technology in 2022, by preterm gestational age and female patient’s reporting area of residence at time of treatment",
|
|
10
|
+
"showTitle": false,
|
|
11
|
+
"showSidebar": true,
|
|
12
|
+
"showDownloadButton": true,
|
|
13
|
+
"showDownloadMediaButton": false,
|
|
14
|
+
"displayAsHex": false,
|
|
15
|
+
"displayStateLabels": false,
|
|
16
|
+
"territoriesLabel": "Territories",
|
|
17
|
+
"territoriesAlwaysShow": false,
|
|
18
|
+
"language": "en",
|
|
19
|
+
"geoLabelOverride": "",
|
|
20
|
+
"hasRegions": false,
|
|
21
|
+
"fullBorder": false,
|
|
22
|
+
"type": "data",
|
|
23
|
+
"convertFipsCodes": true,
|
|
24
|
+
"palette": {
|
|
25
|
+
"isReversed": false
|
|
26
|
+
},
|
|
27
|
+
"allowMapZoom": true,
|
|
28
|
+
"hideGeoColumnInTooltip": false,
|
|
29
|
+
"hidePrimaryColumnInTooltip": false,
|
|
30
|
+
"statePicked": {
|
|
31
|
+
"fipsCode": "01",
|
|
32
|
+
"stateName": "Alabama"
|
|
33
|
+
},
|
|
34
|
+
"expandDataTable": false
|
|
35
|
+
},
|
|
36
|
+
"type": "map",
|
|
37
|
+
"color": "sequential-blue-2(MPX)",
|
|
38
|
+
"columns": {
|
|
39
|
+
"geo": {
|
|
40
|
+
"name": "State",
|
|
41
|
+
"label": "Location",
|
|
42
|
+
"tooltip": false,
|
|
43
|
+
"dataTable": true
|
|
44
|
+
},
|
|
45
|
+
"primary": {
|
|
46
|
+
"dataTable": true,
|
|
47
|
+
"tooltip": true,
|
|
48
|
+
"prefix": "",
|
|
49
|
+
"suffix": "",
|
|
50
|
+
"name": "Ranges",
|
|
51
|
+
"label": "",
|
|
52
|
+
"roundToPlace": "1"
|
|
53
|
+
},
|
|
54
|
+
"navigate": {
|
|
55
|
+
"name": ""
|
|
56
|
+
},
|
|
57
|
+
"latitude": {
|
|
58
|
+
"name": ""
|
|
59
|
+
},
|
|
60
|
+
"longitude": {
|
|
61
|
+
"name": ""
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"legend": {
|
|
65
|
+
"descriptions": {
|
|
66
|
+
"0,0": [
|
|
67
|
+
"National Rate: 17.3"
|
|
68
|
+
],
|
|
69
|
+
"0,1": [
|
|
70
|
+
"National Rate: 4.3"
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
"specialClasses": [],
|
|
74
|
+
"unified": false,
|
|
75
|
+
"singleColumn": true,
|
|
76
|
+
"singleRow": false,
|
|
77
|
+
"verticalSorted": false,
|
|
78
|
+
"showSpecialClassesLast": false,
|
|
79
|
+
"dynamicDescription": true,
|
|
80
|
+
"type": "category",
|
|
81
|
+
"numberOfItems": 5,
|
|
82
|
+
"position": "side",
|
|
83
|
+
"title": "",
|
|
84
|
+
"style": "circles",
|
|
85
|
+
"subStyle": "linear blocks",
|
|
86
|
+
"tickRotation": "",
|
|
87
|
+
"singleColumnLegend": false,
|
|
88
|
+
"hideBorder": false,
|
|
89
|
+
"categoryValuesOrder": [
|
|
90
|
+
"20.6 - 23.3",
|
|
91
|
+
"23.4 - 28.3",
|
|
92
|
+
"18.5 - 20.5",
|
|
93
|
+
"10.2 - 15.5",
|
|
94
|
+
"15.6 - 18.4"
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
"filters": [
|
|
98
|
+
{
|
|
99
|
+
"order": "asc",
|
|
100
|
+
"label": "Select a Measure",
|
|
101
|
+
"columnName": "Year",
|
|
102
|
+
"values": [
|
|
103
|
+
"Percentages of preterm infants conceived through ART",
|
|
104
|
+
"Proportion of infants conceived through ART that were born preterm among all preterm births "
|
|
105
|
+
],
|
|
106
|
+
"active": "Percentages of preterm infants conceived through ART",
|
|
107
|
+
"filterStyle": "dropdown"
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"table": {
|
|
111
|
+
"wrapColumns": false,
|
|
112
|
+
"label": "Data Table",
|
|
113
|
+
"expanded": false,
|
|
114
|
+
"limitHeight": false,
|
|
115
|
+
"height": "",
|
|
116
|
+
"caption": "",
|
|
117
|
+
"showDownloadUrl": false,
|
|
118
|
+
"showDataTableLink": false,
|
|
119
|
+
"showFullGeoNameInCSV": false,
|
|
120
|
+
"forceDisplay": true,
|
|
121
|
+
"download": true,
|
|
122
|
+
"indexLabel": ""
|
|
123
|
+
},
|
|
124
|
+
"tooltips": {
|
|
125
|
+
"appearanceType": "hover",
|
|
126
|
+
"linkLabel": "Learn More",
|
|
127
|
+
"capitalizeLabels": true,
|
|
128
|
+
"opacity": 90
|
|
129
|
+
},
|
|
130
|
+
"visual": {
|
|
131
|
+
"minBubbleSize": 1,
|
|
132
|
+
"maxBubbleSize": 20,
|
|
133
|
+
"extraBubbleBorder": false,
|
|
134
|
+
"cityStyle": "circle",
|
|
135
|
+
"cityStyleLabel": "",
|
|
136
|
+
"showBubbleZeros": false,
|
|
137
|
+
"additionalCityStyles": [],
|
|
138
|
+
"geoCodeCircleSize": 8
|
|
139
|
+
},
|
|
140
|
+
"mapPosition": {
|
|
141
|
+
"coordinates": [
|
|
142
|
+
0,
|
|
143
|
+
30
|
|
144
|
+
],
|
|
145
|
+
"zoom": 1
|
|
146
|
+
},
|
|
147
|
+
"map": {
|
|
148
|
+
"layers": [],
|
|
149
|
+
"patterns": []
|
|
150
|
+
},
|
|
151
|
+
"hexMap": {
|
|
152
|
+
"type": "",
|
|
153
|
+
"shapeGroups": [
|
|
154
|
+
{
|
|
155
|
+
"legendTitle": "",
|
|
156
|
+
"legendDescription": "",
|
|
157
|
+
"items": [
|
|
158
|
+
{
|
|
159
|
+
"key": "",
|
|
160
|
+
"shape": "Arrow Up",
|
|
161
|
+
"column": "",
|
|
162
|
+
"operator": "=",
|
|
163
|
+
"value": ""
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
},
|
|
169
|
+
"filterBehavior": "Filter Change",
|
|
170
|
+
"openModal": true,
|
|
171
|
+
"uid": "map1728585388205",
|
|
172
|
+
"dataDescription": {
|
|
173
|
+
"horizontal": false,
|
|
174
|
+
"series": false
|
|
175
|
+
},
|
|
176
|
+
"dataKey": "table - 6 dashboard.csv",
|
|
177
|
+
"version": "4.24.9",
|
|
178
|
+
"editor": {
|
|
179
|
+
"activeFilterValueForDescription": [
|
|
180
|
+
0,
|
|
181
|
+
0
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdc/map",
|
|
3
|
-
"version": "4.24.
|
|
3
|
+
"version": "4.24.11",
|
|
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.24.
|
|
28
|
+
"@cdc/core": "^4.24.11",
|
|
29
29
|
"@emotion/core": "^10.0.28",
|
|
30
30
|
"@emotion/react": "^11.1.5",
|
|
31
31
|
"@hello-pangea/dnd": "^16.2.0",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"react": "^18.2.0",
|
|
53
53
|
"react-dom": "^18.2.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "9ab5ee9b2b0ef7321a66a2104be6ce8899ec3808"
|
|
56
56
|
}
|
package/src/CdcMap.tsx
CHANGED
|
@@ -30,7 +30,6 @@ import { publish } from '@cdc/core/helpers/events'
|
|
|
30
30
|
import coveUpdateWorker from '@cdc/core/helpers/coveUpdateWorker'
|
|
31
31
|
import { getQueryStringFilterValue } from '@cdc/core/helpers/queryStringUtils'
|
|
32
32
|
import Title from '@cdc/core/components/ui/Title'
|
|
33
|
-
import { getTextWidth } from '@cdc/core/helpers/getTextWidth'
|
|
34
33
|
|
|
35
34
|
// Data
|
|
36
35
|
import { countryCoordinates } from './data/country-coordinates'
|
|
@@ -137,7 +136,8 @@ const CdcMap = ({
|
|
|
137
136
|
const legendRef = useRef(null)
|
|
138
137
|
const tooltipRef = useRef(null)
|
|
139
138
|
const legendId = useId()
|
|
140
|
-
|
|
139
|
+
// create random tooltipId
|
|
140
|
+
const tooltipId = `${Math.random().toString(16).slice(-4)}`
|
|
141
141
|
const mapId = useId()
|
|
142
142
|
|
|
143
143
|
const { changeFilterActive, handleSorting } = useFilters({ config: state, setConfig: setState })
|
|
@@ -345,7 +345,6 @@ const CdcMap = ({
|
|
|
345
345
|
const newLegendMemo = new Map() // Reset memoization
|
|
346
346
|
const newLegendSpecialClassLastMemo = new Map() // Reset bin memoization
|
|
347
347
|
let primaryCol = obj.columns.primary.name,
|
|
348
|
-
isSingleState = obj.general.geoType === 'single-state',
|
|
349
348
|
isBubble = obj.general.type === 'bubble',
|
|
350
349
|
categoricalCol = obj.columns.categorical ? obj.columns.categorical.name : undefined,
|
|
351
350
|
type = obj.legend.type,
|
|
@@ -573,7 +572,9 @@ const CdcMap = ({
|
|
|
573
572
|
newLegendMemo.forEach(assignSpecialClassLastIndex)
|
|
574
573
|
legendSpecialClassLastMemo.current = newLegendSpecialClassLastMemo
|
|
575
574
|
|
|
576
|
-
|
|
575
|
+
// filter special classes from results
|
|
576
|
+
const specialValues = result.filter(d => d.special).map(d => d.value)
|
|
577
|
+
return result.filter(d => d.special || !specialValues.includes(d.value))
|
|
577
578
|
}
|
|
578
579
|
|
|
579
580
|
let uniqueValues = {}
|
|
@@ -1462,6 +1463,11 @@ const CdcMap = ({
|
|
|
1462
1463
|
if (newData) {
|
|
1463
1464
|
newState.data = newData
|
|
1464
1465
|
}
|
|
1466
|
+
} else if (newState.formattedData) {
|
|
1467
|
+
newState.data = newState.formattedData
|
|
1468
|
+
} else if (newState.dataDescription) {
|
|
1469
|
+
newState.data = transform.autoStandardize(newState.data)
|
|
1470
|
+
newState.data = transform.developerStandardize(newState.data, newState.dataDescription)
|
|
1465
1471
|
}
|
|
1466
1472
|
|
|
1467
1473
|
// This code goes through and adds the defaults for every property declaring in the initial state at the top.
|
|
@@ -1493,8 +1499,10 @@ const CdcMap = ({
|
|
|
1493
1499
|
// add ability to rename state properties over time.
|
|
1494
1500
|
const processedConfig = { ...coveUpdateWorker(newState) }
|
|
1495
1501
|
|
|
1496
|
-
|
|
1497
|
-
|
|
1502
|
+
setTimeout(() => {
|
|
1503
|
+
setState(processedConfig)
|
|
1504
|
+
setLoading(false)
|
|
1505
|
+
}, 10)
|
|
1498
1506
|
}
|
|
1499
1507
|
|
|
1500
1508
|
const init = async () => {
|
|
@@ -1722,7 +1730,6 @@ const CdcMap = ({
|
|
|
1722
1730
|
tooltipRef,
|
|
1723
1731
|
topoData,
|
|
1724
1732
|
setTopoData,
|
|
1725
|
-
getTextWidth,
|
|
1726
1733
|
mapId
|
|
1727
1734
|
}
|
|
1728
1735
|
|
|
@@ -1827,7 +1834,7 @@ const CdcMap = ({
|
|
|
1827
1834
|
closeModal(e)
|
|
1828
1835
|
}
|
|
1829
1836
|
}}
|
|
1830
|
-
style={{ padding: '15px
|
|
1837
|
+
style={{ padding: '15px 0px', margin: '0px' }}
|
|
1831
1838
|
>
|
|
1832
1839
|
{/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */}
|
|
1833
1840
|
<section className='outline-none geography-container w-100' ref={mapSvg} tabIndex='0'>
|
|
@@ -1839,13 +1846,21 @@ const CdcMap = ({
|
|
|
1839
1846
|
{'us-region' === geoType && <UsaMap.Region />}
|
|
1840
1847
|
{'us-county' === geoType && <UsaMap.County />}
|
|
1841
1848
|
{'world' === geoType && <WorldMap />}
|
|
1842
|
-
{'data' === general.type && logo &&
|
|
1849
|
+
{'data' === general.type && logo && (
|
|
1850
|
+
<img src={logo} alt='' className='map-logo' style={{ maxWidth: '50px' }} />
|
|
1851
|
+
)}
|
|
1843
1852
|
</>
|
|
1844
1853
|
)}
|
|
1845
1854
|
</section>
|
|
1846
1855
|
|
|
1847
1856
|
{general.showSidebar && 'navigation' !== general.type && (
|
|
1848
|
-
<Legend
|
|
1857
|
+
<Legend
|
|
1858
|
+
dimensions={dimensions}
|
|
1859
|
+
ref={legendRef}
|
|
1860
|
+
skipId={tabId}
|
|
1861
|
+
containerWidthPadding={0}
|
|
1862
|
+
currentViewport={currentViewport}
|
|
1863
|
+
/>
|
|
1849
1864
|
)}
|
|
1850
1865
|
</div>
|
|
1851
1866
|
|
|
@@ -1923,8 +1938,6 @@ const CdcMap = ({
|
|
|
1923
1938
|
|
|
1924
1939
|
{state.annotations.length > 0 && <Annotation.Dropdown />}
|
|
1925
1940
|
|
|
1926
|
-
{state.annotations.length > 0 && <Annotation.Dropdown />}
|
|
1927
|
-
|
|
1928
1941
|
{general.footnotes && <section className='footnotes'>{parse(general.footnotes)}</section>}
|
|
1929
1942
|
</section>
|
|
1930
1943
|
)}
|
|
@@ -30,7 +30,8 @@ export const Equal_Number_Map: Story = {
|
|
|
30
30
|
|
|
31
31
|
export const Scale_Based: Story = {
|
|
32
32
|
args: {
|
|
33
|
-
configUrl:
|
|
33
|
+
configUrl:
|
|
34
|
+
'https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/examples/Scale-Based-Categorical-Map-With-Special-Classes.json'
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
export const Qualitative: Story = {
|
|
@@ -86,11 +87,6 @@ export const Custom_Map_Layers: Story = {
|
|
|
86
87
|
configUrl: 'https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/examples/custom-layer-map.json'
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
|
-
export const Geocode: Story = {
|
|
90
|
-
args: {
|
|
91
|
-
configUrl: 'https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/examples/example-u-s-geo-code-dat.json'
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
90
|
|
|
95
91
|
export const Single_State_With_Filters: Story = {
|
|
96
92
|
args: {
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
|
+
import CdcMap from '../CdcMap'
|
|
3
|
+
import SingleStateWithFilters from './_mock/DEV-8942.json'
|
|
4
|
+
import UsGradient from './_mock/usa-state-gradient.json'
|
|
5
|
+
import WastewaterMap from './_mock/wastewater-map.json'
|
|
6
|
+
import { editConfigKeys } from '@cdc/chart/src/helpers/configHelpers'
|
|
7
|
+
|
|
8
|
+
const meta: Meta<typeof CdcMap> = {
|
|
9
|
+
title: 'Components/Templates/Map/Legend',
|
|
10
|
+
component: CdcMap
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type Story = StoryObj<typeof CdcMap>
|
|
14
|
+
|
|
15
|
+
export default meta
|
|
16
|
+
|
|
17
|
+
export const Single_State_With_Filters: Story = {
|
|
18
|
+
args: {
|
|
19
|
+
config: editConfigKeys(SingleStateWithFilters, [
|
|
20
|
+
{ path: ['legend', 'style'], value: 'gradient' },
|
|
21
|
+
{ path: ['legend', 'position'], value: 'top' },
|
|
22
|
+
{ path: ['legend', 'hideBorder'], value: true },
|
|
23
|
+
{ path: ['legend', 'title'], value: '' },
|
|
24
|
+
{ path: ['legend', 'description'], value: '' }
|
|
25
|
+
])
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const Gradient: Story = {
|
|
30
|
+
args: {
|
|
31
|
+
config: UsGradient
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const Gradient_Smooth: Story = {
|
|
36
|
+
args: {
|
|
37
|
+
config: editConfigKeys(UsGradient, [{ path: ['legend', 'subStyle'], value: 'smooth' }])
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export const Gradient_With_Box: Story = {
|
|
41
|
+
args: {
|
|
42
|
+
config: editConfigKeys(UsGradient, [
|
|
43
|
+
{ path: ['legend', 'subStyle'], value: 'linear blocks' },
|
|
44
|
+
{ path: ['legend', 'hideBorder'], value: false }
|
|
45
|
+
])
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const Gradient_With_Text: Story = {
|
|
50
|
+
args: {
|
|
51
|
+
config: editConfigKeys(UsGradient, [
|
|
52
|
+
{ path: ['legend', 'title'], value: 'Title' },
|
|
53
|
+
{ path: ['legend', 'description'], value: 'Description' },
|
|
54
|
+
{ path: ['legend', 'hideBorder'], value: true }
|
|
55
|
+
])
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const Legend_Right: Story = {
|
|
60
|
+
args: {
|
|
61
|
+
config: editConfigKeys(SingleStateWithFilters, [{ path: ['legend', 'hideBorder'], value: true }])
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const Gradient_With_Patterns: Story = {
|
|
66
|
+
args: {
|
|
67
|
+
config: WastewaterMap
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export const Gradient_Reversed: Story = {
|
|
71
|
+
args: {
|
|
72
|
+
config: editConfigKeys(WastewaterMap, [
|
|
73
|
+
{
|
|
74
|
+
path: ['customColors'],
|
|
75
|
+
value: undefined
|
|
76
|
+
},
|
|
77
|
+
{ path: ['legend', 'specialClasses'], value: ['No Data'] },
|
|
78
|
+
{ path: ['legend', 'showSpecialClassesLast'], value: false },
|
|
79
|
+
{
|
|
80
|
+
path: ['legend', 'categoryValuesOrder'],
|
|
81
|
+
value: ['No Data', 'Minimal', 'Low', 'Moderate', 'High', 'Very High']
|
|
82
|
+
},
|
|
83
|
+
{ path: ['color'], value: 'greenblue' }
|
|
84
|
+
])
|
|
85
|
+
}
|
|
86
|
+
}
|