@cdc/map 2.6.3 → 4.22.10
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 +32 -18
- package/examples/bubble-us.json +363 -0
- package/examples/bubble-world.json +427 -0
- package/examples/default-county.json +64 -12
- package/examples/default-geocode.json +746 -0
- package/examples/default-hex.json +477 -0
- package/examples/default-usa-regions.json +118 -0
- package/examples/default-usa.json +1 -1
- package/examples/default-world-data.json +1450 -0
- package/examples/default-world.json +5 -3
- package/examples/example-city-state.json +46 -1
- package/examples/gallery/categorical-qualitative.json +797 -0
- package/examples/gallery/categorical-scale-based.json +739 -0
- package/examples/gallery/city-state.json +479 -0
- package/examples/gallery/county.json +22731 -0
- package/examples/gallery/equal-interval.json +1027 -0
- package/examples/gallery/equal-number.json +1027 -0
- package/examples/gallery/filterable.json +909 -0
- package/examples/gallery/hex-filtered.json +420 -0
- package/examples/gallery/hex.json +413 -0
- package/examples/gallery/single-state.json +21402 -0
- package/examples/gallery/world.json +1592 -0
- package/examples/private/atsdr.json +439 -0
- package/examples/private/atsdr_new.json +436 -0
- package/examples/private/bubble.json +285 -0
- package/examples/private/city-state.json +428 -0
- package/examples/private/cty-issue.json +42768 -0
- package/examples/private/default-usa.json +460 -0
- package/examples/private/default-world-data.json +1444 -0
- package/examples/private/default.json +968 -0
- package/examples/private/legend-issue.json +1 -0
- package/examples/private/map-rounding-error.json +42759 -0
- package/examples/private/map.csv +60 -0
- package/examples/private/mdx.json +210 -0
- package/examples/private/monkeypox.json +376 -0
- package/examples/private/regions.json +52 -0
- package/examples/private/valid-data-map.csv +59 -0
- package/examples/private/wcmsrd-13881-data.json +2858 -0
- package/examples/private/wcmsrd-13881.json +5823 -0
- package/examples/private/wcmsrd-14492-data.json +292 -0
- package/examples/private/wcmsrd-14492.json +114 -0
- package/examples/private/wcmsrd-test.json +268 -0
- package/examples/private/world.json +1580 -0
- package/examples/private/worldmap.json +1490 -0
- package/package.json +51 -50
- package/src/CdcMap.js +1384 -1075
- package/src/components/BubbleList.js +244 -0
- package/src/components/CityList.js +79 -17
- package/src/components/CountyMap.js +104 -44
- package/src/components/DataTable.js +32 -22
- package/src/components/EditorPanel.js +977 -414
- package/src/components/Geo.js +1 -1
- package/src/components/Modal.js +2 -1
- package/src/components/NavigationMenu.js +4 -3
- package/src/components/Sidebar.js +14 -19
- package/src/components/SingleStateMap.js +178 -249
- package/src/components/UsaMap.js +104 -36
- package/src/components/UsaRegionMap.js +320 -0
- package/src/components/WorldMap.js +117 -34
- package/src/data/country-coordinates.js +250 -0
- package/src/data/{dfc-map.json → county-map.json} +0 -0
- package/src/data/initial-state.js +23 -3
- package/src/data/state-coordinates.js +55 -0
- package/src/data/supported-geos.js +101 -15
- package/src/data/us-regions-topo-2.json +360525 -0
- package/src/data/us-regions-topo.json +37894 -0
- package/src/hooks/useColorPalette.ts +96 -0
- package/src/index.html +8 -4
- package/src/scss/editor-panel.scss +78 -57
- package/src/scss/main.scss +1 -6
- package/src/scss/map.scss +126 -2
- package/src/scss/sidebar.scss +2 -1
- package/src/data/color-palettes.js +0 -200
- package/src/images/map-folded.svg +0 -1
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
useTable, useSortBy, useResizeColumns, useBlockLayout
|
|
6
6
|
} from 'react-table';
|
|
7
7
|
import Papa from 'papaparse';
|
|
8
|
-
import ExternalIcon from '../images/external-link.svg';
|
|
8
|
+
import ExternalIcon from '../images/external-link.svg'; // TODO: Move to Icon component
|
|
9
9
|
|
|
10
10
|
import ErrorBoundary from '@cdc/core/components/ErrorBoundary';
|
|
11
11
|
import LegendCircle from '@cdc/core/components/LegendCircle';
|
|
@@ -30,7 +30,10 @@ const DataTable = (props) => {
|
|
|
30
30
|
applyLegendToRow,
|
|
31
31
|
displayGeoName,
|
|
32
32
|
navigationHandler,
|
|
33
|
-
viewport
|
|
33
|
+
viewport,
|
|
34
|
+
formatLegendLocation,
|
|
35
|
+
tabbingId,
|
|
36
|
+
setFilteredCountryCode
|
|
34
37
|
} = props;
|
|
35
38
|
|
|
36
39
|
const [expanded, setExpanded] = useState(expandDataTable);
|
|
@@ -39,7 +42,7 @@ const DataTable = (props) => {
|
|
|
39
42
|
|
|
40
43
|
const [ready, setReady] = useState(false)
|
|
41
44
|
|
|
42
|
-
const fileName = `${mapTitle}.csv`;
|
|
45
|
+
const fileName = `${mapTitle || 'data-table'}.csv`;
|
|
43
46
|
|
|
44
47
|
|
|
45
48
|
// Catch all sorting method used on load by default but also on user click
|
|
@@ -164,7 +167,6 @@ const DataTable = (props) => {
|
|
|
164
167
|
id={`${skipId}`}
|
|
165
168
|
data-html2canvas-ignore
|
|
166
169
|
role="button"
|
|
167
|
-
tabIndex="-1"
|
|
168
170
|
>
|
|
169
171
|
Download Data (CSV)
|
|
170
172
|
</a>
|
|
@@ -176,9 +178,9 @@ const DataTable = (props) => {
|
|
|
176
178
|
const newTableColumns = [];
|
|
177
179
|
|
|
178
180
|
Object.keys(columns).forEach((column) => {
|
|
179
|
-
if (columns[column].dataTable === true &&
|
|
181
|
+
if (columns[column].dataTable === true && columns[column].name) {
|
|
180
182
|
const newCol = {
|
|
181
|
-
Header: columns[column].label
|
|
183
|
+
Header: columns[column].label ? columns[column].label : columns[column].name,
|
|
182
184
|
id: column,
|
|
183
185
|
accessor: (row) => {
|
|
184
186
|
if (runtimeData) {
|
|
@@ -204,7 +206,11 @@ const DataTable = (props) => {
|
|
|
204
206
|
|
|
205
207
|
const legendColor = applyLegendToRow(rowObj);
|
|
206
208
|
|
|
207
|
-
|
|
209
|
+
if(state.general.geoType !== 'us-county' || state.general.type === 'us-geocode') {
|
|
210
|
+
var labelValue = displayGeoName(row.original);
|
|
211
|
+
} else {
|
|
212
|
+
var labelValue = formatLegendLocation(row.original)
|
|
213
|
+
}
|
|
208
214
|
|
|
209
215
|
labelValue = getCellAnchor(labelValue, rowObj);
|
|
210
216
|
|
|
@@ -230,11 +236,11 @@ const DataTable = (props) => {
|
|
|
230
236
|
});
|
|
231
237
|
|
|
232
238
|
return newTableColumns;
|
|
233
|
-
}, [indexTitle, columns, runtimeData,
|
|
239
|
+
}, [indexTitle, columns, runtimeData,getCellAnchor,displayDataAsText,applyLegendToRow,customSort,displayGeoName,state.legend.specialClasses]);
|
|
234
240
|
|
|
235
241
|
const tableData = useMemo(
|
|
236
242
|
() => Object.keys(runtimeData).filter((key) => applyLegendToRow(runtimeData[key])).sort((a, b) => customSort(a, b)),
|
|
237
|
-
[
|
|
243
|
+
[ runtimeData, applyLegendToRow, customSort]
|
|
238
244
|
);
|
|
239
245
|
|
|
240
246
|
// Change accessibility label depending on expanded status
|
|
@@ -282,7 +288,7 @@ const DataTable = (props) => {
|
|
|
282
288
|
if(!state.data) return <Loading />
|
|
283
289
|
return (
|
|
284
290
|
<ErrorBoundary component="DataTable">
|
|
285
|
-
<section id={
|
|
291
|
+
<section id={tabbingId.replace('#', '')} className={`data-table-container ${viewport}`} aria-label={accessibilityLabel}>
|
|
286
292
|
<a id='skip-nav' className='cdcdataviz-sr-only-focusable' href={`#${skipId}`}>
|
|
287
293
|
Skip Navigation or Skip to Content
|
|
288
294
|
</a>
|
|
@@ -292,17 +298,17 @@ const DataTable = (props) => {
|
|
|
292
298
|
tabIndex="0"
|
|
293
299
|
onKeyDown={(e) => { if (e.keyCode === 13) { setExpanded(!expanded); } }}
|
|
294
300
|
>
|
|
295
|
-
|
|
301
|
+
|
|
296
302
|
{tableTitle}
|
|
297
303
|
</div>
|
|
298
|
-
<div
|
|
304
|
+
<div
|
|
299
305
|
className="table-container"
|
|
300
|
-
style={ { maxHeight: state.dataTable.limitHeight && `${state.dataTable.height}px`, overflowY: 'scroll' } }
|
|
306
|
+
style={ { maxHeight: state.dataTable.limitHeight && `${state.dataTable.height}px`, overflowY: 'scroll' } }
|
|
301
307
|
>
|
|
302
308
|
<table
|
|
303
|
-
height={expanded ? null : 0} {...getTableProps()}
|
|
304
|
-
aria-live="assertive"
|
|
305
|
-
className={expanded ? 'data-table' : 'data-table cdcdataviz-sr-only'}
|
|
309
|
+
height={expanded ? null : 0} {...getTableProps()}
|
|
310
|
+
aria-live="assertive"
|
|
311
|
+
className={expanded ? 'data-table' : 'data-table cdcdataviz-sr-only'}
|
|
306
312
|
hidden={!expanded}
|
|
307
313
|
aria-rowcount={state?.data.length ? state.data.length : '-1' }
|
|
308
314
|
>
|
|
@@ -311,7 +317,8 @@ const DataTable = (props) => {
|
|
|
311
317
|
{headerGroups.map((headerGroup) => (
|
|
312
318
|
<tr {...headerGroup.getHeaderGroupProps()}>
|
|
313
319
|
{headerGroup.headers.map((column) => (
|
|
314
|
-
<th
|
|
320
|
+
<th
|
|
321
|
+
tabIndex="0"
|
|
315
322
|
title={column.Header}
|
|
316
323
|
role="columnheader"
|
|
317
324
|
scope="col"
|
|
@@ -337,11 +344,14 @@ const DataTable = (props) => {
|
|
|
337
344
|
prepareRow(row);
|
|
338
345
|
return (
|
|
339
346
|
<tr {...row.getRowProps()} role="row">
|
|
340
|
-
{row.cells.map((cell) =>
|
|
341
|
-
|
|
342
|
-
{cell.
|
|
343
|
-
|
|
344
|
-
|
|
347
|
+
{row.cells.map((cell) => {
|
|
348
|
+
return (
|
|
349
|
+
<td tabIndex="0" {...cell.getCellProps()} role="gridcell" onClick={ (e) => (state.general.type === 'bubble' && state.general.allowMapZoom && state.general.geoType === 'world') ? setFilteredCountryCode(cell.row.original) : true }>
|
|
350
|
+
{cell.render('Cell')}
|
|
351
|
+
</td>
|
|
352
|
+
)
|
|
353
|
+
}
|
|
354
|
+
)}
|
|
345
355
|
</tr>
|
|
346
356
|
);
|
|
347
357
|
})}
|