@cdc/map 4.24.10 → 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.
Files changed (57) hide show
  1. package/dist/cdcmap.js +33447 -32769
  2. package/examples/default-geocode.json +13 -4
  3. package/examples/default-usa-regions.json +267 -117
  4. package/examples/example-city-state.json +6 -3
  5. package/examples/pattern.json +861 -0
  6. package/examples/private/DEV-9644.json +184 -0
  7. package/examples/private/DEV-9989.json +229 -0
  8. package/examples/private/ardi.json +180 -0
  9. package/examples/private/colors 2.json +416 -0
  10. package/examples/private/colors.json +416 -0
  11. package/examples/private/colors.json.zip +0 -0
  12. package/examples/private/customColors.json +45348 -0
  13. package/examples/private/default-patterns.json +867 -0
  14. package/examples/private/test.json +1632 -0
  15. package/index.html +4 -5
  16. package/package.json +3 -3
  17. package/src/CdcMap.tsx +93 -83
  18. package/src/_stories/CdcMap.Legend.Gradient.stories.tsx +67 -0
  19. package/src/_stories/CdcMap.Legend.stories.tsx +40 -0
  20. package/src/_stories/CdcMap.Patterns.stories.tsx +29 -0
  21. package/src/_stories/CdcMap.stories.tsx +59 -0
  22. package/src/_stories/UsaMap.NoData.stories.tsx +19 -0
  23. package/src/_stories/_mock/custom-layer-map.json +1117 -0
  24. package/src/_stories/_mock/default-patterns.json +865 -0
  25. package/src/_stories/_mock/example-city-state.json +858 -0
  26. package/src/_stories/_mock/usa-state-gradient.json +238 -0
  27. package/src/_stories/_mock/wastewater-map.json +208 -0
  28. package/src/components/CityList.tsx +5 -2
  29. package/src/components/EditorPanel/components/EditorPanel.tsx +68 -295
  30. package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +27 -23
  31. package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +75 -16
  32. package/src/components/Legend/components/Legend.tsx +42 -20
  33. package/src/components/Legend/components/index.scss +24 -24
  34. package/src/components/UsaMap/components/HexIcon.tsx +7 -1
  35. package/src/components/UsaMap/components/SingleState/SingleState.CountyOutput.tsx +40 -6
  36. package/src/components/UsaMap/components/SingleState/SingleState.StateOutput.tsx +10 -2
  37. package/src/components/UsaMap/components/Territory/Territory.Hexagon.tsx +57 -12
  38. package/src/components/UsaMap/components/Territory/Territory.Rectangle.tsx +95 -21
  39. package/src/components/UsaMap/components/Territory/TerritoryShape.ts +13 -0
  40. package/src/components/UsaMap/components/UsaMap.County.tsx +11 -13
  41. package/src/components/UsaMap/components/UsaMap.Region.tsx +59 -16
  42. package/src/components/UsaMap/components/UsaMap.SingleState.tsx +2 -1
  43. package/src/components/UsaMap/components/UsaMap.State.tsx +61 -63
  44. package/src/components/UsaMap/helpers/shapes.ts +5 -4
  45. package/src/components/WorldMap/WorldMap.tsx +77 -16
  46. package/src/data/initial-state.js +2 -1
  47. package/src/helpers/applyColorToLegend.ts +80 -0
  48. package/src/helpers/colors.ts +23 -0
  49. package/src/hooks/useTooltip.ts +9 -6
  50. package/src/scss/editor-panel.scss +0 -3
  51. package/src/scss/filters.scss +1 -9
  52. package/src/scss/main.scss +0 -5
  53. package/src/scss/map.scss +11 -63
  54. package/src/types/MapConfig.ts +8 -2
  55. package/src/types/MapContext.ts +1 -0
  56. package/examples/default-patterns.json +0 -579
  57. package/src/scss/datatable.scss +0 -6
@@ -14,7 +14,9 @@ const useTooltip = props => {
14
14
  if (geoType === 'us-county' && type !== 'us-geocode') {
15
15
  let stateFipsCode = row[config.columns.geo.name].substring(0, 2)
16
16
  const stateName = supportedStatesFipsCodes[stateFipsCode]
17
- toolTipText += hideGeoColumnInTooltip ? `<strong>${stateName}</strong><br/>` : `<strong>Location: ${stateName}</strong><br/>`
17
+ toolTipText += hideGeoColumnInTooltip
18
+ ? `<strong>${stateName}</strong><br/>`
19
+ : `<strong>Location: ${stateName}</strong><br/>`
18
20
  }
19
21
  return toolTipText
20
22
  }
