@cdc/map 4.24.7 → 4.24.9

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.
Files changed (46) hide show
  1. package/dist/cdcmap.js +40720 -38422
  2. package/examples/county-year.csv +10 -0
  3. package/examples/default-geocode.json +44 -10
  4. package/examples/default-patterns.json +0 -2
  5. package/examples/default-single-state.json +279 -108
  6. package/examples/map-issue-3.json +646 -0
  7. package/examples/single-state-filter.json +153 -0
  8. package/index.html +9 -6
  9. package/package.json +3 -3
  10. package/src/CdcMap.tsx +322 -126
  11. package/src/_stories/CdcMap.stories.tsx +7 -0
  12. package/src/_stories/_mock/DEV-8942.json +270 -0
  13. package/src/components/Annotation/AnnotationDropdown.tsx +1 -0
  14. package/src/components/{BubbleList.jsx → BubbleList.tsx} +1 -1
  15. package/src/components/{CityList.jsx → CityList.tsx} +28 -2
  16. package/src/components/{DataTable.jsx → DataTable.tsx} +2 -2
  17. package/src/components/EditorPanel/components/EditorPanel.tsx +647 -127
  18. package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +0 -22
  19. package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +61 -11
  20. package/src/components/Legend/components/Legend.tsx +125 -36
  21. package/src/components/Legend/components/index.scss +42 -42
  22. package/src/components/Modal.tsx +25 -0
  23. package/src/components/UsaMap/components/SingleState/SingleState.CountyOutput.tsx +74 -0
  24. package/src/components/UsaMap/components/SingleState/SingleState.StateOutput.tsx +29 -0
  25. package/src/components/UsaMap/components/SingleState/index.tsx +9 -0
  26. package/src/components/UsaMap/components/UsaMap.County.tsx +84 -33
  27. package/src/components/UsaMap/components/UsaMap.SingleState.tsx +173 -206
  28. package/src/components/UsaMap/components/UsaMap.State.tsx +161 -26
  29. package/src/components/UsaMap/data/us-extended-geography.json +1 -0
  30. package/src/components/UsaMap/helpers/map.ts +111 -0
  31. package/src/components/WorldMap/WorldMap.tsx +17 -32
  32. package/src/components/ZoomControls.tsx +41 -0
  33. package/src/data/initial-state.js +7 -1
  34. package/src/data/supported-geos.js +15 -4
  35. package/src/helpers/generateRuntimeLegendHash.ts +2 -2
  36. package/src/hooks/useStateZoom.tsx +157 -0
  37. package/src/hooks/{useZoomPan.js → useZoomPan.ts} +6 -5
  38. package/src/scss/editor-panel.scss +0 -4
  39. package/src/scss/main.scss +23 -1
  40. package/src/scss/map.scss +8 -0
  41. package/src/types/MapConfig.ts +9 -1
  42. package/src/types/MapContext.ts +14 -2
  43. package/src/components/Modal.jsx +0 -22
  44. /package/src/components/{Geo.jsx → Geo.tsx} +0 -0
  45. /package/src/components/{NavigationMenu.jsx → NavigationMenu.tsx} +0 -0
  46. /package/src/components/{ZoomableGroup.jsx → ZoomableGroup.tsx} +0 -0
@@ -1,6 +1,7 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react'
2
2
  import CdcMap from '../CdcMap'
3
3
  import EqualNumberOptInExample from './_mock/DEV-7286.json'
4
+ import SingleStateWithFilters from './_mock/DEV-8942.json'
4
5
 
5
6
  const meta: Meta<typeof CdcMap> = {
6
7
  title: 'Components/Templates/Map',
@@ -91,4 +92,10 @@ export const Geocode: Story = {
91
92
  }
92
93
  }
93
94
 
95
+ export const Single_State_With_Filters: Story = {
96
+ args: {
97
+ config: SingleStateWithFilters
98
+ }
99
+ }
100
+
94
101
  export default meta
