@cdc/chart 4.24.7 → 4.24.9

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 (51) hide show
  1. package/dist/cdcchart.js +40313 -37543
  2. package/examples/cases-year.json +13379 -0
  3. package/examples/gallery/bar-chart-vertical/combo-line-chart.json +76 -15
  4. package/examples/gallery/bar-chart-vertical/vertical-bar-chart-stacked.json +5 -5
  5. package/index.html +17 -8
  6. package/package.json +2 -2
  7. package/src/CdcChart.tsx +383 -133
  8. package/src/_stories/Chart.Legend.Gradient.tsx +19 -0
  9. package/src/_stories/_mock/legend.gradient_mock.json +236 -0
  10. package/src/components/Annotations/components/AnnotationDraggable.tsx +64 -11
  11. package/src/components/Axis/Categorical.Axis.tsx +145 -0
  12. package/src/components/BarChart/components/BarChart.Horizontal.tsx +4 -3
  13. package/src/components/BarChart/components/BarChart.StackedHorizontal.tsx +1 -1
  14. package/src/components/BarChart/components/BarChart.StackedVertical.tsx +2 -5
  15. package/src/components/BarChart/components/BarChart.Vertical.tsx +17 -8
  16. package/src/components/BarChart/helpers/index.ts +5 -16
  17. package/src/components/BrushChart.tsx +205 -0
  18. package/src/components/EditorPanel/EditorPanel.tsx +1766 -509
  19. package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +19 -5
  20. package/src/components/EditorPanel/components/Panels/Panel.General.tsx +190 -37
  21. package/src/components/EditorPanel/components/Panels/Panel.Sankey.tsx +43 -7
  22. package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +4 -4
  23. package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +1 -11
  24. package/src/components/EditorPanel/editor-panel.scss +16 -3
  25. package/src/components/EditorPanel/{useEditorPermissions.js → useEditorPermissions.ts} +90 -19
  26. package/src/components/Legend/Legend.Component.tsx +185 -193
  27. package/src/components/Legend/Legend.Suppression.tsx +146 -0
  28. package/src/components/Legend/Legend.tsx +21 -5
  29. package/src/components/Legend/helpers/index.ts +33 -3
  30. package/src/components/LegendWrapper.tsx +26 -0
  31. package/src/components/LineChart/LineChartProps.ts +1 -18
  32. package/src/components/LineChart/components/LineChart.BumpCircle.tsx +103 -0
  33. package/src/components/LineChart/components/LineChart.Circle.tsx +47 -8
  34. package/src/components/LineChart/helpers.ts +55 -11
  35. package/src/components/LineChart/index.tsx +113 -38
  36. package/src/components/LinearChart.tsx +1366 -0
  37. package/src/components/PieChart/PieChart.tsx +74 -17
  38. package/src/components/Sankey/index.tsx +22 -16
  39. package/src/components/Sparkline/components/SparkLine.tsx +2 -2
  40. package/src/data/initial-state.js +13 -3
  41. package/src/hooks/useLegendClasses.ts +52 -15
  42. package/src/hooks/useMinMax.ts +4 -4
  43. package/src/hooks/useScales.ts +34 -24
  44. package/src/hooks/useTooltip.tsx +85 -22
  45. package/src/scss/DataTable.scss +2 -1
  46. package/src/scss/main.scss +107 -14
  47. package/src/types/ChartConfig.ts +34 -8
  48. package/src/types/ChartContext.ts +5 -4
  49. package/examples/feature/line/line-chart.json +0 -449
  50. package/src/components/BrushHandle.jsx +0 -17
  51. package/src/components/LineChart/index.scss +0 -1
@@ -9,7 +9,17 @@ import { localPoint } from '@visx/event'
9
9
  import { bisector } from 'd3-array'
10
10
 
