@cdc/map 4.24.2 → 4.24.3
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 +27001 -26354
- package/examples/508.json +548 -0
- package/examples/default-county.json +0 -28
- package/examples/default-hex.json +110 -13
- package/examples/default-usa.json +69 -28
- package/examples/usa-special-class-legend.json +501 -0
- package/index.html +4 -3
- package/package.json +3 -3
- package/src/CdcMap.tsx +60 -21
- package/src/components/BubbleList.jsx +9 -1
- package/src/components/CityList.jsx +60 -8
- package/src/components/DataTable.jsx +7 -7
- package/src/components/EditorPanel/components/EditorPanel.tsx +180 -44
- package/src/components/EditorPanel/components/HexShapeSettings.tsx +16 -1
- package/src/components/Legend/components/Legend.tsx +67 -13
- package/src/components/Legend/components/index.scss +31 -5
- package/src/components/UsaMap/components/HexIcon.tsx +41 -0
- package/src/components/UsaMap/components/Territory/Territory.Hexagon.tsx +38 -19
- package/src/components/UsaMap/components/Territory/Territory.Rectangle.tsx +10 -21
- package/src/components/UsaMap/components/UsaMap.Region.tsx +11 -37
- package/src/components/UsaMap/components/UsaMap.State.tsx +61 -59
- package/src/components/UsaMap/helpers/patternSizes.tsx +5 -0
- package/src/components/WorldMap/components/WorldMap.jsx +3 -1
- package/src/data/initial-state.js +3 -0
- package/src/data/supported-geos.js +1 -1
- package/src/scss/editor-panel.scss +3 -0
- package/src/scss/main.scss +2 -1
- package/src/types/MapConfig.ts +7 -0
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
import { useContext } from 'react'
|
|
2
2
|
import { PatternLines, PatternCircles, PatternWaves } from '@visx/pattern'
|
|
3
|
-
import chroma from 'chroma-js'
|
|
4
3
|
import ConfigContext from './../../../../context'
|
|
5
4
|
import { type MapContext } from '../../../../types/MapContext'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
small: '8',
|
|
9
|
-
medium: '10',
|
|
10
|
-
large: '12'
|
|
11
|
-
}
|
|
5
|
+
import { patternSizes } from './../../helpers/patternSizes'
|
|
6
|
+
import { getContrastColor } from '@cdc/core/helpers/cove/accessibility'
|
|
12
7
|
|
|
13
8
|
const TerritoryRectangle = ({ label, text, stroke, strokeWidth, textColor, hasPattern, territory, ...props }) => {
|
|
14
9
|
const { state, supportedTerritories } = useContext<MapContext>(ConfigContext)
|
|
15
10
|
|
|
16
11
|
return (
|
|
17
12
|
<svg viewBox='0 0 45 28'>
|
|
18
|
-
<g {...props} strokeLinejoin='round'>
|
|
13
|
+
<g {...props} strokeLinejoin='round' tabIndex={-1}>
|
|
19
14
|
<path
|
|
20
15
|
stroke={stroke}
|
|
21
16
|
strokeWidth={strokeWidth}
|
|
@@ -27,32 +22,26 @@ const TerritoryRectangle = ({ label, text, stroke, strokeWidth, textColor, hasPa
|
|
|
27
22
|
</text>
|
|
28
23
|
|
|
29
24
|
{state.map.patterns.map((patternData, patternIndex) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const hasMatchingValues = supportedTerritories[territory].includes(patternData?.dataValue)
|
|
33
|
-
console.log('has match', patternData)
|
|
34
|
-
|
|
35
|
-
if (chroma.contrast(defaultPatternColor, props.style.fill) < 3.5) {
|
|
36
|
-
defaultPatternColor = 'white'
|
|
37
|
-
}
|
|
25
|
+
const patternColor = getContrastColor('#FFF', props.style.fill)
|
|
26
|
+
const hasMatchingValues = supportedTerritories[territory]?.includes(patternData?.dataValue)
|
|
38
27
|
|
|
39
28
|
if (!hasMatchingValues) return null
|
|
40
29
|
if (!patternData.pattern) return null
|
|
41
30
|
|
|
42
31
|
return (
|
|
43
32
|
<>
|
|
44
|
-
{patternData?.pattern === 'waves' && <PatternWaves id={`territory-${patternData?.dataKey}--${patternIndex}`} height={
|
|
45
|
-
{patternData?.pattern === 'circles' && <PatternCircles id={`territory-${patternData?.dataKey}--${patternIndex}`} height={
|
|
46
|
-
{patternData?.pattern === 'lines' && <PatternLines id={`territory-${patternData?.dataKey}--${patternIndex}`} height={
|
|
33
|
+
{patternData?.pattern === 'waves' && <PatternWaves id={`territory-${patternData?.dataKey}--${patternIndex}`} height={patternSizes[patternData?.size] ?? 10} width={patternSizes[patternData?.size] ?? 10} fill={patternColor} complement />}
|
|
34
|
+
{patternData?.pattern === 'circles' && <PatternCircles id={`territory-${patternData?.dataKey}--${patternIndex}`} height={patternSizes[patternData?.size] ?? 10} width={patternSizes[patternData?.size] ?? 10} fill={patternColor} complement />}
|
|
35
|
+
{patternData?.pattern === 'lines' && <PatternLines id={`territory-${patternData?.dataKey}--${patternIndex}`} height={patternSizes[patternData?.size] ?? 6} width={patternSizes[patternData?.size] ?? 6} stroke={patternColor} strokeWidth={1} orientation={['diagonalRightToLeft']} />}
|
|
47
36
|
<path
|
|
48
37
|
stroke={stroke}
|
|
49
38
|
strokeWidth={strokeWidth}
|
|
50
39
|
d='M40,0.5 C41.2426407,0.5 42.3676407,1.00367966 43.1819805,1.81801948 C43.9963203,2.63235931 44.5,3.75735931 44.5,5 L44.5,5 L44.5,23 C44.5,24.2426407 43.9963203,25.3676407 43.1819805,26.1819805 C42.3676407,26.9963203 41.2426407,27.5 40,27.5 L40,27.5 L5,27.5 C3.75735931,27.5 2.63235931,26.9963203 1.81801948,26.1819805 C1.00367966,25.3676407 0.5,24.2426407 0.5,23 L0.5,23 L0.5,5 C0.5,3.75735931 1.00367966,2.63235931 1.81801948,1.81801948 C2.63235931,1.00367966 3.75735931,0.5 5,0.5 L5,0.5 Z'
|
|
51
40
|
fill={`url(#territory-${patternData?.dataKey}--${patternIndex})`}
|
|
52
|
-
color='white'
|
|
41
|
+
color={patternData ? 'white' : textColor}
|
|
53
42
|
className={[`territory-pattern-${patternData.dataKey}`, `territory-pattern-${patternData.dataKey}--${patternData.dataValue}`].join(' ')}
|
|
54
43
|
/>
|
|
55
|
-
<text textAnchor='middle' dominantBaseline='middle' x='50%' y='54%' fill={text} style={{ stroke: patternData ? 'black' : textColor, strokeWidth: patternData ? 6 : 0 }} className='territory-text' paint-order='stroke'>
|
|
44
|
+
<text textAnchor='middle' dominantBaseline='middle' x='50%' y='54%' fill={text} style={{ fill: patternData ? 'white' : 'black', stroke: patternData ? 'black' : textColor, strokeWidth: patternData ? 6 : 0 }} className='territory-text' paint-order='stroke'>
|
|
56
45
|
{label}
|
|
57
46
|
</text>
|
|
58
47
|
</>
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { useState, useEffect, memo, useContext } from 'react'
|
|
2
|
+
import { getContrastColor } from '@cdc/core/helpers/cove/accessibility'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
import ErrorBoundary from '@cdc/core/components/ErrorBoundary'
|
|
4
|
+
// 3rd party
|
|
5
5
|
import { geoCentroid } from 'd3-geo'
|
|
6
6
|
import { feature } from 'topojson-client'
|
|
7
|
-
import topoJSON from '../data/us-regions-topo-2.json'
|
|
8
7
|
import { Mercator } from '@visx/geo'
|
|
9
|
-
|
|
8
|
+
|
|
9
|
+
// cdc
|
|
10
|
+
import ErrorBoundary from '@cdc/core/components/ErrorBoundary'
|
|
11
|
+
import topoJSON from '../data/us-regions-topo-2.json'
|
|
10
12
|
import ConfigContext from '../../../context'
|
|
11
13
|
|
|
12
14
|
const { features: unitedStates } = feature(topoJSON, topoJSON.objects.regions)
|
|
@@ -74,7 +76,7 @@ const UsaRegionMap = props => {
|
|
|
74
76
|
|
|
75
77
|
let toolTip
|
|
76
78
|
|
|
77
|
-
let styles = {
|
|
79
|
+
let styles: React.CSSProperties = {
|
|
78
80
|
fill: '#E6E6E6',
|
|
79
81
|
color: '#202020'
|
|
80
82
|
}
|
|
@@ -87,13 +89,8 @@ const UsaRegionMap = props => {
|
|
|
87
89
|
|
|
88
90
|
const legendColors = applyLegendToRow(territoryData)
|
|
89
91
|
|
|
90
|
-
let textColor = '#FFF'
|
|
91
|
-
|
|
92
92
|
if (legendColors) {
|
|
93
|
-
|
|
94
|
-
if (chroma.contrast(textColor, legendColors[0]) < 3.5) {
|
|
95
|
-
textColor = '#202020'
|
|
96
|
-
}
|
|
93
|
+
const textColor = getContrastColor('#FFF', legendColors[0])
|
|
97
94
|
|
|
98
95
|
let needsPointer = false
|
|
99
96
|
|
|
@@ -124,12 +121,7 @@ const UsaRegionMap = props => {
|
|
|
124
121
|
|
|
125
122
|
if (undefined === abbr) return null
|
|
126
123
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
// Dynamic text color
|
|
130
|
-
if (chroma.contrast(textColor, bgColor) < 3.5) {
|
|
131
|
-
textColor = '#202020'
|
|
132
|
-
}
|
|
124
|
+
const textColor = getContrastColor('#FFF', bgColor)
|
|
133
125
|
|
|
134
126
|
let x = 0,
|
|
135
127
|
y = 5
|
|
@@ -195,11 +187,7 @@ const UsaRegionMap = props => {
|
|
|
195
187
|
|
|
196
188
|
const TerratoryRect = props => {
|
|
197
189
|
const { posX = 0, tName } = props
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (chroma.contrast(textColor, legendColors[0]) < 4.5) {
|
|
201
|
-
textColor = '#202020'
|
|
202
|
-
}
|
|
190
|
+
const textColor = getContrastColor('#FFF', legendColors[0])
|
|
203
191
|
return (
|
|
204
192
|
<>
|
|
205
193
|
<rect x={posX} width='36' height='24' rx='6' stroke='#fff' strokeWidth='1' />
|
|
@@ -212,28 +200,14 @@ const UsaRegionMap = props => {
|
|
|
212
200
|
|
|
213
201
|
const circleRadius = 15
|
|
214
202
|
|
|
215
|
-
// SIDE CHART EXPERIMENT
|
|
216
|
-
// const height = state.data[index].Change;
|
|
217
|
-
// const barHeight = Math.abs(height * 20 );
|
|
218
|
-
// const barPositive = height > 0;
|
|
219
|
-
// const barY = barPositive ? -barHeight + 15 : 15;
|
|
220
|
-
// const baseY = 14;
|
|
221
|
-
// const barFill = barPositive ? "#fff" : "#fff";
|
|
222
|
-
|
|
223
203
|
return (
|
|
224
|
-
<g key={key} className='geo-group' style={styles} onClick={() => geoClickHandler(geoDisplayName, geoData)} data-tooltip-id='tooltip' data-tooltip-html={toolTip}>
|
|
204
|
+
<g key={key} className='geo-group' style={styles} onClick={() => geoClickHandler(geoDisplayName, geoData)} data-tooltip-id='tooltip' data-tooltip-html={toolTip} tabIndex={-1}>
|
|
225
205
|
<path tabIndex={-1} className='single-geo' stroke={geoStrokeColor} strokeWidth={1.3} d={path} />
|
|
226
206
|
<g id={`region-${index + 1}-label`}>
|
|
227
207
|
<circle fill='#fff' stroke='#999' cx={circleRadius} cy={circleRadius} r={circleRadius} />
|
|
228
208
|
<text fill='#333' x='15px' y='20px' textAnchor='middle'>
|
|
229
209
|
{index + 1}
|
|
230
210
|
</text>
|
|
231
|
-
{/* SIDE CHART EXPERIMENT */}
|
|
232
|
-
{/*<g y={barY*20}>*/}
|
|
233
|
-
{/* <rect x="-20" y={barY} width="10" height={barHeight} fill={barFill} stroke="#333"/>*/}
|
|
234
|
-
{/* <rect x="-23" y={baseY} width="16" height="2" fill="#000" />*/}
|
|
235
|
-
{/*</g>*/}
|
|
236
|
-
{/* / SIDE CHART EXPERIMENT */}
|
|
237
211
|
</g>
|
|
238
212
|
{geoKey === 'region 2' && (
|
|
239
213
|
<g id='region-2-territories'>
|
|
@@ -9,21 +9,20 @@ import hexTopoJSON from '../data/us-hex-topo.json'
|
|
|
9
9
|
import { geoCentroid, geoPath } from 'd3-geo'
|
|
10
10
|
import { feature } from 'topojson-client'
|
|
11
11
|
import { AlbersUsa, Mercator } from '@visx/geo'
|
|
12
|
-
import chroma from 'chroma-js'
|
|
13
12
|
import CityList from '../../CityList'
|
|
14
13
|
import BubbleList from '../../BubbleList'
|
|
15
14
|
import { supportedCities, supportedStates } from '../../../data/supported-geos'
|
|
16
15
|
import { geoAlbersUsa } from 'd3-composite-projections'
|
|
17
|
-
import { Group } from '@visx/group'
|
|
18
|
-
import { Text } from '@visx/text'
|
|
19
16
|
import { PatternLines, PatternCircles, PatternWaves } from '@visx/pattern'
|
|
20
|
-
import
|
|
17
|
+
import HexIcon from './HexIcon'
|
|
18
|
+
import { patternSizes } from '../helpers/patternSizes'
|
|
21
19
|
|
|
22
20
|
import Territory from './Territory'
|
|
23
21
|
|
|
24
22
|
import useMapLayers from '../../../hooks/useMapLayers'
|
|
25
23
|
import ConfigContext from '../../../context'
|
|
26
24
|
import { MapContext } from '../../../types/MapContext'
|
|
25
|
+
import { getContrastColor } from '@cdc/core/helpers/cove/accessibility'
|
|
27
26
|
|
|
28
27
|
const { features: unitedStates } = feature(topoJSON, topoJSON.objects.states)
|
|
29
28
|
const { features: unitedStatesHex } = feature(hexTopoJSON, hexTopoJSON.objects.states)
|
|
@@ -132,19 +131,14 @@ const UsaMap = () => {
|
|
|
132
131
|
|
|
133
132
|
const label = supportedTerritories[territory][1]
|
|
134
133
|
|
|
135
|
-
if (!territoryData) return <Shape key={label} label={label}
|
|
134
|
+
if (!territoryData) return <Shape key={label} label={label} style={styles} text={styles.color} />
|
|
136
135
|
|
|
137
136
|
toolTip = applyTooltipsToGeo(displayGeoName(territory), territoryData)
|
|
138
137
|
|
|
139
138
|
const legendColors = applyLegendToRow(territoryData)
|
|
140
139
|
|
|
141
|
-
let textColor = '#FFF'
|
|
142
|
-
|
|
143
140
|
if (legendColors) {
|
|
144
|
-
|
|
145
|
-
if (chroma.contrast(textColor, legendColors[0]) < 3.5) {
|
|
146
|
-
textColor = '#202020'
|
|
147
|
-
}
|
|
141
|
+
const textColor = getContrastColor('#FFF', legendColors[0])
|
|
148
142
|
|
|
149
143
|
let needsPointer = false
|
|
150
144
|
|
|
@@ -169,7 +163,7 @@ const UsaMap = () => {
|
|
|
169
163
|
|
|
170
164
|
return (
|
|
171
165
|
<>
|
|
172
|
-
<Shape key={label} label={label} style={styles} text={styles.color} strokeWidth={1.5} textColor={textColor} onClick={() => geoClickHandler(territory, territoryData)} data-tooltip-id='tooltip' data-tooltip-html={toolTip} territory={territory} territoryData={territoryData} />
|
|
166
|
+
<Shape key={label} label={label} style={styles} text={styles.color} strokeWidth={1.5} textColor={textColor} onClick={() => geoClickHandler(territory, territoryData)} data-tooltip-id='tooltip' data-tooltip-html={toolTip} territory={territory} territoryData={territoryData} tabIndex={-1} />
|
|
173
167
|
</>
|
|
174
168
|
)
|
|
175
169
|
}
|
|
@@ -204,7 +198,7 @@ const UsaMap = () => {
|
|
|
204
198
|
return 0
|
|
205
199
|
})
|
|
206
200
|
|
|
207
|
-
const geosJsx = geographies.map(({ feature: geo, path = '' }) => {
|
|
201
|
+
const geosJsx = geographies.map(({ feature: geo, path = '' }, geoIndex) => {
|
|
208
202
|
const key = isHex ? geo.properties.iso + '-hex-group' : geo.properties.iso + '-group'
|
|
209
203
|
|
|
210
204
|
let styles = {
|
|
@@ -254,31 +248,51 @@ const UsaMap = () => {
|
|
|
254
248
|
}
|
|
255
249
|
|
|
256
250
|
const getArrowDirection = (geoData, geo, bgColor) => {
|
|
257
|
-
|
|
251
|
+
const centroid = projection(geoCentroid(geo))
|
|
258
252
|
|
|
259
253
|
const iconSize = 8
|
|
260
254
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
// Dynamic text color
|
|
264
|
-
if (chroma.contrast(textColor, bgColor) < 3.5) {
|
|
265
|
-
textColor = '#202020' // dark gray
|
|
266
|
-
}
|
|
255
|
+
const textColor = getContrastColor('#FFF', bgColor)
|
|
267
256
|
|
|
268
257
|
return (
|
|
269
258
|
<>
|
|
270
259
|
{state.hexMap.shapeGroups.map((group, groupIndex) => {
|
|
271
260
|
return group.items.map((item, itemIndex) => {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
<
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
261
|
+
switch (item.operator) {
|
|
262
|
+
case '=':
|
|
263
|
+
if (geoData[item.key] === item.value || Number(geoData[item.key]) === Number(item.value)) {
|
|
264
|
+
return <HexIcon item={item} index={itemIndex} centroid={centroid} iconSize={iconSize} />
|
|
265
|
+
}
|
|
266
|
+
break
|
|
267
|
+
case '≠':
|
|
268
|
+
if (geoData[item.key] !== item.value && Number(geoData[item.key]) !== Number(item.value)) {
|
|
269
|
+
return <HexIcon item={item} index={itemIndex} centroid={centroid} iconSize={iconSize} />
|
|
270
|
+
}
|
|
271
|
+
break
|
|
272
|
+
case '<':
|
|
273
|
+
if (Number(geoData[item.key]) < Number(item.value)) {
|
|
274
|
+
return <HexIcon item={item} index={itemIndex} centroid={centroid} iconSize={iconSize} />
|
|
275
|
+
}
|
|
276
|
+
break
|
|
277
|
+
case '>':
|
|
278
|
+
if (Number(geoData[item.key]) > Number(item.value)) {
|
|
279
|
+
return <HexIcon item={item} index={itemIndex} centroid={centroid} iconSize={iconSize} />
|
|
280
|
+
}
|
|
281
|
+
break
|
|
282
|
+
case '<=':
|
|
283
|
+
if (Number(geoData[item.key]) <= Number(item.value)) {
|
|
284
|
+
return <HexIcon item={item} index={itemIndex} centroid={centroid} iconSize={iconSize} />
|
|
285
|
+
}
|
|
286
|
+
break
|
|
287
|
+
case '>=':
|
|
288
|
+
if (item.operator === '>=') {
|
|
289
|
+
if (Number(geoData[item.key]) >= Number(item.value)) {
|
|
290
|
+
return <HexIcon item={item} index={itemIndex} centroid={centroid} iconSize={iconSize} />
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
break
|
|
294
|
+
default:
|
|
295
|
+
break
|
|
282
296
|
}
|
|
283
297
|
})
|
|
284
298
|
})}
|
|
@@ -286,33 +300,26 @@ const UsaMap = () => {
|
|
|
286
300
|
)
|
|
287
301
|
}
|
|
288
302
|
|
|
289
|
-
const sizes = {
|
|
290
|
-
small: '8',
|
|
291
|
-
medium: '10',
|
|
292
|
-
large: '12'
|
|
293
|
-
}
|
|
294
|
-
|
|
295
303
|
return (
|
|
296
|
-
<g data-name={geoName} key={key}>
|
|
297
|
-
<g className='geo-group' style={styles} onClick={() => geoClickHandler(geoDisplayName, geoData)} id={geoName} data-tooltip-id='tooltip' data-tooltip-html={tooltip}>
|
|
304
|
+
<g data-name={geoName} key={key} tabIndex={-1}>
|
|
305
|
+
<g className='geo-group' style={styles} onClick={() => geoClickHandler(geoDisplayName, geoData)} id={geoName} data-tooltip-id='tooltip' data-tooltip-html={tooltip} tabIndex={-1}>
|
|
306
|
+
{/* state path */}
|
|
298
307
|
<path tabIndex={-1} className='single-geo' strokeWidth={1.3} d={path} />
|
|
299
|
-
{state.map.patterns.map((patternData, patternIndex) => {
|
|
300
|
-
let { pattern, dataKey, size } = patternData
|
|
301
|
-
let defaultPatternColor = 'black'
|
|
302
308
|
|
|
309
|
+
{/* apply patterns on top of state path*/}
|
|
310
|
+
{state.map.patterns.map((patternData, patternIndex) => {
|
|
311
|
+
const { pattern, dataKey, size } = patternData
|
|
312
|
+
const currentFill = styles.fill
|
|
303
313
|
const hasMatchingValues = patternData.dataValue === geoData[patternData.dataKey]
|
|
304
|
-
|
|
305
|
-
if (chroma.contrast(defaultPatternColor, legendColors[0]) < 3.5) {
|
|
306
|
-
defaultPatternColor = 'white'
|
|
307
|
-
}
|
|
314
|
+
const patternColor = getContrastColor('#000', currentFill)
|
|
308
315
|
|
|
309
316
|
return (
|
|
310
317
|
hasMatchingValues && (
|
|
311
318
|
<>
|
|
312
|
-
{pattern === 'waves' && <PatternWaves id={`${dataKey}--${
|
|
313
|
-
{pattern === 'circles' && <PatternCircles id={`${dataKey}--${
|
|
314
|
-
{pattern === 'lines' && <PatternLines id={`${dataKey}--${
|
|
315
|
-
<path className={`pattern-geoKey--${dataKey}`} tabIndex={-1} stroke='transparent' d={path} fill={`url(#${dataKey}--${
|
|
319
|
+
{pattern === 'waves' && <PatternWaves id={`${dataKey}--${geoIndex}`} height={patternSizes[size] ?? 10} width={patternSizes[size] ?? 10} fill={patternColor} />}
|
|
320
|
+
{pattern === 'circles' && <PatternCircles id={`${dataKey}--${geoIndex}`} height={patternSizes[size] ?? 10} width={patternSizes[size] ?? 10} fill={patternColor} />}
|
|
321
|
+
{pattern === 'lines' && <PatternLines id={`${dataKey}--${geoIndex}`} height={patternSizes[size] ?? 6} width={patternSizes[size] ?? 6} stroke={patternColor} strokeWidth={1} orientation={['diagonalRightToLeft']} />}
|
|
322
|
+
<path className={`pattern-geoKey--${dataKey}`} tabIndex={-1} stroke='transparent' d={path} fill={`url(#${dataKey}--${geoIndex})`} />
|
|
316
323
|
</>
|
|
317
324
|
)
|
|
318
325
|
)
|
|
@@ -326,8 +333,8 @@ const UsaMap = () => {
|
|
|
326
333
|
|
|
327
334
|
// Default return state, just geo with no additional information
|
|
328
335
|
return (
|
|
329
|
-
<g data-name={geoName} key={key}>
|
|
330
|
-
<g className='geo-group' style={styles}>
|
|
336
|
+
<g data-name={geoName} key={key} tabIndex={-1}>
|
|
337
|
+
<g className='geo-group' style={styles} tabIndex={-1}>
|
|
331
338
|
<path tabIndex={-1} className='single-geo' stroke={geoStrokeColor} strokeWidth={1.3} d={path} />
|
|
332
339
|
{(isHex || showLabel) && geoLabel(geo, styles.fill, projection)}
|
|
333
340
|
</g>
|
|
@@ -375,12 +382,7 @@ const UsaMap = () => {
|
|
|
375
382
|
|
|
376
383
|
if (undefined === abbr) return null
|
|
377
384
|
|
|
378
|
-
let textColor = '#FFF'
|
|
379
|
-
|
|
380
|
-
// Dynamic text color
|
|
381
|
-
if (chroma.contrast(textColor, bgColor) < 3.5) {
|
|
382
|
-
textColor = '#202020' // dark gray
|
|
383
|
-
}
|
|
385
|
+
let textColor = getContrastColor('#FFF', bgColor)
|
|
384
386
|
|
|
385
387
|
// always make HI black since it is off to the side
|
|
386
388
|
if (abbr === 'US-HI' && !state.general.displayAsHex) {
|
|
@@ -398,7 +400,7 @@ const UsaMap = () => {
|
|
|
398
400
|
|
|
399
401
|
if (undefined === offsets[abbr] || isHex) {
|
|
400
402
|
return (
|
|
401
|
-
<g transform={`translate(${centroid})`}>
|
|
403
|
+
<g transform={`translate(${centroid})`} tabIndex={-1}>
|
|
402
404
|
<text x={x} y={y} fontSize={14} strokeWidth='0' style={{ fill: textColor }} textAnchor='middle'>
|
|
403
405
|
{abbr.substring(3)}
|
|
404
406
|
</text>
|
|
@@ -409,7 +411,7 @@ const UsaMap = () => {
|
|
|
409
411
|
let [dx, dy] = offsets[abbr]
|
|
410
412
|
|
|
411
413
|
return (
|
|
412
|
-
<g>
|
|
414
|
+
<g tabIndex={-1}>
|
|
413
415
|
<line x1={centroid[0]} y1={centroid[1]} x2={centroid[0] + dx} y2={centroid[1] + dy} stroke='rgba(0,0,0,.5)' strokeWidth={1} />
|
|
414
416
|
<text x={4} strokeWidth='0' fontSize={13} style={{ fill: '#202020' }} alignmentBaseline='middle' transform={`translate(${centroid[0] + dx}, ${centroid[1] + dy})`}>
|
|
415
417
|
{abbr.substring(3)}
|
|
@@ -154,7 +154,9 @@ const WorldMap = props => {
|
|
|
154
154
|
styles.cursor = 'pointer'
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
return
|
|
157
|
+
return (
|
|
158
|
+
<Geo additionalData={additionalData} geoData={geoData} state={state} key={i + '-geo'} style={styles} path={path} stroke={geoStrokeColor} strokeWidth={strokeWidth} onClick={() => geoClickHandler(geoDisplayName, geoData)} data-tooltip-id='tooltip' data-tooltip-html={toolTip} tabIndex={-1} />
|
|
159
|
+
)
|
|
158
160
|
}
|
|
159
161
|
|
|
160
162
|
// Default return state, just geo with no additional information
|
|
@@ -499,7 +499,7 @@ export const supportedCountries = {
|
|
|
499
499
|
ATA: ['Antarctica'],
|
|
500
500
|
'Madeira Islands': ['Madeira Islands'],
|
|
501
501
|
'Gaza/West Bank': ['Gaza/West Bank'],
|
|
502
|
-
'Saint Paul and
|
|
502
|
+
'Saint Paul and Amsterdam Islands': ['Saint Paul and Amsterdam Islands'],
|
|
503
503
|
'Sovereign Base Areas of Akrotiri and Dhekelia': ['Sovereign Base Areas of Akrotiri and Dhekelia'],
|
|
504
504
|
'Plazas de Soberania': ['Plazas de Soberania'],
|
|
505
505
|
Akrotiri: ['Akrotiri'],
|
package/src/scss/main.scss
CHANGED
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
cursor: pointer;
|
|
122
122
|
width: 1em;
|
|
123
123
|
}
|
|
124
|
-
|
|
124
|
+
a.navigation-link {
|
|
125
125
|
text-decoration: underline;
|
|
126
126
|
cursor: pointer;
|
|
127
127
|
color: #075290;
|
|
@@ -129,6 +129,7 @@
|
|
|
129
129
|
svg {
|
|
130
130
|
display: inline-block;
|
|
131
131
|
max-width: 13px;
|
|
132
|
+
margin-left: .5em;
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
135
|
&.capitalize p {
|
package/src/types/MapConfig.ts
CHANGED
|
@@ -11,10 +11,15 @@ export type MapVisualSettings = {
|
|
|
11
11
|
extraBubbleBorder: boolean
|
|
12
12
|
/** cityStyle - visual indicator of cities on state maps */
|
|
13
13
|
cityStyle: 'circle' | 'pin'
|
|
14
|
+
/** cityStyle - optional visual indicator of label on the Legend */
|
|
15
|
+
cityStyleLabel: string
|
|
14
16
|
/** geoCodeCircleSize - controls the size of the city style option (circle or pin) */
|
|
17
|
+
|
|
15
18
|
geoCodeCircleSize: number
|
|
16
19
|
/** showBubbleZeros - shows circles on maps when the data is provided even if its a zero value */
|
|
17
20
|
showBubbleZeros: boolean
|
|
21
|
+
/** additionalCityStyles - shows Circle, Square, Triangle, Rhombus/Diamond, Star, Map Pin on maps when the additionalCityStyles is added */
|
|
22
|
+
additionalCityStyles: [] | [{ label: string; column: string; value: string; shape: string }]
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
type PatternSelection = {
|
|
@@ -26,6 +31,8 @@ type PatternSelection = {
|
|
|
26
31
|
pattern: 'lines' | 'circles' | 'waves'
|
|
27
32
|
// optional legend update
|
|
28
33
|
label: string
|
|
34
|
+
// size of pattern
|
|
35
|
+
size: 'small' | 'medium' | 'large'
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
export type GeoColumnProperties = Pick<EditorColumnProperties, 'name' | 'label' | 'tooltip' | 'dataTable'>
|