@@ -0,0 +1,270 @@
1
+ {
2
+ "annotations": [],
3
+ "general": {
4
+ "title": "Default County Map",
5
+ "subtext": "",
6
+ "territoriesLabel": "Territories",
7
+ "type": "map",
8
+ "geoType": "single-state",
9
+ "headerColor": "theme-blue",
10
+ "showSidebar": true,
11
+ "showTitle": true,
12
+ "geoBorderColor": "darkGray",
13
+ "showDownloadButton": true,
14
+ "expandDataTable": false,
15
+ "statePicked": {
16
+ "fipsCode": "06",
17
+ "stateName": "California"
18
+ },
19
+ "annotationDropdownText": "Annotations",
20
+ "showDownloadMediaButton": false,
21
+ "displayAsHex": false,
22
+ "displayStateLabels": false,
23
+ "territoriesAlwaysShow": false,
24
+ "language": "en",
25
+ "geoLabelOverride": "Location",
26
+ "hasRegions": false,
27
+ "fullBorder": false,
28
+ "convertFipsCodes": true,
29
+ "palette": {
30
+ "isReversed": false
31
+ },
32
+ "allowMapZoom": true,
33
+ "hideGeoColumnInTooltip": false,
34
+ "hidePrimaryColumnInTooltip": false
35
+ },
36
+ "type": "map",
37
+ "color": "pinkpurple",
38
+ "columns": {
39
+ "geo": {
40
+ "name": "FIPS Codes",
41
+ "label": "Location",
42
+ "tooltip": false,
43
+ "dataTable": true
44
+ },
45
+ "primary": {
46
+ "name": "Insured Rate",
47
+ "label": "Data Label",
48
+ "prefix": "",
49
+ "suffix": "%",
50
+ "dataTable": true,
51
+ "tooltip": true,
52
+ "roundToPlace": 0
53
+ },
54
+ "navigate": {
55
+ "name": "link",
56
+ "tooltip": false,
57
+ "dataTable": false
58
+ },
59
+ "latitude": {
60
+ "name": "Latitude"
61
+ },
62
+ "longitude": {
63
+ "name": "Longitude"
64
+ },
65
+ "additionalColumn1": {
66
+ "label": "New Column",
67
+ "dataTable": true,
68
+ "tooltips": false,
69
+ "prefix": "",
70
+ "suffix": "",
71
+ "name": "State"
72
+ },
73
+ "additionalColumn2": {
74
+ "label": "New Column",
75
+ "dataTable": true,
76
+ "tooltips": false,
77
+ "prefix": "",
78
+ "suffix": "",
79
+ "name": "Latitude"
80
+ },
81
+ "additionalColumn3": {
82
+ "label": "New Column",
83
+ "dataTable": true,
84
+ "tooltips": false,
85
+ "prefix": "",
86
+ "suffix": "",
87
+ "name": "Longitude"
88
+ }
89
+ },
90
+ "legend": {
91
+ "numberOfItems": 3,
92
+ "position": "side",
93
+ "title": "Legend Title",
94
+ "description": "Legend Text",
95
+ "type": "equalnumber",
96
+ "specialClasses": [
97
+ {
98
+ "key": "Insured Rate",
99
+ "value": "N/A",
100
+ "label": "N/A"
101
+ }
102
+ ],
103
+ "descriptions": {},
104
+ "unified": false,
105
+ "singleColumn": false,
106
+ "singleRow": false,
107
+ "verticalSorted": false,
108
+ "showSpecialClassesLast": false,
109
+ "dynamicDescription": false
110
+ },
111
+ "filters": [
112
+ {
113
+ "order": "asc",
114
+ "label": "",
115
+ "columnName": "State",
116
+ "values": [
117
+ "California",
118
+ "Florida"
119
+ ],
120
+ "active": "California",
121
+ "filterStyle": "dropdown"
122
+ }
123
+ ],
124
+ "table": {
125
+ "wrapColumns": false,
126
+ "label": "Data Table",
127
+ "expanded": false,
128
+ "limitHeight": false,
129
+ "height": "",
130
+ "caption": "",
131
+ "showDownloadUrl": false,
132
+ "showDataTableLink": true,
133
+ "showFullGeoNameInCSV": false,
134
+ "forceDisplay": true,
135
+ "download": true,
136
+ "indexLabel": ""
137
+ },
138
+ "tooltips": {
139
+ "appearanceType": "hover",
140
+ "linkLabel": "Learn More",
141
+ "capitalizeLabels": true,
142
+ "opacity": 90
143
+ },
144
+ "runtime": {
145
+ "editorErrorMessage": []
146
+ },
147
+ "visual": {
148
+ "minBubbleSize": 1,
149
+ "maxBubbleSize": 20,
150
+ "extraBubbleBorder": false,
151
+ "cityStyle": "circle",
152
+ "cityStyleLabel": "",
153
+ "showBubbleZeros": false,
154
+ "additionalCityStyles": [],
155
+ "geoCodeCircleSize": "7"
156
+ },
157
+ "mapPosition": {
158
+ "coordinates": [
159
+ 0,
160
+ 0
161
+ ],
162
+ "zoom": 1
163
+ },
164
+ "map": {
165
+ "layers": [],
166
+ "patterns": []
167
+ },
168
+ "hexMap": {
169
+ "type": "",
170
+ "shapeGroups": [
171
+ {
172
+ "legendTitle": "",
173
+ "legendDescription": "",
174
+ "items": [
175
+ {
176
+ "key": "",
177
+ "shape": "Arrow Up",
178
+ "column": "",
179
+ "operator": "=",
180
+ "value": ""
181
+ }
182
+ ]
183
+ }
184
+ ]
185
+ },
186
+ "filterBehavior": "Filter Change",
187
+ "data": [
188
+ {
189
+ "Insured Rate": 8,
190
+ "Coverage Status": "Insured",
191
+ "FIPS Codes": "06071",
192
+ "Year (Good filter option)": "2010",
193
+ "link": "",
194
+ "Latitude": "",
195
+ "Longitude": "",
196
+ "State": "California"
197
+ },
198
+ {
199
+ "Insured Rate": 25,
200
+ "Coverage Status": "Insured",
201
+ "FIPS Codes": "55005",
202
+ "Year (Good filter option)": "2010",
203
+ "link": "",
204
+ "Latitude": "",
205
+ "Longitude": "",
206
+ "State": "California"
207
+ },
208
+ {
209
+ "Insured Rate": 25,
210
+ "Coverage Status": "Insured",
211
+ "FIPS Codes": "12103",
212
+ "Year (Good filter option)": "2010",
213
+ "link": "",
214
+ "Latitude": "",
215
+ "Longitude": "",
216
+ "State": "Florida"
217
+ },
218
+ {
219
+ "Insured Rate": 25,
220
+ "Coverage Status": "Insured",
221
+ "FIPS Codes": "32005",
222
+ "Year (Good filter option)": "2010",
223
+ "link": "",
224
+ "Latitude": "",
225
+ "State": "California",
226
+ "Longitude": ""
227
+ },
228
+ {
229
+ "Insured Rate": 18,
230
+ "Coverage Status": "Insured",
231
+ "FIPS Codes": "06075",
232
+ "Year (Good filter option)": "2010",
233
+ "link": "",
234
+ "Latitude": "",
235
+ "Longitude": "",
236
+ "State": "California"
237
+ },
238
+ {
239
+ "Insured Rate": 3,
240
+ "Coverage Status": "Insured",
241
+ "FIPS Codes": "06027",
242
+ "Year (Good filter option)": "2010",
243
+ "link": "",
244
+ "Latitude": "",
245
+ "Longitude": "",
246
+ "State": "California"
247
+ },
248
+ {
249
+ "Insured Rate": 25,
250
+ "Coverage Status": "Insured",
251
+ "FIPS Codes": "06029",
252
+ "Year (Good filter option)": "2010",
253
+ "link": "",
254
+ "Latitude": "",
255
+ "Longitude": "",
256
+ "State": "California"
257
+ },
258
+ {
259
+ "Insured Rate": 60,
260
+ "Coverage Status": "Insured",
261
+ "FIPS Codes": "Yosemite is great!",
262
+ "Year (Good filter option)": "2010",
263
+ "link": "",
264
+ "Latitude": "37.865101",
265
+ "Longitude": "-119.538330",
266
+ "State": "California"
267
+ }
268
+ ],
269
+ "version": "4.24.9"
270
+ }
@@ -32,6 +32,7 @@ const AnnotationDropdown = () => {
32
32
 
33
33
  if (config.general.showAnnotationDropdown) {
34
34
  classes.push('d-lg-block')
35
+ classes.splice(classes.indexOf('d-lg-none'), 1)
35
36
  }
36
37
  return classes.join(' ')
37
38
  }
