@cdc/map 4.24.11 → 4.24.12-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.
- package/dist/cdcmap.js +34008 -33475
- package/examples/default-geocode.json +13 -4
- package/examples/default-usa-regions.json +267 -117
- package/examples/example-city-state.json +6 -3
- package/examples/pattern.json +861 -0
- package/examples/private/DEV-9989.json +229 -0
- package/examples/private/ardi.json +180 -0
- package/examples/private/colors 2.json +416 -0
- package/examples/private/colors.json +416 -0
- package/examples/private/colors.json.zip +0 -0
- package/examples/private/customColors.json +45348 -0
- package/examples/private/default-patterns.json +867 -0
- package/examples/private/test.json +1632 -0
- package/index.html +4 -5
- package/package.json +3 -3
- package/src/CdcMap.tsx +82 -79
- package/src/_stories/{CdcMapLegend.stories.tsx → CdcMap.Legend.Gradient.stories.tsx} +1 -20
- package/src/_stories/CdcMap.Legend.stories.tsx +40 -0
- package/src/_stories/CdcMap.Patterns.stories.tsx +29 -0
- package/src/_stories/CdcMap.stories.tsx +59 -0
- package/src/_stories/UsaMap.NoData.stories.tsx +19 -0
- package/src/_stories/_mock/custom-layer-map.json +1117 -0
- package/src/_stories/_mock/default-patterns.json +865 -0
- package/src/_stories/_mock/example-city-state.json +858 -0
- package/src/components/CityList.tsx +5 -2
- package/src/components/EditorPanel/components/EditorPanel.tsx +39 -256
- package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +1 -1
- package/src/components/Legend/components/Legend.tsx +22 -6
- package/src/components/Legend/components/index.scss +16 -23
- package/src/components/UsaMap/components/SingleState/SingleState.CountyOutput.tsx +40 -6
- package/src/components/UsaMap/components/SingleState/SingleState.StateOutput.tsx +10 -2
- package/src/components/UsaMap/components/Territory/Territory.Hexagon.tsx +1 -1
- package/src/components/UsaMap/components/Territory/Territory.Rectangle.tsx +14 -13
- package/src/components/UsaMap/components/UsaMap.County.tsx +11 -13
- package/src/components/UsaMap/components/UsaMap.Region.tsx +59 -16
- package/src/components/UsaMap/components/UsaMap.SingleState.tsx +2 -1
- package/src/components/UsaMap/components/UsaMap.State.tsx +58 -60
- package/src/components/WorldMap/WorldMap.tsx +77 -16
- package/src/data/initial-state.js +2 -1
- package/src/helpers/applyColorToLegend.ts +80 -0
- package/src/helpers/colors.ts +23 -0
- package/src/hooks/useTooltip.ts +9 -6
- package/src/scss/filters.scss +0 -3
- package/src/scss/main.scss +0 -1
- package/src/scss/map.scss +11 -59
- package/src/types/MapConfig.ts +7 -1
- package/src/types/MapContext.ts +1 -0
- package/examples/default-patterns.json +0 -579
- package/src/scss/datatable.scss +0 -6
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useContext } from 'react'
|
|
2
2
|
import ConfigContext from '../../../../context'
|
|
3
3
|
import { MapContext } from '../../../../types/MapContext'
|
|
4
|
+
import { getGeoFillColor } from '../../../../helpers/colors'
|
|
4
5
|
|
|
5
6
|
interface CountyOutputProps {
|
|
6
7
|
counties: any[]
|
|
@@ -11,7 +12,10 @@ interface CountyOutputProps {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
const CountyOutput: React.FC<CountyOutputProps> = ({ path, counties, scale, geoStrokeColor, tooltipId }) => {
|
|
14
|
-
const { applyTooltipsToGeo, applyLegendToRow, displayGeoName, state, data, geoClickHandler } =
|
|
15
|
+
const { applyTooltipsToGeo, applyLegendToRow, displayGeoName, state, data, geoClickHandler } =
|
|
16
|
+
useContext<MapContext>(ConfigContext)
|
|
17
|
+
|
|
18
|
+
const geoFillColor = getGeoFillColor(state)
|
|
15
19
|
return (
|
|
16
20
|
<>
|
|
17
21
|
{counties.map(county => {
|
|
@@ -50,19 +54,49 @@ const CountyOutput: React.FC<CountyOutputProps> = ({ path, counties, scale, geoS
|
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
// When to add pointer cursor
|
|
53
|
-
if (
|
|
57
|
+
if (
|
|
58
|
+
(state.columns.navigate && geoData[state.columns.navigate.name]) ||
|
|
59
|
+
state.tooltips.appearanceType === 'hover'
|
|
60
|
+
) {
|
|
54
61
|
styles.cursor = 'pointer'
|
|
55
62
|
}
|
|
56
63
|
|
|
57
64
|
return (
|
|
58
|
-
<g
|
|
59
|
-
|
|
65
|
+
<g
|
|
66
|
+
key={`key--${county.id}`}
|
|
67
|
+
className={`county county--${geoDisplayName.split(' ').join('')} county--${
|
|
68
|
+
geoData[state.columns.geo.name]
|
|
69
|
+
}`}
|
|
70
|
+
style={styles}
|
|
71
|
+
onClick={() => geoClickHandler(geoDisplayName, geoData)}
|
|
72
|
+
data-tooltip-id={`tooltip__${tooltipId}`}
|
|
73
|
+
data-tooltip-html={toolTip}
|
|
74
|
+
>
|
|
75
|
+
<path
|
|
76
|
+
tabIndex={-1}
|
|
77
|
+
className={`county`}
|
|
78
|
+
stroke={geoStrokeColor}
|
|
79
|
+
d={countyPath}
|
|
80
|
+
strokeWidth={0.75 / scale}
|
|
81
|
+
/>
|
|
60
82
|
</g>
|
|
61
83
|
)
|
|
62
84
|
} else {
|
|
63
85
|
return (
|
|
64
|
-
<g
|
|
65
|
-
|
|
86
|
+
<g
|
|
87
|
+
key={`key--${county.id}`}
|
|
88
|
+
className={`county county--${geoDisplayName.split(' ').join('')}`}
|
|
89
|
+
style={{ fill: geoFillColor }}
|
|
90
|
+
data-tooltip-id={`tooltip__${tooltipId}`}
|
|
91
|
+
data-tooltip-html={toolTip}
|
|
92
|
+
>
|
|
93
|
+
<path
|
|
94
|
+
tabIndex={-1}
|
|
95
|
+
className={`county`}
|
|
96
|
+
stroke={geoStrokeColor}
|
|
97
|
+
d={countyPath}
|
|
98
|
+
strokeWidth={0.75 / scale}
|
|
99
|
+
/>
|
|
66
100
|
</g>
|
|
67
101
|
)
|
|
68
102
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useContext } from 'react'
|
|
2
2
|
import { mesh, Topology } from 'topojson-client'
|
|
3
3
|
import ConfigContext from '../../../../context'
|
|
4
|
+
import { getGeoFillColor, getGeoStrokeColor } from '../../../../helpers/colors'
|
|
4
5
|
|
|
5
6
|
type StateOutputProps = {
|
|
6
7
|
topoData: Topology
|
|
@@ -15,12 +16,19 @@ const StateOutput: React.FC<StateOutputProps> = ({ topoData, path, scale, stateT
|
|
|
15
16
|
return s.properties.name === state.general.statePicked.stateName
|
|
16
17
|
})
|
|
17
18
|
|
|
18
|
-
const geoStrokeColor = state
|
|
19
|
+
const geoStrokeColor = getGeoStrokeColor(state)
|
|
20
|
+
const geoFillColor = getGeoFillColor(state)
|
|
19
21
|
|
|
20
22
|
let stateLines = path(mesh(topoData, geo[0]))
|
|
21
23
|
|
|
22
24
|
return (
|
|
23
|
-
<g
|
|
25
|
+
<g
|
|
26
|
+
key={'single-state'}
|
|
27
|
+
className='single-state'
|
|
28
|
+
style={{ fill: geoFillColor }}
|
|
29
|
+
stroke={geoStrokeColor}
|
|
30
|
+
strokeWidth={0.95 / scale}
|
|
31
|
+
>
|
|
24
32
|
<path tabIndex={-1} className='state-path' d={stateLines} />
|
|
25
33
|
</g>
|
|
26
34
|
)
|
|
@@ -176,7 +176,7 @@ const TerritoryHexagon = ({
|
|
|
176
176
|
|
|
177
177
|
return (
|
|
178
178
|
territoryData && (
|
|
179
|
-
<svg viewBox='
|
|
179
|
+
<svg viewBox='-1 -1 46 53' className='territory-wrapper--hex'>
|
|
180
180
|
<g {...props} data-tooltip-html={dataTooltipHtml} data-tooltip-id={dataTooltipId} onClick={handleShapeClick}>
|
|
181
181
|
<polygon
|
|
182
182
|
stroke={stroke}
|
|
@@ -2,7 +2,7 @@ import { useContext } from 'react'
|
|
|
2
2
|
import { PatternLines, PatternCircles, PatternWaves } from '@visx/pattern'
|
|
3
3
|
import ConfigContext from './../../../../context'
|
|
4
4
|
import { type MapContext } from '../../../../types/MapContext'
|
|
5
|
-
import { patternSizes } from '
|
|
5
|
+
import { patternSizes } from '../../helpers/patternSizes'
|
|
6
6
|
import { getContrastColor } from '@cdc/core/helpers/cove/accessibility'
|
|
7
7
|
import { type TerritoryShape } from './TerritoryShape'
|
|
8
8
|
|
|
@@ -17,15 +17,16 @@ const TerritoryRectangle: React.FC<TerritoryShape> = ({
|
|
|
17
17
|
territory,
|
|
18
18
|
text,
|
|
19
19
|
textColor,
|
|
20
|
+
backgroundColor,
|
|
20
21
|
...props
|
|
21
22
|
}) => {
|
|
22
|
-
const { state
|
|
23
|
+
const { state } = useContext<MapContext>(ConfigContext)
|
|
23
24
|
const { territoryData, ...otherProps } = props
|
|
24
25
|
const rectanglePath =
|
|
25
|
-
'
|
|
26
|
+
'M42,0.5 C42.8284271,0.5 43.5,1.17157288 43.5,2 L43.5,2 L43.5,26 C43.5,26.8284271 42.8284271,27.5 42,27.5 L42,27.5 L3,27.5 C2.17157288,27.5 1.5,26.8284271 1.5,26 L1.5,26 L1.5,2 C1.5,1.17157288 2.17157288,0.5 3,0.5 L3,0.5 Z'
|
|
26
27
|
|
|
27
28
|
return (
|
|
28
|
-
<svg viewBox='0 0 45
|
|
29
|
+
<svg viewBox='0 0 45 29' key={territory} className={territory}>
|
|
29
30
|
<g
|
|
30
31
|
{...otherProps}
|
|
31
32
|
strokeLinejoin='round'
|
|
@@ -41,7 +42,7 @@ const TerritoryRectangle: React.FC<TerritoryShape> = ({
|
|
|
41
42
|
x='50%'
|
|
42
43
|
y='54%'
|
|
43
44
|
fill={text}
|
|
44
|
-
style={{ stroke:
|
|
45
|
+
style={{ stroke: 'none' }}
|
|
45
46
|
className='territory-text'
|
|
46
47
|
paintOrder='stroke'
|
|
47
48
|
onClick={handleShapeClick}
|
|
@@ -52,8 +53,8 @@ const TerritoryRectangle: React.FC<TerritoryShape> = ({
|
|
|
52
53
|
</text>
|
|
53
54
|
|
|
54
55
|
{state.map.patterns.map((patternData, patternIndex) => {
|
|
55
|
-
const patternColor = getContrastColor('#FFF',
|
|
56
|
-
const hasMatchingValues =
|
|
56
|
+
const patternColor = patternData.color || getContrastColor('#FFF', backgroundColor)
|
|
57
|
+
const hasMatchingValues = patternData.dataValue === territoryData?.[patternData.dataKey]
|
|
57
58
|
|
|
58
59
|
if (!hasMatchingValues) return null
|
|
59
60
|
if (!patternData.pattern) return null
|
|
@@ -62,7 +63,7 @@ const TerritoryRectangle: React.FC<TerritoryShape> = ({
|
|
|
62
63
|
<>
|
|
63
64
|
{patternData?.pattern === 'waves' && (
|
|
64
65
|
<PatternWaves
|
|
65
|
-
id={`territory-${patternData?.dataKey}--${patternIndex}`}
|
|
66
|
+
id={`territory-${territory}-${patternData?.dataKey}--${patternIndex}`}
|
|
66
67
|
height={patternSizes[patternData?.size] ?? 10}
|
|
67
68
|
width={patternSizes[patternData?.size] ?? 10}
|
|
68
69
|
fill={patternColor}
|
|
@@ -71,7 +72,7 @@ const TerritoryRectangle: React.FC<TerritoryShape> = ({
|
|
|
71
72
|
)}
|
|
72
73
|
{patternData?.pattern === 'circles' && (
|
|
73
74
|
<PatternCircles
|
|
74
|
-
id={`territory-${patternData?.dataKey}--${patternIndex}`}
|
|
75
|
+
id={`territory-${territory}-${patternData?.dataKey}--${patternIndex}`}
|
|
75
76
|
height={patternSizes[patternData?.size] ?? 10}
|
|
76
77
|
width={patternSizes[patternData?.size] ?? 10}
|
|
77
78
|
fill={patternColor}
|
|
@@ -80,7 +81,7 @@ const TerritoryRectangle: React.FC<TerritoryShape> = ({
|
|
|
80
81
|
)}
|
|
81
82
|
{patternData?.pattern === 'lines' && (
|
|
82
83
|
<PatternLines
|
|
83
|
-
id={`territory-${patternData?.dataKey}--${patternIndex}`}
|
|
84
|
+
id={`territory-${territory}-${patternData?.dataKey}--${patternIndex}`}
|
|
84
85
|
height={patternSizes[patternData?.size] ?? 6}
|
|
85
86
|
width={patternSizes[patternData?.size] ?? 6}
|
|
86
87
|
stroke={patternColor}
|
|
@@ -92,11 +93,11 @@ const TerritoryRectangle: React.FC<TerritoryShape> = ({
|
|
|
92
93
|
stroke={stroke}
|
|
93
94
|
strokeWidth={strokeWidth}
|
|
94
95
|
d={rectanglePath}
|
|
95
|
-
fill={`url(#territory-${patternData?.dataKey}--${patternIndex})`}
|
|
96
|
+
fill={`url(#territory-${territory}-${patternData?.dataKey}--${patternIndex})`}
|
|
96
97
|
color={patternData ? 'white' : textColor}
|
|
97
98
|
className={[
|
|
98
|
-
`territory-pattern-${patternData
|
|
99
|
-
`territory-pattern-${patternData
|
|
99
|
+
`territory-pattern-${patternData?.dataKey}`,
|
|
100
|
+
`territory-pattern-${patternData?.dataKey}--${patternData.dataValue}`
|
|
100
101
|
].join(' ')}
|
|
101
102
|
/>
|
|
102
103
|
<text
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
drawShape,
|
|
22
22
|
createShapeProperties
|
|
23
23
|
} from '../helpers/shapes'
|
|
24
|
+
import { getGeoStrokeColor } from '../../../helpers/colors'
|
|
24
25
|
|
|
25
26
|
const getCountyTopoURL = year => {
|
|
26
27
|
return `https://www.cdc.gov/TemplatePackage/contrib/data/county-topography/cb_${year}_us_county_20m.json`
|
|
@@ -131,22 +132,23 @@ const CountyMap = props => {
|
|
|
131
132
|
const {
|
|
132
133
|
applyLegendToRow,
|
|
133
134
|
applyTooltipsToGeo,
|
|
135
|
+
container,
|
|
134
136
|
containerEl,
|
|
135
137
|
data,
|
|
136
138
|
displayGeoName,
|
|
137
139
|
geoClickHandler,
|
|
138
140
|
handleMapAriaLabels,
|
|
141
|
+
runtimeFilters,
|
|
139
142
|
runtimeLegend,
|
|
143
|
+
setState,
|
|
140
144
|
state,
|
|
141
|
-
runtimeFilters,
|
|
142
145
|
tooltipId,
|
|
143
146
|
tooltipRef,
|
|
144
|
-
container,
|
|
145
|
-
setState
|
|
146
147
|
} = useContext(ConfigContext)
|
|
147
148
|
|
|
148
149
|
// CREATE STATE LINES
|
|
149
150
|
const projection = geoAlbersUsaTerritories()
|
|
151
|
+
const geoStrokeColor = getGeoStrokeColor(state)
|
|
150
152
|
|
|
151
153
|
const [focus, setFocus] = useState({})
|
|
152
154
|
const [topoData, setTopoData] = useState({})
|
|
@@ -210,9 +212,7 @@ const CountyMap = props => {
|
|
|
210
212
|
}
|
|
211
213
|
|
|
212
214
|
const runtimeKeys = Object.keys(data)
|
|
213
|
-
|
|
214
|
-
const geoStrokeColor = state.general.geoBorderColor === 'darkGray' ? 'rgb(90, 90, 90)' : 'rgb(255, 255, 255)'
|
|
215
|
-
const lineWidth = 0.3
|
|
215
|
+
const lineWidth = 1
|
|
216
216
|
|
|
217
217
|
const onReset = () => {
|
|
218
218
|
setState({
|
|
@@ -449,7 +449,7 @@ const CountyMap = props => {
|
|
|
449
449
|
}
|
|
450
450
|
|
|
451
451
|
if (focus.index !== -1) {
|
|
452
|
-
context.strokeStyle =
|
|
452
|
+
context.strokeStyle = geoStrokeColor
|
|
453
453
|
context.lineWidth = 1
|
|
454
454
|
context.beginPath()
|
|
455
455
|
path(topoData.mapData[focus.index])
|
|
@@ -493,7 +493,6 @@ const CountyMap = props => {
|
|
|
493
493
|
|
|
494
494
|
// Enforces stroke style of the county lines
|
|
495
495
|
context.strokeStyle = geoStrokeColor
|
|
496
|
-
context.lineWidth = lineWidth
|
|
497
496
|
|
|
498
497
|
// Iterates through each state/county topo and renders it
|
|
499
498
|
topoData.mapData.forEach((geo, i) => {
|
|
@@ -518,7 +517,7 @@ const CountyMap = props => {
|
|
|
518
517
|
|
|
519
518
|
// If the focused state is found in the geo data, render it with a thicker outline
|
|
520
519
|
if (focus.index !== -1) {
|
|
521
|
-
context.strokeStyle =
|
|
520
|
+
context.strokeStyle = geoStrokeColor
|
|
522
521
|
context.lineWidth = 2
|
|
523
522
|
context.beginPath()
|
|
524
523
|
path(topoData.mapData[focus.index])
|
|
@@ -531,8 +530,7 @@ const CountyMap = props => {
|
|
|
531
530
|
context.beginPath()
|
|
532
531
|
path(layer)
|
|
533
532
|
context.fillStyle = layer.properties.fill
|
|
534
|
-
context.
|
|
535
|
-
context.strokeStyle = layer.properties['stroke']
|
|
533
|
+
context.strokeStyle = geoStrokeColor
|
|
536
534
|
context.lineWidth = layer.properties['stroke-width']
|
|
537
535
|
context.fill()
|
|
538
536
|
context.stroke()
|
|
@@ -540,7 +538,7 @@ const CountyMap = props => {
|
|
|
540
538
|
}
|
|
541
539
|
|
|
542
540
|
if (state.general.type === 'us-geocode') {
|
|
543
|
-
context.strokeStyle =
|
|
541
|
+
context.strokeStyle = geoStrokeColor
|
|
544
542
|
const geoRadius = (state.visual.geoCodeCircleSize || 5) * (focus.id ? 2 : 1)
|
|
545
543
|
const { additionalCityStyles } = state.visual || []
|
|
546
544
|
const cityStyles = Object.values(data)
|
|
@@ -604,7 +602,7 @@ const CountyMap = props => {
|
|
|
604
602
|
className='county-map-canvas'
|
|
605
603
|
></canvas>
|
|
606
604
|
|
|
607
|
-
<button className={`btn btn-primary
|
|
605
|
+
<button className={`btn btn--reset btn-primary`} onClick={onReset} ref={resetButton} tabIndex='0'>
|
|
608
606
|
Reset Zoom
|
|
609
607
|
</button>
|
|
610
608
|
</ErrorBoundary>
|
|
@@ -11,6 +11,7 @@ import ErrorBoundary from '@cdc/core/components/ErrorBoundary'
|
|
|
11
11
|
import topoJSON from '../data/us-regions-topo-2.json'
|
|
12
12
|
import ConfigContext from '../../../context'
|
|
13
13
|
import Annotation from '../../Annotation'
|
|
14
|
+
import { getGeoFillColor, getGeoStrokeColor } from '../../../helpers/colors'
|
|
14
15
|
|
|
15
16
|
const { features: unitedStates } = feature(topoJSON, topoJSON.objects.regions)
|
|
16
17
|
|
|
@@ -69,7 +70,8 @@ const UsaRegionMap = props => {
|
|
|
69
70
|
setTerritoriesData(territoriesList)
|
|
70
71
|
}, [data])
|
|
71
72
|
|
|
72
|
-
const geoStrokeColor = state
|
|
73
|
+
const geoStrokeColor = getGeoStrokeColor(state)
|
|
74
|
+
const geoFillColor = getGeoFillColor(state)
|
|
73
75
|
|
|
74
76
|
const territories = territoriesData.map(territory => {
|
|
75
77
|
const Shape = Rect
|
|
@@ -79,7 +81,7 @@ const UsaRegionMap = props => {
|
|
|
79
81
|
let toolTip
|
|
80
82
|
|
|
81
83
|
let styles: React.CSSProperties = {
|
|
82
|
-
fill:
|
|
84
|
+
fill: geoFillColor,
|
|
83
85
|
color: '#202020'
|
|
84
86
|
}
|
|
85
87
|
|
|
@@ -97,7 +99,10 @@ const UsaRegionMap = props => {
|
|
|
97
99
|
let needsPointer = false
|
|
98
100
|
|
|
99
101
|
// If we need to add a pointer cursor
|
|
100
|
-
if (
|
|
102
|
+
if (
|
|
103
|
+
(state.columns.navigate && territoryData[state.columns.navigate.name]) ||
|
|
104
|
+
state.tooltips.appearanceType === 'click'
|
|
105
|
+
) {
|
|
101
106
|
needsPointer = true
|
|
102
107
|
}
|
|
103
108
|
|
|
@@ -113,7 +118,19 @@ const UsaRegionMap = props => {
|
|
|
113
118
|
}
|
|
114
119
|
}
|
|
115
120
|
|
|
116
|
-
return
|
|
121
|
+
return (
|
|
122
|
+
<Shape
|
|
123
|
+
key={label}
|
|
124
|
+
label={label}
|
|
125
|
+
css={styles}
|
|
126
|
+
text={styles.color}
|
|
127
|
+
stroke={geoStrokeColor}
|
|
128
|
+
strokeWidth={1}
|
|
129
|
+
onClick={() => geoClickHandler(territory, territoryData)}
|
|
130
|
+
data-tooltip-id={`tooltip__${tooltipId}`}
|
|
131
|
+
data-tooltip-html={toolTip}
|
|
132
|
+
/>
|
|
133
|
+
)
|
|
117
134
|
}
|
|
118
135
|
})
|
|
119
136
|
|
|
@@ -130,8 +147,22 @@ const UsaRegionMap = props => {
|
|
|
130
147
|
|
|
131
148
|
return (
|
|
132
149
|
<g>
|
|
133
|
-
<line
|
|
134
|
-
|
|
150
|
+
<line
|
|
151
|
+
x1={centroid[0]}
|
|
152
|
+
y1={centroid[1]}
|
|
153
|
+
x2={centroid[0] + dx}
|
|
154
|
+
y2={centroid[1] + dy}
|
|
155
|
+
stroke='rgba(0,0,0,.5)'
|
|
156
|
+
strokeWidth={1}
|
|
157
|
+
/>
|
|
158
|
+
<text
|
|
159
|
+
x={4}
|
|
160
|
+
strokeWidth='0'
|
|
161
|
+
fontSize={13}
|
|
162
|
+
style={{ fill: '#202020' }}
|
|
163
|
+
alignmentBaseline='middle'
|
|
164
|
+
transform={`translate(${centroid[0] + dx}, ${centroid[1] + dy})`}
|
|
165
|
+
>
|
|
135
166
|
{abbr.substring(3)}
|
|
136
167
|
</text>
|
|
137
168
|
</g>
|
|
@@ -146,7 +177,7 @@ const UsaRegionMap = props => {
|
|
|
146
177
|
const key = isHex ? geo.properties.iso + '-hex-group' : geo.properties.iso + '-group'
|
|
147
178
|
|
|
148
179
|
let styles = {
|
|
149
|
-
fill:
|
|
180
|
+
fill: geoFillColor,
|
|
150
181
|
cursor: 'default'
|
|
151
182
|
}
|
|
152
183
|
|
|
@@ -172,28 +203,32 @@ const UsaRegionMap = props => {
|
|
|
172
203
|
const toolTip = applyTooltipsToGeo(geoDisplayName, geoData)
|
|
173
204
|
|
|
174
205
|
styles = {
|
|
175
|
-
fill: state.general.type !== 'bubble' ? legendColors[0] :
|
|
206
|
+
fill: state.general.type !== 'bubble' ? legendColors[0] : geoFillColor,
|
|
176
207
|
cursor: 'default',
|
|
177
208
|
'&:hover': {
|
|
178
|
-
fill: state.general.type !== 'bubble' ? legendColors[1] :
|
|
209
|
+
fill: state.general.type !== 'bubble' ? legendColors[1] : geoFillColor
|
|
179
210
|
},
|
|
180
211
|
'&:active': {
|
|
181
|
-
fill: state.general.type !== 'bubble' ? legendColors[2] :
|
|
212
|
+
fill: state.general.type !== 'bubble' ? legendColors[2] : geoFillColor
|
|
182
213
|
}
|
|
183
214
|
}
|
|
184
215
|
|
|
185
216
|
// When to add pointer cursor
|
|
186
|
-
if (
|
|
217
|
+
if (
|
|
218
|
+
(state.columns.navigate && geoData[state.columns.navigate.name]) ||
|
|
219
|
+
state.tooltips.appearanceType === 'click'
|
|
220
|
+
) {
|
|
187
221
|
styles.cursor = 'pointer'
|
|
188
222
|
}
|
|
189
223
|
|
|
190
224
|
const TerratoryRect = props => {
|
|
191
225
|
const { posX = 0, tName } = props
|
|
192
226
|
const textColor = getContrastColor('#FFF', legendColors[0])
|
|
227
|
+
const geoStrokeColor = getGeoStrokeColor(state)
|
|
193
228
|
return (
|
|
194
229
|
<>
|
|
195
|
-
<rect x={posX} width='36' height='24' rx='
|
|
196
|
-
<text x={
|
|
230
|
+
<rect x={posX} width='36' height='24' rx='2' stroke={geoStrokeColor} strokeWidth='1' />
|
|
231
|
+
<text textAnchor='middle' x={36 / 2 + posX} y='17' fill={textColor}>
|
|
197
232
|
{tName}
|
|
198
233
|
</text>
|
|
199
234
|
</>
|
|
@@ -203,8 +238,16 @@ const UsaRegionMap = props => {
|
|
|
203
238
|
const circleRadius = 15
|
|
204
239
|
|
|
205
240
|
return (
|
|
206
|
-
<g
|
|
207
|
-
|
|
241
|
+
<g
|
|
242
|
+
key={key}
|
|
243
|
+
className='geo-group'
|
|
244
|
+
style={styles}
|
|
245
|
+
onClick={() => geoClickHandler(geoDisplayName, geoData)}
|
|
246
|
+
data-tooltip-id={`tooltip__${tooltipId}`}
|
|
247
|
+
data-tooltip-html={toolTip}
|
|
248
|
+
tabIndex={-1}
|
|
249
|
+
>
|
|
250
|
+
<path tabIndex={-1} className='single-geo' stroke={geoStrokeColor} strokeWidth={1} d={path} />
|
|
208
251
|
<g id={`region-${index + 1}-label`}>
|
|
209
252
|
<circle fill='#fff' stroke='#999' cx={circleRadius} cy={circleRadius} r={circleRadius} />
|
|
210
253
|
<text fill='#333' x='15px' y='20px' textAnchor='middle'>
|
|
@@ -239,7 +282,7 @@ const UsaRegionMap = props => {
|
|
|
239
282
|
// Default return state, just geo with no additional information
|
|
240
283
|
return (
|
|
241
284
|
<g key={key} className='geo-group' style={styles}>
|
|
242
|
-
<path tabIndex={-1} className='single-geo' stroke={geoStrokeColor} strokeWidth={1
|
|
285
|
+
<path tabIndex={-1} className='single-geo' stroke={geoStrokeColor} strokeWidth={1} d={path} />
|
|
243
286
|
{(isHex || showLabel) && geoLabel(geo, styles.fill, projection)}
|
|
244
287
|
</g>
|
|
245
288
|
)
|
|
@@ -14,6 +14,7 @@ import ZoomControls from '../../ZoomControls'
|
|
|
14
14
|
import { MapContext } from '../../../types/MapContext'
|
|
15
15
|
import useStateZoom from '../../../hooks/useStateZoom'
|
|
16
16
|
import { Text } from '@visx/text'
|
|
17
|
+
import { getGeoStrokeColor } from '../../../helpers/colors'
|
|
17
18
|
|
|
18
19
|
// SVG ITEMS
|
|
19
20
|
const WIDTH = 880
|
|
@@ -49,7 +50,7 @@ const SingleStateMap = props => {
|
|
|
49
50
|
const cityListProjection = geoAlbersUsaTerritories()
|
|
50
51
|
.translate([WIDTH / 2, HEIGHT / 2])
|
|
51
52
|
.scale(1)
|
|
52
|
-
const geoStrokeColor = state
|
|
53
|
+
const geoStrokeColor = getGeoStrokeColor(state)
|
|
53
54
|
const path = geoPath().projection(projection)
|
|
54
55
|
|
|
55
56
|
useEffect(() => {
|