@cdc/map 4.26.2 → 4.26.4
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/CONFIG.md +235 -0
- package/README.md +70 -24
- package/dist/cdcmap-CY9IcPSi.es.js +6 -0
- package/dist/cdcmap-DlpiY3fQ.es.js +4 -0
- package/dist/cdcmap.js +31260 -27946
- package/examples/{testing-layer-2.json → __data__/testing-layer-2.json} +1 -1
- package/examples/{testing-layer.json → __data__/testing-layer.json} +1 -1
- package/examples/county-hsa-toggle.json +51993 -0
- package/examples/custom-map-layers.json +2 -2
- package/examples/default-county.json +3 -3
- package/examples/minimal-example.json +69 -0
- package/examples/private/annotation-bug.json +642 -0
- package/examples/private/css-issue.json +314 -0
- package/examples/private/region-breaking.json +1639 -0
- package/examples/private/test1.json +27247 -0
- package/package.json +4 -4
- package/src/CdcMap.tsx +3 -14
- package/src/CdcMapComponent.tsx +302 -164
- package/src/_stories/CdcMap.Defaults.smoke.stories.tsx +76 -0
- package/src/_stories/CdcMap.Editor.ColumnsSectionTests.stories.tsx +601 -0
- package/src/_stories/CdcMap.Editor.DataTableSectionTests.stories.tsx +404 -0
- package/src/_stories/CdcMap.Editor.FiltersSectionTests.stories.tsx +229 -0
- package/src/_stories/CdcMap.Editor.GeneralSectionTests.stories.tsx +262 -0
- package/src/_stories/CdcMap.Editor.LegendSectionTests.stories.tsx +541 -0
- package/src/_stories/CdcMap.Editor.MultiCountryWorldMapTests.stories.tsx +359 -0
- package/src/_stories/CdcMap.Editor.PatternSettingsSectionTests.stories.tsx +516 -0
- package/src/_stories/CdcMap.Editor.SmallMultiplesSectionTests.stories.tsx +165 -0
- package/src/_stories/CdcMap.Editor.TextAnnotationsSectionTests.stories.tsx +145 -0
- package/src/_stories/CdcMap.Editor.TypeSectionTests.stories.tsx +312 -0
- package/src/_stories/CdcMap.Editor.VisualSectionTests.stories.tsx +359 -0
- package/src/_stories/CdcMap.Editor.ZoomControlsTests.stories.tsx +88 -0
- package/src/_stories/{CdcMap.stories.tsx → CdcMap.smoke.stories.tsx} +23 -1
- package/src/_stories/Map.HTMLInDataTable.stories.tsx +385 -0
- package/src/_stories/_mock/legends/legend-tests.json +3 -3
- package/src/_stories/_mock/multi-state-show-unselected.json +82 -0
- package/src/cdcMapComponent.styles.css +2 -2
- package/src/components/Annotation/Annotation.Draggable.styles.css +4 -4
- package/src/components/Annotation/AnnotationDropdown.styles.css +1 -1
- package/src/components/Annotation/AnnotationList.styles.css +13 -13
- package/src/components/Annotation/AnnotationList.tsx +1 -1
- package/src/components/EditorPanel/components/EditorPanel.tsx +905 -416
- package/src/components/EditorPanel/components/HexShapeSettings.tsx +1 -1
- package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +112 -117
- package/src/components/EditorPanel/components/Panels/Panel.PatternSettings-style.css +1 -1
- package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +31 -15
- package/src/components/EditorPanel/components/editorPanel.styles.css +55 -25
- package/src/components/Legend/components/Legend.tsx +12 -7
- package/src/components/Legend/components/LegendGroup/legend.group.css +5 -5
- package/src/components/Legend/components/LegendItem.Hex.tsx +4 -2
- package/src/components/Legend/components/index.scss +2 -3
- package/src/components/NavigationMenu.tsx +2 -1
- package/src/components/SmallMultiples/SmallMultiples.css +5 -5
- package/src/components/SmallMultiples/SynchronizedTooltip.tsx +1 -1
- package/src/components/UsaMap/components/SingleState/SingleState.StateOutput.tsx +32 -17
- package/src/components/UsaMap/components/TerritoriesSection.tsx +3 -2
- package/src/components/UsaMap/components/Territory/Territory.Rectangle.tsx +13 -8
- package/src/components/UsaMap/components/UsaMap.County.tsx +629 -231
- package/src/components/UsaMap/components/UsaMap.Region.styles.css +1 -1
- package/src/components/UsaMap/components/UsaMap.SingleState.styles.css +2 -2
- package/src/components/UsaMap/components/UsaMap.State.tsx +14 -9
- package/src/components/UsaMap/data/cb_2019_us_county_20m.json +75817 -1
- package/src/components/UsaMap/data/hsa_fips_mapping.json +3144 -0
- package/src/components/WorldMap/WorldMap.tsx +10 -13
- package/src/components/WorldMap/data/world-topo-updated.json +1 -0
- package/src/components/WorldMap/data/world-topo.json +1 -1
- package/src/components/WorldMap/worldMap.styles.css +1 -1
- package/src/components/ZoomControls.tsx +49 -18
- package/src/components/zoomControls.styles.css +27 -11
- package/src/data/initial-state.js +15 -5
- package/src/data/legacy-defaults.ts +8 -0
- package/src/data/supported-counties.json +1 -1
- package/src/data/supported-geos.js +19 -0
- package/src/helpers/colors.ts +2 -1
- package/src/helpers/countyTerritories.ts +38 -0
- package/src/helpers/dataTableHelpers.ts +85 -0
- package/src/helpers/displayGeoName.ts +19 -11
- package/src/helpers/getMapContainerClasses.ts +8 -2
- package/src/helpers/getMatchingPatternForRow.ts +67 -0
- package/src/helpers/getPatternForRow.ts +11 -18
- package/src/helpers/tests/countyTerritories.test.ts +87 -0
- package/src/helpers/tests/dataTableHelpers.test.ts +78 -0
- package/src/helpers/tests/displayGeoName.test.ts +17 -0
- package/src/helpers/tests/getMatchingPatternForRow.test.ts +150 -0
- package/src/helpers/tests/getPatternForRow.test.ts +140 -2
- package/src/helpers/urlDataHelpers.ts +7 -1
- package/src/hooks/useApplyTooltipsToGeo.tsx +7 -4
- package/src/hooks/useMapLayers.tsx +1 -1
- package/src/hooks/useResizeObserver.ts +36 -22
- package/src/hooks/useTooltip.test.tsx +64 -0
- package/src/hooks/useTooltip.ts +46 -15
- package/src/scss/editor-panel.scss +1 -1
- package/src/scss/main.scss +140 -6
- package/src/scss/map.scss +9 -4
- package/src/store/map.actions.ts +5 -0
- package/src/store/map.reducer.ts +13 -0
- package/src/test/CdcMap.test.jsx +26 -2
- package/src/types/MapConfig.ts +28 -4
- package/src/types/MapContext.ts +5 -1
- package/topojson-updater/README.txt +1 -1
- package/dist/cdcmap-Cf9_fbQf.es.js +0 -6
- package/examples/__data__/city-state-data.json +0 -668
- package/examples/city-state.json +0 -434
- package/examples/default-world-data.json +0 -1450
- package/examples/new-cities.json +0 -656
- package/src/_stories/CdcMap.Editor.stories.tsx +0 -3475
- package/src/helpers/componentHelpers.ts +0 -8
- package/topojson-updater/package-lock.json +0 -223
- /package/src/_stories/{CdcMap.ColumnWrap.stories.tsx → CdcMap.ColumnWrap.smoke.stories.tsx} +0 -0
- /package/src/_stories/{CdcMap.DistrictOfColumbia.stories.tsx → CdcMap.DistrictOfColumbia.smoke.stories.tsx} +0 -0
- /package/src/_stories/{CdcMap.Filters.stories.tsx → CdcMap.Filters.smoke.stories.tsx} +0 -0
- /package/src/_stories/{CdcMap.Legend.Gradient.stories.tsx → CdcMap.Legend.Gradient.smoke.stories.tsx} +0 -0
- /package/src/_stories/{CdcMap.Legend.stories.tsx → CdcMap.Legend.smoke.stories.tsx} +0 -0
- /package/src/_stories/{CdcMap.Patterns.stories.tsx → CdcMap.Patterns.smoke.stories.tsx} +0 -0
- /package/src/_stories/{CdcMap.SmallMultiples.stories.tsx → CdcMap.SmallMultiples.smoke.stories.tsx} +0 -0
- /package/src/_stories/{CdcMap.Table.stories.tsx → CdcMap.Table.smoke.stories.tsx} +0 -0
- /package/src/_stories/{CdcMap.ZeroColor.stories.tsx → CdcMap.ZeroColor.smoke.stories.tsx} +0 -0
- /package/src/_stories/{GoogleMap.stories.tsx → GoogleMap.smoke.stories.tsx} +0 -0
- /package/src/_stories/{UsaMap.NoData.stories.tsx → UsaMap.NoData.smoke.stories.tsx} +0 -0
package/CONFIG.md
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
# `@cdc/map` Configuration Reference
|
|
2
|
+
|
|
3
|
+
This document covers the `@cdc/map`-owned config contract. Shared nested structures such as `filters`, `table`, `annotations`, `markupVariables`, `general.palette`, `general.headerColor`, and the shared column/property shapes are documented in the [`@cdc/core` config reference](https://github.com/CDCgov/cdc-open-viz/blob/main/packages/core/CONFIG.md).
|
|
4
|
+
|
|
5
|
+
To follow those shared types locally, use `packages/core/CONFIG.md` in this monorepo or `node_modules/@cdc/core/CONFIG.md` in an installed app. If neither path is available, use the GitHub link above.
|
|
6
|
+
|
|
7
|
+
## Organization
|
|
8
|
+
|
|
9
|
+
The sections below follow the package’s real config surface:
|
|
10
|
+
|
|
11
|
+
| Section | Covers |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| Identity and data source | Package identity plus loader metadata |
|
|
14
|
+
| Geography and columns | Map mode, geography controls, and package-specific column wiring |
|
|
15
|
+
| Copy and shell controls | Title, intro/subtext, download toggles, and map shell behavior |
|
|
16
|
+
| Classification and palette | Map-specific legend behavior and palette notes |
|
|
17
|
+
| Map features | Overlays, patterns, hex maps, and small multiples |
|
|
18
|
+
| Layout and interactivity | Map positioning, visual shell settings, and tooltip behavior |
|
|
19
|
+
| Fields You Can Ignore | Legacy/editor artifacts that may still appear in saved configs |
|
|
20
|
+
|
|
21
|
+
## Minimum Working Config
|
|
22
|
+
|
|
23
|
+
The copy-pasteable minimum config lives in [README.md](./README.md). Its source of truth is [`examples/minimal-example.json`](./examples/minimal-example.json), and a test keeps the README block in sync with that file.
|
|
24
|
+
|
|
25
|
+
## Identity and Data Source
|
|
26
|
+
|
|
27
|
+
| Field | Type | Required | Default | Description | Allowed values / Notes |
|
|
28
|
+
| --- | --- | --- | --- | --- | --- |
|
|
29
|
+
| `type` | `string` | Yes | None | Identifies the package. | Must be `map`. |
|
|
30
|
+
| `version` | `string` | No | None | Saved COVE version for migration purposes. | Use the current package version when authoring a new config. |
|
|
31
|
+
| `color` | `string` | No | Legacy fallback | Legacy palette name kept for backward compatibility. | Prefer `general.palette.name` when authoring new configs. |
|
|
32
|
+
|
|
33
|
+
The following data-loading fields are shared and documented in core: `data`, `dataUrl`, `runtimeDataUrl`, `dataDescription`, `dataMetadata`, and `dataKey` for dashboard-driven embeds.
|
|
34
|
+
|
|
35
|
+
## Geography and Columns
|
|
36
|
+
|
|
37
|
+
| Field | Type | Required | Default | Description | Allowed values / Notes |
|
|
38
|
+
| --- | --- | --- | --- | --- | --- |
|
|
39
|
+
| `general.geoType` | `string` | Yes | `single-state` | Chooses the geography family being rendered. | `us`, `us-region`, `us-county`, `world`, `us-geocode`, `world-geocode`, `bubble`, `single-state`, `google-map` |
|
|
40
|
+
| `general.type` | `string` | Yes | `data` | Chooses the interaction mode. | `data`, `navigation`, `us-geocode`, `world-geocode`, `bubble` |
|
|
41
|
+
| `columns.geo` | `object` | Yes | See package defaults | Geography lookup column. | Uses shared column properties from core; `displayColumn` is map-specific and is used when the displayed geography label differs from the lookup field. |
|
|
42
|
+
| `columns.primary` | `object` | Conditionally | See package defaults | Main data column used for classification and tooltips. | Uses shared column properties from core. Required for data maps and bubble maps. |
|
|
43
|
+
| `columns.navigate` | `object` | Conditionally | `{ name: '' }` | URL column used in navigation mode. | Required when `general.type` is `navigation`. |
|
|
44
|
+
| `columns.latitude` | `object` | Conditionally | `{ name: '' }` | Latitude column for geocode and bubble maps. | Required for `us-geocode` and `world-geocode`. |
|
|
45
|
+
| `columns.longitude` | `object` | Conditionally | `{ name: '' }` | Longitude column for geocode and bubble maps. | Required for `us-geocode` and `world-geocode`. |
|
|
46
|
+
| `columns.categorical` | `object` | No | `{ name: '' }` | Category column for bubble maps using categorical legends. | `name` only. |
|
|
47
|
+
| `columns.hsa` | `object` | No | `{ name: '' }` | Optional HSA column used by county maps when HSA boundaries are shown. | `name` only. |
|
|
48
|
+
|
|
49
|
+
## Copy And Shell Controls
|
|
50
|
+
|
|
51
|
+
| Field | Type | Required | Default | Description | Allowed values / Notes |
|
|
52
|
+
| --- | --- | --- | --- | --- | --- |
|
|
53
|
+
| `general.title` | `string` | No | `''` | Main map title. | Hidden when `showTitle` is `false`. |
|
|
54
|
+
| `general.titleStyle` | `string` | No | `small` | Chooses the visual title treatment. | `legacy`, `large`, `small` |
|
|
55
|
+
| `general.showTitle` | `boolean` | No | `true` | Shows or hides the title. | `true`, `false` |
|
|
56
|
+
| `general.superTitle` | `string` | No | `''` | Optional small line above the main title. | Editor-managed. |
|
|
57
|
+
| `general.language` | `string` | No | `en` | Language code used by some map helpers and editor defaults. | Usually an ISO locale/language code. |
|
|
58
|
+
| `general.introText` | `string` | No | `''` | Intro copy shown in the shell. | Supports markup variables when enabled. |
|
|
59
|
+
| `general.subtext` | `string` | No | `''` | Supporting copy shown below the visualization. | Supports basic HTML plus markup variables when enabled. |
|
|
60
|
+
| `general.footnotes` | `string` | No | `''` | Optional footnote copy. | Shared footnotes shape is documented in core. |
|
|
61
|
+
| `general.navigationTarget` | `string` | No | `_self` | Target used when the map opens navigation URLs. | `_self`, `_blank` |
|
|
62
|
+
| `general.showSidebar` | `boolean` | No | `true` | Shows the legend/sidebar region. | Set to `false` for navigation and bubble layouts. |
|
|
63
|
+
| `general.noDataMessage` | `string` | No | `No State Selected` | Message shown when a single-state map has no active selection. | Package-specific copy. |
|
|
64
|
+
| `general.annotationDropdownText` | `string` | No | `Annotations` | Label shown for the annotation dropdown. | Used when annotation dropdowns are enabled. |
|
|
65
|
+
| `general.showAnnotationDropdown` | `boolean` | No | `false` | Shows the annotation dropdown in the shell. | Editor-driven toggle. |
|
|
66
|
+
| `general.geoBorderColor` | `string` | No | `darkGray` | Border color used for geography outlines. | `darkGray`, `sameAsBackground`, and other editor-supported color tokens. |
|
|
67
|
+
| `general.geoLabelOverride` | `string` | No | `''` | Overrides the geography label used in tooltips and other copy. | Useful when the map should say "Country", "State/Territory", or similar. |
|
|
68
|
+
| `general.fullBorder` | `boolean` | No | `false` | Adds a full border around navigation maps. | Mainly relevant when `general.type` is `navigation`. |
|
|
69
|
+
| `general.headerColor` | `string` | No | `theme-blue` | Shared header theme token. | See core docs for the full token list. |
|
|
70
|
+
| `general.displayStateLabels` | `boolean` | No | `true` | Shows state labels directly on the map. | `true`, `false` |
|
|
71
|
+
| `general.displayAsHex` | `boolean` | No | `false` | Switches the US map to a hex-style treatment. | Works with `hexMap`. |
|
|
72
|
+
| `general.equalNumberOptIn` | `boolean` | No | `false` | Enables the newer equal-number legend path. | Used when `legend.separateZero` and equal-number classification interact. |
|
|
73
|
+
| `general.allowMapZoom` | `boolean` | No | `true` | Enables zooming on supported map types. | Disabled in some editor flows and unsupported map modes. |
|
|
74
|
+
| `general.convertFipsCodes` | `boolean` | No | `true` | Normalizes FIPS-like geography values. | Helpful for US maps that use mixed FIPS formats. |
|
|
75
|
+
| `general.hideGeoColumnInTooltip` | `boolean` | No | `false` | Hides the geography field name in tooltips. | `true`, `false` |
|
|
76
|
+
| `general.hidePrimaryColumnInTooltip` | `boolean` | No | `false` | Hides the primary data field name in tooltips. | `true`, `false` |
|
|
77
|
+
| `general.showDownloadMediaButton` | `boolean` | No | `false` | Enables the media download button. | Often paired with the image/PDF toggles below. |
|
|
78
|
+
| `general.showDownloadImgButton` | `boolean` | No | `false` | Enables PNG/image download. | Editor-managed field. |
|
|
79
|
+
| `general.includeContextInDownload` | `boolean` | No | `false` | Includes heading and explanatory context in image downloads. | Only meaningful when image downloads are enabled. |
|
|
80
|
+
| `general.showDownloadPdfButton` | `boolean` | No | `false` | Enables PDF download. | Editor-managed field. |
|
|
81
|
+
| `general.showHSABoundaries` | `boolean` | No | `false` | Shows HSA boundaries on supported county maps. | Mainly relevant for health-system maps. |
|
|
82
|
+
| `general.showNeighboringStates` | `boolean` | No | `false` | Includes neighboring states in the county map outline. | Only relevant for county maps. |
|
|
83
|
+
| `general.showStateDropdown` | `boolean` | No | `false` | Shows a state picker in county views. | Only relevant for county maps. |
|
|
84
|
+
| `general.hideUnselectedStates` | `boolean` | No | `true` when states are picked | Controls whether selected-state maps hide or keep unselected states visible. | Only meaningful when `statesPicked` is populated on single-state maps. |
|
|
85
|
+
| `general.statesPicked` | `object[]` | No | `[]` | Selected states for single-state maps. | Each item has `fipsCode` and `stateName`. |
|
|
86
|
+
| `general.countriesPicked` | `object[]` | No | `[]` | Selected countries for world maps. | Each item has `iso` and `name`. |
|
|
87
|
+
| `general.hideUnselectedCountries` | `boolean` | No | `false` | Controls whether unselected countries are hidden or grayed out. | Only meaningful when `countriesPicked` is populated. |
|
|
88
|
+
| `general.territoriesAlwaysShow` | `boolean` | No | `true` | Controls how U.S. territories are rendered on U.S. maps. | `true`, `false`. On county maps, `false` hides all territory counties; `true` renders only territory counties with matching runtime data. On state maps, `false` renders only territories with matching runtime data; `true` renders all supported territories whether data exists or not. When omitted, the editor/runtime treat it as `true`, and legacy configs are backfilled to `true` during migration. |
|
|
89
|
+
| `general.territoriesLabel` | `string` | No | `Territories` | Label used for territories in US maps. | Often left at the default. |
|
|
90
|
+
| `general.hasRegions` | `boolean` | No | `false` | Marks the map as region-aware for some data-loading and editor flows. | Mainly used by US regional map flows. |
|
|
91
|
+
|
|
92
|
+
The canonical palette configuration is shared in core. This package still accepts the legacy `color` field for older saved configs, but new configs should author `general.palette` instead.
|
|
93
|
+
|
|
94
|
+
## Classification And Palette
|
|
95
|
+
|
|
96
|
+
Legend configuration is shared with core. The map package honors the shared legend contract plus these map-specific behaviors:
|
|
97
|
+
|
|
98
|
+
| Behavior | Details |
|
|
99
|
+
| --- | --- |
|
|
100
|
+
| `legend.separateZero` | When `true`, numeric legends split zero into its own class unless `general.equalNumberOptIn` changes the scaling path. |
|
|
101
|
+
| `legend.categoryValuesOrder` | Controls the order of categorical legend items and small-multiple tile sorting. |
|
|
102
|
+
| `legend.additionalCategories` | Adds extra category labels to the legend. |
|
|
103
|
+
| `legend.groupBy` | Groups categorical legend items when the editor uses grouped category views. |
|
|
104
|
+
| `legend.tickRotation` | Rotates legend tick labels in supported layouts. |
|
|
105
|
+
| `legend.hideBorder` | Hides the legend border when `true`. The default is `true` for the package’s current initial state. |
|
|
106
|
+
| `legend.singleColumnLegend` | Legacy flag used by older legend layouts. |
|
|
107
|
+
| `legend.separators` | Optional separator metadata used by gradient legends. |
|
|
108
|
+
|
|
109
|
+
## Filtering And Tables
|
|
110
|
+
|
|
111
|
+
Shared filter and table structures are documented in core. Map-specific behavior includes:
|
|
112
|
+
|
|
113
|
+
| Behavior | Details |
|
|
114
|
+
| --- | --- |
|
|
115
|
+
| `filterBehavior` | Controls whether the map updates immediately or waits for an explicit filter change in supporting editor flows. |
|
|
116
|
+
| `filterIntro` | Intro copy shown near the filter UI. |
|
|
117
|
+
| `table.forceDisplay` | Keeps the data table visible even when the current mode would normally hide it. |
|
|
118
|
+
|
|
119
|
+
## Map Features
|
|
120
|
+
|
|
121
|
+
### `map.layers`
|
|
122
|
+
|
|
123
|
+
Custom overlay or base layers added by the editor.
|
|
124
|
+
|
|
125
|
+
| Field | Type | Required | Default | Description | Allowed values / Notes |
|
|
126
|
+
| --- | --- | --- | --- | --- | --- |
|
|
127
|
+
| `name` | `string` | Yes | None | Display name for the layer. | Used in the editor accordion label. |
|
|
128
|
+
| `url` | `string` | Yes | None | Layer source URL. | Usually GeoJSON or TopoJSON. |
|
|
129
|
+
| `namespace` | `string` | No | `''` | SVG namespace / layer prefix. | Used when building layer ids. |
|
|
130
|
+
| `fill` | `string` | No | `''` | Fill color for the layer. | CSS color string. |
|
|
131
|
+
| `fillOpacity` | `number` | No | `''` | Fill opacity for the layer. | Numeric opacity value. |
|
|
132
|
+
| `stroke` | `string` | No | `''` | Stroke color for the layer. | CSS color string. |
|
|
133
|
+
| `strokeWidth` | `number` | No | `''` | Stroke width for the layer. | Numeric width value. |
|
|
134
|
+
| `tooltip` | `boolean` | No | `false` | Enables hover/click tooltips on the layer. | `true`, `false` |
|
|
135
|
+
|
|
136
|
+
### `map.patterns`
|
|
137
|
+
|
|
138
|
+
Pattern overlays applied to matching geography rows.
|
|
139
|
+
|
|
140
|
+
| Field | Type | Required | Default | Description | Allowed values / Notes |
|
|
141
|
+
| --- | --- | --- | --- | --- | --- |
|
|
142
|
+
| `dataKey` | `string` | No | `''` | Column used to match the pattern. | Leave blank to match across all columns. |
|
|
143
|
+
| `dataValue` | `string` | No | `''` | Value that triggers the pattern. | Compared as a string or numeric-like value. |
|
|
144
|
+
| `pattern` | `string` | No | `circles` | Pattern type. | `circles`, `waves`, `lines` |
|
|
145
|
+
| `label` | `string` | No | `''` | Optional legend label for the pattern. | Displayed in the legend when present. |
|
|
146
|
+
| `size` | `string` | No | `medium` | Pattern density / size. | `small`, `medium`, `large` |
|
|
147
|
+
| `color` | `string` | No | `''` | Pattern color. | CSS color string. |
|
|
148
|
+
| `contrastCheck` | `boolean` | No | `true` | Result of the editor contrast check. | Usually managed by the editor. |
|
|
149
|
+
|
|
150
|
+
### `hexMap`
|
|
151
|
+
|
|
152
|
+
| Field | Type | Required | Default | Description | Allowed values / Notes |
|
|
153
|
+
| --- | --- | --- | --- | --- | --- |
|
|
154
|
+
| `hexMap.type` | `string` | No | `''` | Chooses the hex-map rendering mode. | `shapes`, `standard`, or blank to disable. |
|
|
155
|
+
| `hexMap.shapeGroups` | `object[]` | No | `[]` or a single blank group in defaults | Groups of arrow/shape rules for hex-map cells. | See the nested fields below. |
|
|
156
|
+
|
|
157
|
+
`hexMap.shapeGroups[]`
|
|
158
|
+
|
|
159
|
+
| Field | Type | Required | Default | Description | Allowed values / Notes |
|
|
160
|
+
| --- | --- | --- | --- | --- | --- |
|
|
161
|
+
| `legendTitle` | `string` | No | `''` | Title for the shape group in the legend. | Optional. |
|
|
162
|
+
| `legendDescription` | `string` | No | `''` | Description for the shape group. | Optional. |
|
|
163
|
+
| `items` | `object[]` | No | `[]` | Shape rules that determine which arrow or icon is shown. | Each item can match by `key`, `column`, `operator`, and `value`. |
|
|
164
|
+
|
|
165
|
+
`hexMap.shapeGroups[].items[]`
|
|
166
|
+
|
|
167
|
+
| Field | Type | Required | Default | Description | Allowed values / Notes |
|
|
168
|
+
| --- | --- | --- | --- | --- | --- |
|
|
169
|
+
| `key` | `string` | No | `''` | Internal key for the hex-map rule. | Usually left blank in hand-authored configs. |
|
|
170
|
+
| `shape` | `string` | No | `Arrow Up` | Shape rendered for the rule. | Editor values include arrow directions. |
|
|
171
|
+
| `column` | `string` | No | `''` | Source column to inspect. | Can be blank for some legacy flows. |
|
|
172
|
+
| `operator` | `string` | No | `=` | Comparison operator. | `=`, `≠`, `<`, `>`, `<=`, `>=` |
|
|
173
|
+
| `value` | `string` | No | `''` | Comparison value. | Compared against the configured column. |
|
|
174
|
+
|
|
175
|
+
### `smallMultiples`
|
|
176
|
+
|
|
177
|
+
Only supported for `us`, `single-state`, and `us-region` map types.
|
|
178
|
+
|
|
179
|
+
| Field | Type | Required | Default | Description | Allowed values / Notes |
|
|
180
|
+
| --- | --- | --- | --- | --- | --- |
|
|
181
|
+
| `smallMultiples.mode` | `string` | No | `''` | Enables the small-multiples mode. | `by-column` when active. |
|
|
182
|
+
| `smallMultiples.tileColumn` | `string` | No | `''` | Column used to split the map into tiles. | Must be a column in the dataset. |
|
|
183
|
+
| `smallMultiples.tilesPerRowDesktop` | `number` | No | `2` | Number of tiles per row on desktop. | Editor limits this to small integer values. |
|
|
184
|
+
| `smallMultiples.tilesPerRowMobile` | `number` | No | `1` | Number of tiles per row on mobile. | Usually left alone. |
|
|
185
|
+
| `smallMultiples.tileOrderType` | `string` | No | `asc` | Tile ordering strategy. | `asc`, `desc`, `custom` |
|
|
186
|
+
| `smallMultiples.tileOrder` | `string[]` | No | `[]` | Explicit custom tile order. | Used only when `tileOrderType` is `custom`. |
|
|
187
|
+
| `smallMultiples.tileTitles` | `object` | No | `{}` | Optional custom title map per tile key. | Keys are tile identifiers. |
|
|
188
|
+
| `smallMultiples.synchronizedTooltips` | `boolean` | No | `true` | Keeps tooltips synchronized across tiles. | `true`, `false` |
|
|
189
|
+
|
|
190
|
+
### `annotations` and `markupVariables`
|
|
191
|
+
|
|
192
|
+
These structures are shared with core. In map configs, the important package-specific behavior is that annotation dropdowns are only visible when `general.showAnnotationDropdown` is enabled, and markup variables are applied to title, intro, subtext, legend, and other supported text fields when `enableMarkupVariables` is true.
|
|
193
|
+
|
|
194
|
+
## Layout And Interactivity
|
|
195
|
+
|
|
196
|
+
| Field | Type | Required | Default | Description | Allowed values / Notes |
|
|
197
|
+
| --- | --- | --- | --- | --- | --- |
|
|
198
|
+
| `mapPosition.coordinates` | `[number, number]` | No | `[0, 30]` | Initial map center. | The runtime may reset this when the geography changes. |
|
|
199
|
+
| `mapPosition.zoom` | `number` | No | `1` | Initial map zoom. | Editor/runtime may reset it when geography changes. |
|
|
200
|
+
| `visual.border` | `boolean` | No | `false` | Enables a component border. | Shared shell styling flag. |
|
|
201
|
+
| `visual.borderColorTheme` | `boolean` | No | `false` | Uses the theme color for the border. | Shared shell styling flag. |
|
|
202
|
+
| `visual.accent` | `boolean` | No | `false` | Enables accent styling. | Shared shell styling flag. |
|
|
203
|
+
| `visual.background` | `boolean` | No | `false` | Enables background styling. | Shared shell styling flag. |
|
|
204
|
+
| `visual.hideBackgroundColor` | `boolean` | No | `false` | Suppresses the background color. | Shared shell styling flag. |
|
|
205
|
+
| `visual.tp5Treatment` | `boolean` | No | `false` | Enables the TP5 shell treatment. | Mostly controlled by editor settings. |
|
|
206
|
+
| `visual.tp5Background` | `boolean` | No | `false` | Enables the TP5 cyan background. | Mostly controlled by editor settings. |
|
|
207
|
+
| `visual.minBubbleSize` | `number` | No | `1` | Minimum bubble radius. | Only relevant for bubble maps. |
|
|
208
|
+
| `visual.maxBubbleSize` | `number` | No | `20` | Maximum bubble radius. | Only relevant for bubble maps. |
|
|
209
|
+
| `visual.extraBubbleBorder` | `boolean` | No | `false` | Adds an extra border around bubbles. | Only relevant for bubble maps. |
|
|
210
|
+
| `visual.cityStyle` | `string` | No | `circle` | Default city marker shape. | `circle`, `pin`, `square`, `triangle`, `diamond`, `star` |
|
|
211
|
+
| `visual.cityStyleLabel` | `string` | No | `''` | Legend label for the default city style. | Optional. |
|
|
212
|
+
| `visual.geoCodeCircleSize` | `number` | No | `8` | Size used for geocode city markers. | Editor limits this to small integer values. |
|
|
213
|
+
| `visual.showBubbleZeros` | `boolean` | No | `false` | Shows bubble markers for zero values. | Only relevant for bubble maps. |
|
|
214
|
+
| `visual.additionalCityStyles` | `object[]` | No | `[]` | Extra city-style rules added in the editor. | Each rule uses `label`, `column`, `value`, and `shape`. |
|
|
215
|
+
| `tooltips.appearanceType` | `string` | No | `hover` | Chooses hover or click-based detail displays. | `hover`, `click` |
|
|
216
|
+
| `tooltips.linkLabel` | `string` | No | `Learn More` | Tooltip link label. | Used when `appearanceType` is `click`. |
|
|
217
|
+
| `tooltips.noDataLabel` | `string` | No | `''` | Text shown for missing data in the tooltip. | Optional. |
|
|
218
|
+
| `tooltips.opacity` | `number` | No | `90` | Tooltip opacity. | 0-100 in editor flows. |
|
|
219
|
+
|
|
220
|
+
## Fields You Can Ignore
|
|
221
|
+
|
|
222
|
+
These fields may appear in saved configs, editor exports, or runtime state, but consumers usually do not need to author them directly:
|
|
223
|
+
|
|
224
|
+
| Field or group | Why you can ignore it |
|
|
225
|
+
| --- | --- |
|
|
226
|
+
| `runtime.*` | Internal runtime state created by the package during initialization. |
|
|
227
|
+
| `defaultData`, `formattedData`, `datasets`, `runtimeDataUrl`, `dataMetadata` | Loader/runtime artifacts rather than hand-authored standalone config. |
|
|
228
|
+
| `sharing.*` | Loader/export metadata that belongs to editor or embed flows. |
|
|
229
|
+
| `usingWidgetLoader` | Internal loader flag. |
|
|
230
|
+
| `newViz` | Editor-only preview/confirmation flag. |
|
|
231
|
+
| `columns.additionalColumnN` | Editor-generated extra columns for data-table and tooltip workflows. |
|
|
232
|
+
| `general.countyCensusYear`, `general.filterControlsCountyYear`, `general.filterControlsStatesPicked` | Editor-only controls that are surfaced for some county and single-state flows. |
|
|
233
|
+
| `general.territoriesAlwayShow` | Misspelled legacy artifact from an older migration bug. The runtime repairs this to `general.territoriesAlwaysShow`; do not author it manually. |
|
|
234
|
+
| `statePicked` | Legacy saved-config artifact from older editor flows. |
|
|
235
|
+
| `showDownloadButton`, `expandDataTable` | Legacy editor state from older configs. |
|
package/README.md
CHANGED
|
@@ -2,42 +2,88 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@cdc/map)
|
|
4
4
|
|
|
5
|
-
React component for visualizing tabular data on a map of the United States or the world.
|
|
5
|
+
`<CdcMap />` is a React component for visualizing tabular data on a map of the United States or the world.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
* [Numeric Maps](https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/examples/example-numeric-maps.html)
|
|
9
|
-
* [World Map](https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/examples/example-world-data-map.html)
|
|
10
|
-
* [Categorical Map](https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/examples/example-categorical-maps.html)
|
|
11
|
-
* [Filterable Map](https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/examples/example-numeric-maps-filterable.html)
|
|
7
|
+
## Installation
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
```bash
|
|
10
|
+
npm install @cdc/map
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
2. Import the component and begin using in your code.
|
|
15
|
+
Pass a `config` object directly to the component:
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
<!-- README_EXAMPLE_CONFIG_START -->
|
|
18
|
+
```jsx
|
|
19
19
|
import CdcMap from '@cdc/map'
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const config = {
|
|
22
|
+
version: '4.26.4',
|
|
23
|
+
color: 'pinkpurple',
|
|
24
|
+
general: {
|
|
25
|
+
title: 'Minimal US Map',
|
|
26
|
+
geoType: 'us',
|
|
27
|
+
type: 'data',
|
|
28
|
+
showTitle: true
|
|
29
|
+
},
|
|
30
|
+
type: 'map',
|
|
31
|
+
columns: {
|
|
32
|
+
geo: { name: 'FIPS Codes', label: 'Location', tooltip: false, dataTable: true },
|
|
33
|
+
primary: { name: 'Rate', label: 'Rate', prefix: '', suffix: '%', tooltip: true, dataTable: true },
|
|
34
|
+
navigate: { name: '' },
|
|
35
|
+
latitude: { name: '' },
|
|
36
|
+
longitude: { name: '' }
|
|
37
|
+
},
|
|
38
|
+
legend: {
|
|
39
|
+
type: 'equalnumber',
|
|
40
|
+
numberOfItems: 3,
|
|
41
|
+
position: 'side',
|
|
42
|
+
style: 'circles',
|
|
43
|
+
title: 'Legend',
|
|
44
|
+
description: '',
|
|
45
|
+
descriptions: {},
|
|
46
|
+
specialClasses: [],
|
|
47
|
+
unified: false,
|
|
48
|
+
singleColumn: false,
|
|
49
|
+
singleRow: false,
|
|
50
|
+
verticalSorted: false,
|
|
51
|
+
showSpecialClassesLast: false,
|
|
52
|
+
dynamicDescription: false,
|
|
53
|
+
hideBorder: false
|
|
54
|
+
},
|
|
55
|
+
filters: [],
|
|
56
|
+
filterBehavior: 'Filter Change',
|
|
57
|
+
data: [
|
|
58
|
+
{ 'FIPS Codes': '01', Rate: 10 },
|
|
59
|
+
{ 'FIPS Codes': '02', Rate: 20 },
|
|
60
|
+
{ 'FIPS Codes': '04', Rate: 30 }
|
|
61
|
+
]
|
|
62
|
+
}
|
|
22
63
|
|
|
64
|
+
function App() {
|
|
23
65
|
return (
|
|
24
|
-
<div className=
|
|
25
|
-
<CdcMap />
|
|
66
|
+
<div className='App'>
|
|
67
|
+
<CdcMap config={config} />
|
|
26
68
|
</div>
|
|
27
|
-
)
|
|
69
|
+
)
|
|
28
70
|
}
|
|
29
71
|
|
|
30
|
-
export default App
|
|
72
|
+
export default App
|
|
31
73
|
```
|
|
74
|
+
<!-- README_EXAMPLE_CONFIG_END -->
|
|
75
|
+
|
|
76
|
+
You can also load configuration from a URL with `<CdcMap configUrl='/path/to/config.json' />`.
|
|
77
|
+
|
|
78
|
+
## Configuration
|
|
79
|
+
|
|
80
|
+
The primary reference for authoring configs is [CONFIG.md](./CONFIG.md).
|
|
32
81
|
|
|
33
|
-
|
|
82
|
+
If you are reading this in a context where relative Markdown links do not open correctly, use the [GitHub copy of the map config reference](https://github.com/CDCgov/cdc-open-viz/blob/main/packages/map/CONFIG.md).
|
|
34
83
|
|
|
35
|
-
|
|
84
|
+
## Properties
|
|
36
85
|
|
|
37
|
-
| Property
|
|
38
|
-
|
|
39
|
-
|
|
|
40
|
-
| configUrl
|
|
41
|
-
| config | Object | You can pass the raw configuration object directly as a prop. For help generating such an object, use the built in editor. |
|
|
42
|
-
| isEditor | Boolean | A simple flag that will load the editor for the maps inside your app. Helpful to provide a user interface instead of having to edit raw JSON. |
|
|
43
|
-
| className | String | Lets you add a custom class name to the outermost container element of the map. |
|
|
86
|
+
| Property | Type | Description |
|
|
87
|
+
| --- | --- | --- |
|
|
88
|
+
| `config` | `object` | Configuration object for the map. This is the primary integration path for React consumers. |
|
|
89
|
+
| `configUrl` | `string` | Optional URL to a JSON config file. Use this when you want the component to fetch its config at runtime. |
|