@@ -2,7 +2,7 @@ import React, { useContext, useEffect } from 'react'
2
2
  import { scaleLinear } from 'd3-scale'
3
3
  import { countryCoordinates } from '../data/country-coordinates'
4
4
  import stateCoordinates from '../data/state-coordinates'
5
- import ConfigContext from './../../src/context'
5
+ import ConfigContext from '../context'
6
6
 
7
7
  export const BubbleList = ({ data: dataImport, state, projection, applyLegendToRow, applyTooltipsToGeo, handleCircleClick, runtimeData, displayGeoName }) => {
8
8
  const maxDataValue = Math.max(...dataImport.map(d => d[state.columns.primary.name]))
@@ -1,12 +1,17 @@
1
- import { useState, useEffect } from 'react'
1
+ import { useState, useEffect, useContext } from 'react'
2
2
 
3
3
  import { jsx } from '@emotion/react'
4
4
  import { supportedCities } from '../data/supported-geos'
5
5
  import { scaleLinear } from 'd3-scale'
6
6
  import { GlyphStar, GlyphTriangle, GlyphDiamond, GlyphSquare, GlyphCircle } from '@visx/glyph'
7
+ import { getFilterControllingStatePicked } from './UsaMap/helpers/map'
7
8
 
8
- const CityList = ({ data, state, geoClickHandler, applyTooltipsToGeo, displayGeoName, applyLegendToRow, projection, titleCase, setSharedFilterValue, isFilterValueSupported, tooltipId }) => {
9
+ import ConfigContext from '../context'
10
+
11
+ const CityList = ({ data, geoClickHandler, applyTooltipsToGeo, displayGeoName, applyLegendToRow, titleCase, setSharedFilterValue, isFilterValueSupported, tooltipId, projection }) => {
9
12
  const [citiesData, setCitiesData] = useState({})
13
+ const { scale, state, topoData, runtimeData, position } = useContext(ConfigContext)
14
+ if (!projection) return
10
15
 
11
16
  useEffect(() => {
12
17
  const citiesDictionary = {}
@@ -91,6 +96,27 @@ const CityList = ({ data, state, geoClickHandler, applyTooltipsToGeo, displayGeo
91
96
  needsPointer = true
92
97
  }
93
98
 
99
+ if (geoData?.[state.columns.longitude.name] && geoData?.[state.columns.latitude.name] && state.general.geoType === 'single-state') {
100
+ const statePicked = getFilterControllingStatePicked(state, runtimeData)
101
+ const _statePickedData = topoData?.states?.find(s => s.properties.name === statePicked)
102
+ // SVG ITEMS
103
+ const WIDTH = 880
104
+ const HEIGHT = 500
105
+ const PADDING = 50
106
+
107
+ const newProjection = projection.fitExtent(
108
+ [
109
+ [PADDING, PADDING],
110
+ [WIDTH - PADDING, HEIGHT - PADDING]
111
+ ],
112
+ _statePickedData
113
+ )
114
+ let coords = [Number(geoData?.[state.columns.longitude.name]), Number(geoData?.[state.columns.latitude.name])]
115
+ console.log('COORDINATES', coords)
116
+ transform = `translate(${newProjection(coords)}) scale(${state.visual.geoCodeCircleSize / (position.zoom > 1 ? position.zoom : 1)})`
117
+ needsPointer = true
118
+ }
119
+
94
120
  if (!transform) {
95
121
  return
96
122
  }
@@ -5,7 +5,7 @@ import ExternalIcon from '../images/external-link.svg' // TODO: Move to Icon com
5
5
  import Icon from '@cdc/core/components/ui/Icon'
6
6
 
7
7
  import ErrorBoundary from '@cdc/core/components/ErrorBoundary'
8
- import LegendCircle from '@cdc/core/components/LegendCircle'
8
+ import LegendShape from '@cdc/core/components/LegendShape'
9
9
  import MediaControls from '@cdc/core/components/MediaControls'
10
10
  import SkipTo from '@cdc/core/components/elements/SkipTo'
11
11
 
@@ -274,7 +274,7 @@ const DataTable = props => {
274
274
 
275
275
  cellValue = (
276
276
  <>
277
- <LegendCircle fill={legendColor[0]} />
277
+ <LegendShape fill={legendColor[0]} />
278
278
  {labelValue}
279
279
  </>
280
280
  )