@cdc/map 4.25.11 → 4.26.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/dist/cdcmap.js +29879 -29091
- package/examples/private/city_styles_variable.json +877 -0
- package/examples/private/map-filter-issue.json +2260 -0
- package/examples/private/map-legend.json +5303 -0
- package/index.html +27 -37
- package/package.json +5 -4
- package/src/CdcMapComponent.tsx +42 -6
- package/src/_stories/CdcMap.Editor.stories.tsx +92 -37
- package/src/_stories/CdcMap.stories.tsx +94 -0
- package/src/_stories/_mock/usa-state-gradient.json +1 -0
- package/src/components/CityList.tsx +24 -18
- package/src/components/EditorPanel/components/EditorPanel.tsx +2320 -2212
- package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +0 -19
- package/src/components/EditorPanel/components/Panels/Panel.SmallMultiples.tsx +14 -17
- package/src/components/Legend/components/Legend.tsx +24 -41
- package/src/components/Legend/components/LegendGroup/Legend.Group.tsx +1 -1
- package/src/components/Legend/components/index.scss +22 -5
- package/src/components/UsaMap/components/Territory/Territory.Rectangle.tsx +6 -5
- package/src/components/UsaMap/components/Territory/TerritoryShape.ts +1 -0
- package/src/components/UsaMap/components/UsaMap.County.tsx +2 -2
- package/src/components/UsaMap/components/UsaMap.SingleState.tsx +4 -7
- package/src/components/UsaMap/components/UsaMap.State.tsx +4 -2
- package/src/data/initial-state.js +1 -0
- package/src/helpers/applyLegendToRow.ts +5 -3
- package/src/helpers/constants.ts +2 -0
- package/src/helpers/displayGeoName.ts +8 -5
- package/src/helpers/generateRuntimeFilters.ts +1 -1
- package/src/helpers/generateRuntimeLegend.ts +1 -1
- package/src/helpers/generateRuntimeLegendHash.ts +1 -1
- package/src/helpers/index.ts +9 -3
- package/src/helpers/isLegendItemDisabled.ts +2 -2
- package/src/helpers/resetLegendToggles.ts +1 -0
- package/src/helpers/tests/hashObj.test.ts +1 -1
- package/src/helpers/toggleLegendActive.ts +76 -8
- package/src/hooks/useResizeObserver.ts +3 -0
- package/src/hooks/useStateZoom.tsx +2 -2
- package/src/test/CdcMap.test.jsx +1 -1
- package/src/types/MapConfig.ts +2 -0
- package/src/types/runtimeLegend.ts +1 -0
- package/LICENSE +0 -201
- package/src/components/MapControls.tsx +0 -44
- package/src/helpers/getUniqueValues.ts +0 -19
- package/src/helpers/hashObj.ts +0 -25
- package/src/hooks/useLegendSeparators.ts +0 -26
|
@@ -4,8 +4,7 @@ import { GlyphCircle, GlyphDiamond, GlyphSquare, GlyphStar, GlyphTriangle } from
|
|
|
4
4
|
import ConfigContext from '../context'
|
|
5
5
|
import { useLegendMemoContext } from '../context/LegendMemoContext'
|
|
6
6
|
import { supportedCities } from '../data/supported-geos'
|
|
7
|
-
import {
|
|
8
|
-
import { displayGeoName, getGeoStrokeColor, SVG_HEIGHT, SVG_PADDING, SVG_WIDTH, isLegendItemDisabled } from '../helpers'
|
|
7
|
+
import { displayGeoName, getGeoStrokeColor, isLegendItemDisabled } from '../helpers'
|
|
9
8
|
import useGeoClickHandler from '../hooks/useGeoClickHandler'
|
|
10
9
|
import useApplyTooltipsToGeo from '../hooks/useApplyTooltipsToGeo'
|
|
11
10
|
import { applyLegendToRow } from '../helpers/applyLegendToRow'
|
|
@@ -19,7 +18,7 @@ type CityListProps = {
|
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
const CityList: React.FC<CityListProps> = ({ setSharedFilterValue, isFilterValueSupported, tooltipId, projection }) => {
|
|
22
|
-
const { config,
|
|
21
|
+
const { config, runtimeData, position, runtimeLegend } = useContext(ConfigContext)
|
|
23
22
|
const { legendMemo, legendSpecialClassLastMemo } = useLegendMemoContext()
|
|
24
23
|
const { geoClickHandler } = useGeoClickHandler()
|
|
25
24
|
const { applyTooltipsToGeo } = useApplyTooltipsToGeo()
|
|
@@ -146,20 +145,12 @@ const CityList: React.FC<CityListProps> = ({ setSharedFilterValue, isFilterValue
|
|
|
146
145
|
}
|
|
147
146
|
|
|
148
147
|
if (geoData?.[longitudeColumnName] && geoData?.[latitudeColumnName] && config.general.geoType === 'single-state') {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
[SVG_WIDTH - SVG_PADDING, SVG_HEIGHT - SVG_PADDING]
|
|
156
|
-
],
|
|
157
|
-
_statesPickedData
|
|
158
|
-
)
|
|
159
|
-
let coords = [Number(geoData?.[longitudeColumnName]), Number(geoData?.[latitudeColumnName])]
|
|
160
|
-
transform = `translate(${newProjection(coords)}) scale(${
|
|
161
|
-
config.visual.geoCodeCircleSize / ((position as any).zoom > 1 ? (position as any).zoom : 1)
|
|
162
|
-
})`
|
|
148
|
+
// For single-state maps, the projection passed in is already fitted from CustomProjection
|
|
149
|
+
// We just need to project the coordinates and apply zoom adjustment
|
|
150
|
+
const coords = [Number(geoData?.[longitudeColumnName]), Number(geoData?.[latitudeColumnName])]
|
|
151
|
+
const projectedCoords = projection(coords)
|
|
152
|
+
const zoomScale = (position as any).zoom > 1 ? 1 / (position as any).zoom : 1
|
|
153
|
+
transform = `translate(${projectedCoords}) scale(${zoomScale})`
|
|
163
154
|
needsPointer = true
|
|
164
155
|
}
|
|
165
156
|
|
|
@@ -216,10 +207,25 @@ const CityList: React.FC<CityListProps> = ({ setSharedFilterValue, isFilterValue
|
|
|
216
207
|
triangle: <GlyphTriangle {...shapeProps} />
|
|
217
208
|
}
|
|
218
209
|
|
|
210
|
+
// Check if this city matches any additionalCityStyles
|
|
211
|
+
let shapeToUse = config.visual.cityStyle?.toLowerCase() || 'circle'
|
|
212
|
+
if (config.visual.additionalCityStyles && config.visual.additionalCityStyles.length > 0) {
|
|
213
|
+
for (const style of config.visual.additionalCityStyles) {
|
|
214
|
+
if (style.column && style.value && style.shape) {
|
|
215
|
+
const columnValue = geoData[style.column]
|
|
216
|
+
// Convert both to strings for comparison to handle different data types
|
|
217
|
+
if (String(columnValue) === String(style.value)) {
|
|
218
|
+
shapeToUse = style.shape.toLowerCase()
|
|
219
|
+
break
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
219
225
|
// Render the city marker
|
|
220
226
|
return (
|
|
221
227
|
<g key={i} transform={transform} style={styles} className='geo-point' tabIndex={-1}>
|
|
222
|
-
{cityStyleShapes[
|
|
228
|
+
{cityStyleShapes[shapeToUse]}
|
|
223
229
|
</g>
|
|
224
230
|
)
|
|
225
231
|
})
|