@@ -61,7 +63,7 @@ const useTooltip = props => {
61
63
  const handleTooltipSpecialClassText = (specialClasses, column, row, value, columnKey) => {
62
64
  if (specialClasses && specialClasses.length && typeof specialClasses[0] === 'object') {
63
65
  for (const specialClass of specialClasses) {
64
- if (column.name === specialClass.key && String(row[specialClass.key]) === specialClass.value) {
66
+ if (column.name === specialClass.key && String(row?.[specialClass.key]) === specialClass.value) {
65
67
  value = displayDataAsText(specialClass.label, columnKey)
66
68
  break
67
69
  }
@@ -73,7 +75,8 @@ const useTooltip = props => {
73
75
  const handleTooltipPrimaryColumn = (tooltipValue, column) => {
74
76
  const { hidePrimaryColumnInTooltip } = config.general as { hidePrimaryColumnInTooltip: boolean }
75
77
  let tooltipPrefix = column.label?.length > 0 ? column.label : ''
76
- if ((column.name === config.columns.primary.name && hidePrimaryColumnInTooltip) || !tooltipPrefix) return `<li class="tooltip-body">${tooltipValue}</li>`
78
+ if ((column.name === config.columns.primary.name && hidePrimaryColumnInTooltip) || !tooltipPrefix)
79
+ return `<li class="tooltip-body">${tooltipValue}</li>`
77
80
  return `<li class="tooltip-body">${tooltipPrefix}: ${tooltipValue}</li>`
78
81
  }
79
82
 
@@ -91,7 +94,7 @@ const useTooltip = props => {
91
94
  legend: { specialClasses }
92
95
  } = config
93
96
 
94
- if (tooltipEnabledMaps.includes(currentMapType) && undefined !== row) {
97
+ if (tooltipEnabledMaps.includes(currentMapType) && (row !== undefined || config.general.geoType === 'world')) {
95
98
  toolTipText += `<ul>`
96
99
 
97
100
  // if tooltips are allowed, loop through each column
@@ -102,7 +105,7 @@ const useTooltip = props => {
102
105
  let tooltipValue = handleTooltipSpecialClassText(specialClasses, column, row, '', columnKey)
103
106
 
104
107
  if (!tooltipValue) {
105
- tooltipValue = displayDataAsText(row[column.name], columnKey)
108
+ tooltipValue = row ? displayDataAsText(row[column.name], columnKey) : 'No Data'
106
109
  }
107
110
 
108
111
  toolTipText += handleTooltipPrimaryColumn(tooltipValue, column)
@@ -115,7 +118,7 @@ const useTooltip = props => {
115
118
  }
116
119
 
117
120
  const buildTooltip = (row, geoName, toolTipText = '') => {
118
- if (!row) return
121
+ if (!row && config.general.geoType !== 'world') return
119
122
 
120
123
  // Handle County Location Columns
121
124
  toolTipText += handleTooltipStateNameColumn(toolTipText, row)
@@ -546,9 +546,6 @@
546
546
  font-weight: normal;
547
547
  }
548
548
 
549
- .btn {
550
- margin-top: 1em;
551
- }
552
549
  .sort-list {
553
550
  list-style: none;
554
551
  > li {
@@ -1,8 +1,5 @@
1
1
  .cdc-open-viz-module .cdc-map-inner-container .filters-section,
2
2
  .cove .cdc-map-inner-container .filters-section {
3
- margin-left: 1rem;
4
- margin-right: 1rem;
5
-
6
3
  &__title {
7
4
  margin: 15px 0;
8
5
  }
@@ -22,18 +19,13 @@
22
19
 
23
20
  @include breakpoint(md) {
24
21
  display: flex;
25
- gap: 30px;
22
+ flex-wrap: wrap;
26
23
  }
27
24
 
28
25
  label:not(:empty) {
29
26
  margin-right: 0.4em;
30
27
  }
31
28
 
32
- select {
33
- font-size: 1em;
34
- padding-right: 5px;
35
- }
36
-
37
29
  .single-filter {
38
30
  margin-bottom: 0.5em;
39
31
  }
@@ -47,7 +47,6 @@
47
47
 
48
48
  .cdc-map-inner-container {
49
49
  @import './map';
50
- @import './datatable';
51
50
  flex-grow: 1;
52
51
  text-rendering: geometricPrecision;
53
52
  color: #202020;
@@ -55,10 +54,6 @@
55
54
  text-align: left;
56
55
  max-width: 100%;
57
56
  background-color: white;
58
- .btn {
59
- padding: 0.375em 0.75em;
60
- border-radius: 0.3em;
61
- }
62
57
 
63
58
  header.hidden {
64
59
  display: none;
package/src/scss/map.scss CHANGED
@@ -86,25 +86,10 @@ $medium: 768px;
86
86
  transition: 0.2s all;
87
87
  }
88
88
  }
89
- // make logo smaller on mobile
90
- @media screen and (max-width: $small) {
91
- .map-logo {
92
- position: absolute;
93
- bottom: 4em; // needed to align to top of Territories
94
- right: 1em;
95
- z-index: 3;
96
- width: 50px; // make it smaller
97
- }
98
- }
99
- // everything else but mobile
100
- @media screen and (min-width: $small) {
101
- .map-logo {
102
- position: absolute;
103
- bottom: 2em;
104
- right: 1em;
105
- z-index: 3;
106
- width: 75px;
107
- }
89
+ .map-logo {
90
+ display: block;
91
+ margin: 0 0 0 auto;
92
+ max-height: 35px;
108
93
  }
109
94
  }
110
95
 
@@ -116,61 +101,25 @@ $medium: 768px;
116
101
  }
117
102
  }
118
103
 
119
- // for Territories label in one col and Territory blocks wrapping in 2nd column
120
- .two-col {
121
- display: flex;
122
- margin-top: 0;
123
-
124
- justify-content: flex-start;
125
- > label {
126
- margin-top: 0;
127
- display: inline-block;
128
- }
129
- }
130
-
131
104
  .territories-label {
132
105
  color: black;
133
- margin: 2em 5px 2em 1em;
134
106
  font-size: 1.1em;
135
107
  display: block;
108
+ margin-top: 15px;
136
109
  }
137
110
 
138
111
  // Cities and Territories
139
112
  .territories {
140
- margin: 2em 200px 2em 0;
141
- font-size: 1.1em;
142
- width: 100%;
143
- display: block;
144
- align-items: center;
145
- > span {
146
- margin-left: 1em;
147
- margin-right: 0.5em;
148
- }
113
+ gap: 0.5em;
149
114
  svg {
150
115
  max-width: 35px;
151
116
  min-width: 25px;
152
- margin-left: 0.5em;
153
117
  transition: 0.3s all;
118
+
154
119
  text {
155
120
  font-size: 0.95em;
156
121
  }
157
122
  }
158
-
159
- &--mobile {
160
- @extend .territories;
161
- width: 60%;
162
- svg {
163
- margin-bottom: 0.5em;
164
- }
165
- }
166
-
167
- &--tablet {
168
- @extend .territories;
169
- width: 70%;
170
- svg {
171
- margin-bottom: 0.5em;
172
- }
173
- }
174
123
  }
175
124
 
176
125
  .zoom-controls {
@@ -266,10 +215,6 @@ $medium: 768px;
266
215
  transition: none !important;
267
216
  }
268
217
 
269
- // .state {
270
- // display: none;
271
- // }
272
-
273
218
  .state {
274
219
  &--inactive:hover path {
275
220
  cursor: pointer;
@@ -384,5 +329,8 @@ canvas {
384
329
  }
385
330
 
386
331
  .data-table-container {
387
- margin: 5px 0px !important;
332
+ margin: 20px 0px 0px;
333
+ &.download-link-above {
334
+ margin-top: 0;
335
+ }
388
336
  }
@@ -1,6 +1,8 @@
1
1
  import { ComponentThemes } from '@cdc/core/types/ComponentThemes'
2
2
  import { Visualization } from '@cdc/core/types/Visualization'
3
3
  import { EditorColumnProperties } from '@cdc/core/types/EditorColumnProperties'
4
+ import { Version } from '@cdc/core/types/Version'
5
+ import { VizFilter } from '@cdc/core/types/VizFilter'
4
6
 
5
7
  export type MapVisualSettings = {
6
8
  /** minBubbleSize - Minimum Circle Size when the map has a type of bubble */
@@ -33,6 +35,7 @@ type PatternSelection = {
33
35
  label: string
34
36
  // size of pattern
35
37
  size: 'small' | 'medium' | 'large'
38
+ color: string
36
39
  contrastCheck: boolean
37
40
  }
38
41
 
@@ -48,7 +51,7 @@ export type ViewportSize = 'xxs' | 'xs' | 'sm' | 'md' | 'lg'
48
51
  export type LegendShapeItem = {
49
52
  column: string
50
53
  key: string
51
- operator: string
54
+ operator: '=' | '≠' | '<' | '>' | '<=' | '>='
52
55
  shape: string
53
56
  value: string
54
57
  }
@@ -79,7 +82,7 @@ export type MapConfig = Visualization & {
79
82
  }
80
83
  dataUrl: string
81
84
  runtimeDataUrl: string
82
- filters: any[]
85
+ filters: VizFilter[]
83
86
  general: {
84
87
  allowMapZoom: boolean
85
88
  convertFipsCodes: boolean
@@ -163,5 +166,8 @@ export type MapConfig = Visualization & {
163
166
  }
164
167
  hexMap: HexMapSettings
165
168
  filterBehavior: string
169
+ filterIntro: string
166
170
  visual: MapVisualSettings
171
+ // version of the map
172
+ version: Version
167
173
  }
@@ -24,6 +24,7 @@ export type MapContext = {
24
24
  isEditor
25
25
  isFilterValueSupported: boolean
26
26
  loadConfig
27
+ logo: string
27
28
  navigationHandler
28
29
  position
29
30
  resetLegendToggles