11
11
  export const useTooltip = props => {
12
- const { tableData: data, config, formatNumber, capitalize, formatDate, formatTooltipsDate, parseDate, setSharedFilter, isDraggingAnnotation } = useContext<ChartContext>(ConfigContext)
12
+ const {
13
+ tableData: data,
14
+ config,
15
+ formatNumber,
16
+ capitalize,
17
+ formatDate,
18
+ formatTooltipsDate,
19
+ parseDate,
20
+ setSharedFilter,
21
+ isDraggingAnnotation
22
+ } = useContext<ChartContext>(ConfigContext)
13
23
  const { xScale, yScale, showTooltip, hideTooltip } = props
14
24
  const { xAxis, visualizationType, orientation, yAxis, runtime } = config
15
25
 
@@ -47,13 +57,11 @@ export const useTooltip = props => {
47
57
  // handle case where data is missing
48
58
  const showMissingDataValue = config.general.showMissingDataLabel && (!value || value === 'null')
49
59
  let formattedValue = seriesKey === config.xAxis.dataKey ? value : formatNumber(value, getAxisPosition(seriesKey))
50
- formattedValue = showMissingDataValue ? 'N/A' : formattedValue
51
60
 
52
- const suppressed = config.preliminaryData?.find(pd => pd.label && pd.type === 'suppression' && pd.displayTooltip && value === pd.value && (!pd.column || seriesKey === pd.column))
53
-
54
- if (suppressed) {
55
- formattedValue = suppressed.label
56
- }
61
+ formattedValue =
62
+ showMissingDataValue && (config.visualizationSubType === 'stacked' ? !config.general.hideNullValue : true)
63
+ ? 'N/A'
64
+ : formattedValue
57
65
 
58
66
  return formattedValue
59
67
  }
@@ -84,6 +92,7 @@ export const useTooltip = props => {
84
92
  * @return {void} - The tooltip information is displayed
85
93
  */
86
94
  const handleTooltipMouseOver = (e, additionalChartData) => {
95
+ if (visualizationType === 'Bump Chart') return
87
96
  e.stopPropagation()
88
97
  if (isDraggingAnnotation) return
89
98
 
@@ -95,10 +104,13 @@ export const useTooltip = props => {
95
104
 
96
105
  const closestXScaleValue = getXValueFromCoordinate(x - Number(config.yAxis.size || 0))
97
106
 
98
- const includedSeries = visualizationType !== 'Pie' ? config.series.filter(series => series.tooltip === true).map(item => item.dataKey) : config.series.map(item => item.dataKey)
107
+ const includedSeries =
108
+ visualizationType !== 'Pie'
109
+ ? config.runtime.series.filter(series => series.tooltip === true).map(item => item.dataKey)
110
+ : config.runtime.series.map(item => item.dataKey)
99
111
  includedSeries.push(config.xAxis.dataKey)
100
112
  if (config.visualizationType === 'Forecasting') {
101
- config.series.map(s => {
113
+ config.runtime.series.map(s => {
102
114
  s.confidenceIntervals.map(c => {
103
115
  if (c.showInTooltip) {
104
116
  includedSeries.push(c.high)
@@ -125,7 +137,7 @@ export const useTooltip = props => {
125
137
  const resolvedScaleValues = orientation === 'vertical' ? yScaleValues : xScaleValues
126
138
 
127
139
  const getAxisPosition = seriesKey => {
128
- const seriesObj = config.series.filter(s => s.dataKey === seriesKey)[0]
140
+ const seriesObj = config.runtime.series.filter(s => s.dataKey === seriesKey)[0]
129
141
  const position = seriesObj?.axis ? String(seriesObj.axis).toLowerCase() : 'left'
130
142
  return position
131
143
  }
@@ -178,7 +190,12 @@ export const useTooltip = props => {
178
190
  if (visualizationType !== 'Pie' && visualizationType !== 'Forest Plot' && !config.tooltips.singleSeries) {
179
191
  tooltipItems.push(
180
192
  ...getIncludedTooltipSeries()
181
- ?.filter(seriesKey => config.series?.find(item => item.dataKey === seriesKey && item?.tooltip) || config.xAxis?.dataKey == seriesKey || visualizationType === 'Forecasting')
193
+ ?.filter(
194
+ seriesKey =>
195
+ config.runtime.series?.find(item => item.dataKey === seriesKey && item?.tooltip) ||
196
+ config.xAxis?.dataKey == seriesKey ||
197
+ visualizationType === 'Forecasting'
198
+ )
182
199
  ?.flatMap(seriesKey => {
183
200
  const value = resolvedScaleValues[0]?.[seriesKey]
184
201
  const formattedValue = getFormattedValue(seriesKey, value, config, getAxisPosition)
@@ -275,7 +292,10 @@ export const useTooltip = props => {
275
292
  return closestX
276
293
  }
277
294
 
278
- if (config.xAxis.type === 'categorical' || (visualizationType === 'Combo' && orientation !== 'horizontal' && visualizationType !== 'Forest Plot')) {
295
+ if (
296
+ config.xAxis.type === 'categorical' ||
297
+ (visualizationType === 'Combo' && orientation !== 'horizontal' && visualizationType !== 'Forest Plot')
298
+ ) {
279
299
  let range = xScale.range()[1] - xScale.range()[0]
280
300
  let eachBand = range / (xScale.domain().length + 1)
281
301
 
@@ -323,6 +343,7 @@ export const useTooltip = props => {
323
343
  // Get the closest x axis value from the pointer.
324
344
  // After getting the closest value, return the data entry with that x scale value.
325
345
  // Pass the config.visual uid (not uuid) along with that data entry to setSharedFilters
346
+ if (config.visualizationType === 'Bump Chart') return
326
347
  const eventSvgCoords = localPoint(e)
327
348
  const { x } = eventSvgCoords
328
349
  if (!x) throw new Error('COVE: no x value in handleTooltipClick.')
@@ -392,7 +413,7 @@ export const useTooltip = props => {
392
413
 
393
414
  // loop through series for items to add to tooltip.
394
415
  // there is probably a better way of doing this.
395
- config.series?.forEach(s => {
416
+ config.runtime.series?.forEach(s => {
396
417
  if (s.type === 'Forecasting') {
397
418
  stageColumns.push(s.stageColumn)
398
419
 
@@ -420,7 +441,10 @@ export const useTooltip = props => {
420
441
  standardLoopItems = [runtime.xAxis.dataKey, ...runtime?.seriesKeys]
421
442
  break
422
443
  case 'Bar':
423
- standardLoopItems = orientation === 'vertical' ? [runtime.xAxis.dataKey, ...runtime?.seriesKeys] : [runtime.yAxis.dataKey, ...runtime?.seriesKeys]
444
+ standardLoopItems =
445
+ orientation === 'vertical'
446
+ ? [runtime.xAxis.dataKey, ...runtime?.seriesKeys]
447
+ : [runtime.yAxis.dataKey, ...runtime?.seriesKeys]
424
448
  break
425
449
  case 'Pie':
426
450
  standardLoopItems = [runtime.xAxis.dataKey, ...runtime?.seriesKeys]
@@ -430,7 +454,13 @@ export const useTooltip = props => {
430
454
  }
431
455
 
432
456
  if (config.dashboard) {
433
- standardLoopItems = [runtime.xAxis.dataKey, ...runtime?.barSeriesKeys, ...runtime?.lineSeriesKeys, ...stageColumns, ...ciItems]
457
+ standardLoopItems = [
458
+ runtime.xAxis.dataKey,
459
+ ...runtime?.barSeriesKeys,
460
+ ...runtime?.lineSeriesKeys,
461
+ ...stageColumns,
462
+ ...ciItems
463
+ ]
434
464
  }
435
465
 
436
466
  return standardLoopItems
@@ -463,7 +493,7 @@ export const useTooltip = props => {
463
493
  * @returns user defined series name.
464
494
  */
465
495
  const getSeriesNameFromLabel = originalColumnName => {
466
- let series = config.series.filter(s => s.dataKey === originalColumnName)
496
+ let series = config.runtime.series.filter(s => s.dataKey === originalColumnName)
467
497
  if (series[0]?.name) return series[0]?.name
468
498
  return originalColumnName
469
499
  }
@@ -473,18 +503,51 @@ export const useTooltip = props => {
473
503
  const [key, value, axisPosition] = additionalData
474
504
 
475
505
  if (visualizationType === 'Forest Plot') {
476
- if (key === config.xAxis.dataKey) return <li className='tooltip-heading'>{`${capitalize(config.xAxis.dataKey ? `${config.xAxis.dataKey}: ` : '')} ${isDateScale(yAxis) ? formatDate(parseDate(key, false)) : value}`}</li>
506
+ if (key === config.xAxis.dataKey)
507
+ return (
508
+ <li className='tooltip-heading'>{`${capitalize(config.xAxis.dataKey ? `${config.xAxis.dataKey}: ` : '')} ${
509
+ isDateScale(yAxis) ? formatDate(parseDate(key, false)) : value
510
+ }`}</li>
511
+ )
477
512
  return <li className='tooltip-body'>{`${getSeriesNameFromLabel(key)}: ${formatNumber(value, 'left')}`}</li>
478
513
  }
479
- const formattedDate = config.tooltips.dateDisplayFormat ? formatTooltipsDate(parseDate(value, false)) : formatDate(parseDate(value, false))
514
+ const formattedDate = config.tooltips.dateDisplayFormat
515
+ ? formatTooltipsDate(parseDate(value, false))
516
+ : formatDate(parseDate(value, false))
480
517
 
481
518
  // TOOLTIP HEADING
482
- if (visualizationType === 'Bar' && orientation === 'horizontal' && key === config.xAxis.dataKey) return <li className='tooltip-heading'>{`${capitalize(config.runtime.yAxis.label ? `${config.runtime.yAxis.label}: ` : '')} ${config.xAxis.type === 'date' ? formattedDate : value}`}</li>
483
-
484
- if (key === config.xAxis.dataKey) return <li className='tooltip-heading'>{`${capitalize(config.runtime.xAxis.label ? `${config.runtime.xAxis.label}: ` : '')} ${isDateScale(xAxis) ? formattedDate : value}`}</li>
519
+ if (visualizationType === 'Bar' && orientation === 'horizontal' && key === config.xAxis.dataKey)
520
+ return (
521
+ <li className='tooltip-heading'>{`${capitalize(
522
+ config.runtime.yAxis.label ? `${config.runtime.yAxis.label}: ` : ''
523
+ )} ${config.xAxis.type === 'date' ? formattedDate : value}`}</li>
524
+ )
525
+
526
+ if (key === config.xAxis.dataKey)
527
+ return (
528
+ <li className='tooltip-heading'>{`${capitalize(
529
+ config.runtime.xAxis.label ? `${config.runtime.xAxis.label}: ` : ''
530
+ )} ${isDateScale(xAxis) ? formattedDate : value}`}</li>
531
+ )
485
532
 
486
533
  // TOOLTIP BODY
487
- return <li className='tooltip-body'>{`${getSeriesNameFromLabel(key)}: ${value}`}</li>
534
+ // handle suppressed tooltip items
535
+ const { label, displayGray } =
536
+ (config.visualizationSubType !== 'stacked' &&
537
+ config.general.showSuppressedSymbol &&
538
+ config.preliminaryData?.find(
539
+ pd =>
540
+ pd.label &&
541
+ pd.type === 'suppression' &&
542
+ pd.displayTooltip &&
543
+ value === pd.value &&
544
+ (!pd.column || key === pd.column)
545
+ )) ||
546
+ {}
547
+ const newValue = label || value
548
+ const style = displayGray ? { color: '#8b8b8a' } : {}
549
+
550
+ return <li style={style} className='tooltip-body'>{`${getSeriesNameFromLabel(key)}: ${newValue}`}</li>
488
551
  }
489
552
 
490
553
  return {
@@ -1,6 +1,7 @@
1
1
  @include breakpointClass(md) {
2
2
  .data-table-container {
3
- margin: 5px 1em;
3
+ margin: 5px 0em;
4
+ width: 100%;
4
5
  }
5
6
  }
6
7
 
@@ -24,6 +24,28 @@
24
24
  .cdc-open-viz-module.type-chart {
25
25
  @import 'DataTable';
26
26
 
27
+ .legend-top {
28
+ .legend-wrapper .tooltip-boundary {
29
+ display: flex;
30
+ flex-wrap: wrap;
31
+ order: 2;
32
+ aside {
33
+ width: 100%;
34
+ order: 1;
35
+ }
36
+ }
37
+ }
38
+
39
+ .legend-bottom {
40
+ .legend-wrapper {
41
+ display: flex;
42
+ flex-wrap: wrap;
43
+ aside {
44
+ width: 100%;
45
+ }
46
+ }
47
+ }
48
+
27
49
  &.isEditor .cdc-chart-inner-container {
28
50
  background: white;
29
51
  }
@@ -90,7 +112,6 @@
90
112
  .subtext,
91
113
  .subtext--responsive-ticks,
92
114
  .section-subtext {
93
- padding: 0 1rem;
94
115
  &--brush-active {
95
116
  margin-top: 2.5em;
96
117
  }
@@ -109,15 +130,20 @@
109
130
  vertical-align: top;
110
131
  text-align: left;
111
132
  border: 1px solid $lightGray;
112
- order: 1;
113
133
  position: relative;
114
134
 
135
+ &.no-border {
136
+ border: 1px solid transparent;
137
+ }
138
+
115
139
  &__inner {
116
- &.bottom {
140
+ &.double-column,
141
+ &.single-row {
117
142
  display: grid;
118
143
  grid-template-columns: 1fr 1fr;
119
144
  grid-column-gap: 1.5em;
120
145
  }
146
+
121
147
  &.vertical-sorted {
122
148
  display: block;
123
149
 
@@ -151,6 +177,10 @@
151
177
  white-space: pre-wrap;
152
178
  word-break: break-word;
153
179
  }
180
+
181
+ & > :first-child {
182
+ margin-top: 3px;
183
+ }
154
184
  }
155
185
 
156
186
  .vertical-sorted:not(.single-row) .legend-item {
@@ -189,6 +219,23 @@
189
219
  transition: 0.2s all;
190
220
  }
191
221
  }
222
+
223
+ &__outer {
224
+ &.definition-link {
225
+ display: flex;
226
+ flex-direction: row;
227
+ position: absolute;
228
+ left: 0%;
229
+ top: 108%;
230
+ & > * {
231
+ margin: 0;
232
+ }
233
+ & > p,
234
+ a {
235
+ margin-left: 5px;
236
+ }
237
+ }
238
+ }
192
239
  }
193
240
 
194
241
  .dynamic-legend-list {
@@ -272,7 +319,61 @@
272
319
  display: flex;
273
320
  align-items: flex-start;
274
321
  flex-wrap: wrap;
322
+ justify-content: space-between;
323
+
324
+ &.legend-top:not(.legend-hidden) {
325
+ .legend-wrapper {
326
+ & > div {
327
+ order: 2;
328
+ width: 100%;
329
+ }
330
+ aside {
331
+ width: 100%;
332
+ order: 1;
333
+ height: fit-content;
334
+ }
335
+ }
336
+ }
275
337
 
338
+ &.legend-left:not(.legend-hidden) {
339
+ .legend-wrapper {
340
+ & > div {
341
+ order: 2;
342
+ width: 75%;
343
+ }
344
+ aside {
345
+ width: 25%;
346
+ order: 1;
347
+ height: fit-content;
348
+ }
349
+ }
350
+ }
351
+
352
+ &.legend-right:not(.legend-hidden) {
353
+ .legend-wrapper {
354
+ & > div {
355
+ order: 1;
356
+ width: 75%;
357
+ }
358
+ aside {
359
+ width: 25%;
360
+ height: fit-content;
361
+ order: 2;
362
+ }
363
+ }
364
+ }
365
+
366
+ &.left {
367
+ display: flex;
368
+ flex-direction: row-reverse;
369
+ }
370
+ &.top {
371
+ flex-wrap: nowrap;
372
+ flex-direction: column-reverse;
373
+ & > div.tooltip-boundary {
374
+ margin-top: 1.5em;
375
+ }
376
+ }
276
377
  &.bottom {
277
378
  flex-wrap: nowrap;
278
379
  flex-direction: column;
@@ -422,15 +523,7 @@
422
523
  }
423
524
 
424
525
  @include breakpointClass(md) {
425
- .filters-section,
426
- .chart-container:not(.sparkline) {
427
- margin-left: 1em;
428
- margin-right: 1em;
429
- }
430
-
431
526
  .chart-container {
432
- flex-wrap: nowrap;
433
-
434
527
  .no-wrap {
435
528
  flex-wrap: nowrap;
436
529
  }
@@ -438,14 +531,15 @@
438
531
  .legend-container {
439
532
  width: 25%;
440
533
  margin-left: 1em;
441
- order: 2;
534
+ height: fit-content;
442
535
 
443
536
  &.left {
444
537
  margin-left: 0;
445
538
  margin-right: 1em;
446
539
  order: 0;
447
540
  }
448
- &.bottom {
541
+ &.bottom,
542
+ &.top {
449
543
  width: 100%;
450
544
  margin-left: 0;
451
545
  }
@@ -709,7 +803,6 @@
709
803
  .subtext,
710
804
  .subtext--responsive-ticks {
711
805
  margin-top: 0px;
712
- padding: 0 1rem;
713
806
  }
714
807
 
715
808
  .isEditor {
@@ -8,16 +8,34 @@ import { Table } from '@cdc/core/types/Table'
8
8
  import { BoxPlot } from '@cdc/core/types/BoxPlot'
9
9
  import { General } from '@cdc/core/types/General'
10
10
  import { type Link } from './../components/Sankey/types'
11
- import { Legend } from '@cdc/core/types/Legend'
12
11
  import { ConfidenceInterval } from '@cdc/core/types/ConfidenceInterval'
13
12
  import { Region } from '@cdc/core/types/Region'
14
- import { type PreliminaryDataItem } from '../components/LineChart/LineChartProps'
13
+
15
14
  import { VizFilter } from '@cdc/core/types/VizFilter'
16
15
  import { type Annotation } from '@cdc/core/types/Annotation'
17
16
 
18
- export type ViewportSize = 'sm' | 'xs' | 'xxs' | 'lg'
17
+ export type ViewportSize = 'xxs' | 'xs' | 'sm' | 'md' | 'lg'
19
18
  export type ChartColumns = Record<string, Column>
20
19
 
20
+ export interface PreliminaryDataItem {
21
+ column: string
22
+ displayLegend: boolean
23
+ displayTable: boolean
24
+ displayTooltip: boolean
25
+ iconCode: string
26
+ label: string
27
+ lineCode: string
28
+ seriesKey: string
29
+ style: string
30
+ symbol: string
31
+ type: 'effect' | 'suppression'
32
+ value: string
33
+ hideBarSymbol: boolean
34
+ hideLineStyle: boolean
35
+ circleSize: number
36
+ displayGray: boolean
37
+ }
38
+
21
39
  type DataFormat = {
22
40
  abbreviated: boolean
23
41
  bottomAbbreviated: boolean
@@ -54,12 +72,20 @@ export type Legend = {
54
72
  hide: boolean
55
73
  highlightOnHover: boolean
56
74
  label: string
57
- lineMode: boolean
58
- position: string
75
+ position: 'left' | 'bottom' | 'top' | 'right'
59
76
  reverseLabelOrder: boolean
60
77
  singleRow: boolean
61
78
  type: string
62
79
  verticalSorted: boolean
80
+ hideSuppressionLink:boolean
81
+ style:'circles'|'boxes'|'gradient'|'lines'
82
+ subStyle:'linear blocks'|'smooth'
83
+ hideSuppressedLabels:boolean
84
+ tickRotation:string
85
+ hideBorder:{
86
+ side:boolean
87
+ topBottom:boolean
88
+ }
63
89
  }
64
90
 
65
91
  type Visual = {
@@ -79,7 +105,7 @@ export type AllChartsConfig = {
79
105
  barHasBorder: 'true' | 'false'
80
106
  barHeight: number
81
107
  barSpace: number
82
- barStyle: string
108
+ barStyle: 'lollipop'|'rounded'|'flat'
83
109
  barThickness: number
84
110
  boxplot: BoxPlot
85
111
  brush: {
@@ -109,6 +135,7 @@ export type AllChartsConfig = {
109
135
  formattedData: Object[] & { urlFiltered: boolean }
110
136
  heights: {
111
137
  vertical: number
138
+ mobileVertical: number
112
139
  }
113
140
  highlightedBarValues: { value: any; color: string; borderWidth: number; legendLabel: string }[]
114
141
  introText: string
@@ -152,10 +179,9 @@ export type AllChartsConfig = {
152
179
  topAxis: { hasLine: boolean }
153
180
  twoColor: { palette: string }
154
181
  type: 'chart' | 'dashboard'
155
- useLogScale: boolean
156
182
  uid: string | number
157
183
  visual: Visual
158
- visualizationType: 'Area Chart' | 'Bar' | 'Box Plot' | 'Deviation Bar' | 'Forest Plot' | 'Line' | 'Paired Bar' | 'Pie' | 'Scatter Plot' | 'Spark Line' | 'Combo' | 'Forecasting' | 'Sankey'
184
+ visualizationType: 'Area Chart' | 'Bar' | 'Box Plot' | 'Deviation Bar' | 'Forest Plot' | 'Line' | 'Paired Bar' | 'Pie' | 'Scatter Plot' | 'Spark Line' | 'Combo' | 'Forecasting' | 'Sankey' | 'Bump Chart'
159
185
  visualizationSubType: string
160
186
  xAxis: Axis
161
187
  yAxis: Axis
@@ -2,6 +2,7 @@ import { type ChartConfig } from './ChartConfig'
2
2
  import { PickD3Scale } from '@visx/scale'
3
3
  import { type SharedFilter } from '@cdc/dashboard/src/types/SharedFilter'
4
4
  import { type Annotation } from '@cdc/core/types/Annotation'
5
+ import { DimensionsType } from '@cdc/core/types/Dimensions'
5
6
 
6
7
  export type ColorScale = PickD3Scale<'ordinal', any, any>
7
8
 
@@ -16,12 +17,12 @@ type SharedChartContext = {
16
17
  handleChartAriaLabels: (config: any) => string
17
18
  colorScale?: ColorScale
18
19
  config: ChartConfig
19
- currentViewport?: string
20
+ currentViewport?: 'lg' | 'md' | 'sm' | 'xs' | 'xxs'
20
21
  highlight?: Function
21
22
  highlightReset?: Function
22
23
  legendIsolateValues?: string[]
23
24
  setLegendIsolateValues?: Function
24
- getTextWidth?: () => string | number
25
+ getTextWidth?: (a: string, b: string) => string
25
26
  brushConfig: { data: []; isBrushing: boolean; isActive: boolean }
26
27
  setBrushConfig: Function
27
28
  clean: Function
@@ -37,7 +38,7 @@ type SharedChartContext = {
37
38
  // Line Chart Specific Context
38
39
  type LineChartContext = SharedChartContext & {
39
40
  convertLineToBarGraph: boolean
40
- dimensions: [screenWidth: number, screenHeight: number]
41
+ dimensions: DimensionsType
41
42
  formatDate: Function
42
43
  formatTooltipsDate: Function
43
44
  formatNumber: Function
@@ -59,7 +60,7 @@ export type ChartContext =
59
60
  | LineChartContext
60
61
  | (SharedChartContext & {
61
62
  annotations: Annotation[]
62
- dimensions: [screenWidth: number, screenHeight: number]
63
+ dimensions: DimensionsType
63
64
  formatDate?: Function
64
65
  formatTooltipsDate: Function
65
66
  formatNumber?: Function