@cdc/chart 4.23.10 → 4.24.1

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 (125) hide show
  1. package/dist/cdcchart.js +34606 -32218
  2. package/examples/feature/bar/additional-column-tooltip.json +446 -0
  3. package/examples/feature/bar/example-bar-chart.json +1 -46
  4. package/examples/feature/bar/lollipop.json +156 -0
  5. package/examples/feature/bar/tall-data.json +98 -0
  6. package/examples/feature/combo/planet-combo-example-config.json +99 -9
  7. package/examples/feature/dev-4261.json +399 -0
  8. package/examples/feature/forest-plot/forest-plot.json +63 -19
  9. package/examples/feature/forest-plot/{broken.json → linear.json} +77 -23
  10. package/examples/feature/forest-plot/log.json +26 -0
  11. package/examples/feature/forest-plot/logarithmic.json +271 -0
  12. package/examples/feature/line/line-chart-preliminary.json +346 -0
  13. package/examples/feature/line/line-points.json +340 -0
  14. package/examples/feature/regions/index.json +462 -0
  15. package/examples/feature/scatterplot/scatterplot.json +272 -33
  16. package/examples/gallery/bar-chart-vertical/combo-line-chart.json +181 -48
  17. package/examples/private/chart-t.json +3740 -0
  18. package/examples/private/combo.json +369 -0
  19. package/examples/private/epi-data.csv +13 -0
  20. package/examples/private/epi-data.json +62 -0
  21. package/examples/private/epi.json +403 -0
  22. package/examples/private/occupancy.json +109283 -0
  23. package/examples/private/prod-line-config.json +401 -0
  24. package/examples/private/region-data.json +822 -0
  25. package/examples/private/region-testing.json +312 -0
  26. package/examples/private/scaling.json +45325 -0
  27. package/examples/private/testing-data.json +1739 -0
  28. package/examples/private/testing.json +816 -0
  29. package/examples/sparkline-multilple.json +846 -0
  30. package/index.html +12 -8
  31. package/package.json +3 -3
  32. package/src/CdcChart.tsx +42 -211
  33. package/src/ConfigContext.tsx +6 -0
  34. package/src/_stories/Chart.stories.tsx +188 -0
  35. package/src/_stories/Chart.tooltip.stories.tsx +305 -0
  36. package/src/_stories/ChartBrush.stories.tsx +19 -0
  37. package/src/_stories/ChartEditor.stories.tsx +22 -0
  38. package/src/_stories/ChartLine.preliminary.tsx +19 -0
  39. package/src/_stories/ChartSuppress.stories.tsx +19 -0
  40. package/src/_stories/_mock/brush_mock.json +393 -0
  41. package/src/_stories/_mock/pie_config.json +191 -0
  42. package/src/_stories/_mock/pie_data.json +218 -0
  43. package/src/_stories/_mock/preliminary_mock.json +346 -0
  44. package/src/_stories/_mock/suppress_mock.json +911 -0
  45. package/src/components/{AreaChart.Stacked.jsx → AreaChart/components/AreaChart.Stacked.jsx} +6 -7
  46. package/src/components/{AreaChart.jsx → AreaChart/components/AreaChart.jsx} +7 -36
  47. package/src/components/AreaChart/index.tsx +4 -0
  48. package/src/components/{BarChart.Horizontal.jsx → BarChart/components/BarChart.Horizontal.tsx} +111 -34
  49. package/src/components/{BarChart.StackedHorizontal.jsx → BarChart/components/BarChart.StackedHorizontal.tsx} +55 -20
  50. package/src/components/BarChart/components/BarChart.StackedVertical.tsx +106 -0
  51. package/src/components/{BarChart.Vertical.jsx → BarChart/components/BarChart.Vertical.tsx} +162 -34
  52. package/src/components/BarChart/components/BarChart.jsx +39 -0
  53. package/src/components/{BarChartType.jsx → BarChart/components/BarChartType.jsx} +0 -2
  54. package/src/components/BarChart/components/context.tsx +13 -0
  55. package/src/components/BarChart/index.tsx +3 -0
  56. package/src/components/{BoxPlot.jsx → BoxPlot/BoxPlot.jsx} +1 -1
  57. package/src/components/BoxPlot/index.tsx +3 -0
  58. package/src/components/DeviationBar.jsx +4 -3
  59. package/src/components/{EditorPanel.jsx → EditorPanel/EditorPanel.tsx} +807 -865
  60. package/src/components/EditorPanel/components/Panel.DateHighlighting.tsx +109 -0
  61. package/src/components/{ForestPlotSettings.jsx → EditorPanel/components/Panel.ForestPlotSettings.tsx} +190 -220
  62. package/src/components/EditorPanel/components/Panel.Regions.tsx +168 -0
  63. package/src/components/{Series.jsx → EditorPanel/components/Panel.Series.tsx} +23 -4
  64. package/src/components/EditorPanel/components/PanelProps.ts +3 -0
  65. package/src/components/EditorPanel/components/Panels.tsx +13 -0
  66. package/src/components/EditorPanel/components/panels.scss +72 -0
  67. package/src/components/EditorPanel/editor-panel.scss +751 -0
  68. package/src/components/EditorPanel/index.tsx +3 -0
  69. package/src/{hooks → components/EditorPanel}/useEditorPermissions.js +50 -5
  70. package/src/components/{Forecasting.jsx → Forecasting/Forecasting.jsx} +1 -1
  71. package/src/components/Forecasting/index.tsx +3 -0
  72. package/src/components/ForestPlot/ForestPlot.tsx +254 -0
  73. package/src/components/ForestPlot/ForestPlotProps.ts +18 -0
  74. package/src/components/ForestPlot/index.scss +1 -0
  75. package/src/components/ForestPlot/index.tsx +3 -0
  76. package/src/components/Legend/Legend.tsx +347 -0
  77. package/src/components/Legend/index.tsx +3 -0
  78. package/src/components/LineChart/LineChartProps.ts +46 -0
  79. package/src/components/{LineChart.Circle.tsx → LineChart/components/LineChart.Circle.tsx} +36 -30
  80. package/src/components/LineChart/helpers.ts +45 -0
  81. package/src/components/LineChart/index.scss +1 -0
  82. package/src/components/{LineChart.tsx → LineChart/index.tsx} +83 -42
  83. package/src/components/LinearChart.jsx +125 -82
  84. package/src/components/PairedBarChart.jsx +2 -2
  85. package/src/components/{PieChart.jsx → PieChart/PieChart.tsx} +16 -7
  86. package/src/components/PieChart/index.tsx +3 -0
  87. package/src/components/Regions/components/Regions.tsx +135 -0
  88. package/src/components/Regions/index.tsx +3 -0
  89. package/src/components/{ScatterPlot.jsx → ScatterPlot/ScatterPlot.jsx} +3 -3
  90. package/src/components/ScatterPlot/index.tsx +3 -0
  91. package/src/components/{SparkLine.jsx → Sparkline/SparkLine.jsx} +2 -2
  92. package/src/components/Sparkline/index.tsx +3 -0
  93. package/src/components/ZoomBrush.tsx +168 -0
  94. package/src/data/initial-state.js +30 -16
  95. package/src/helpers/abbreviateNumber.ts +17 -0
  96. package/src/helpers/computeMarginBottom.ts +55 -0
  97. package/src/helpers/filterData.ts +18 -0
  98. package/src/helpers/generateColorsArray.ts +8 -0
  99. package/src/helpers/getQuartiles.ts +30 -0
  100. package/src/helpers/handleChartAriaLabels.ts +19 -0
  101. package/src/helpers/handleLineType.ts +18 -0
  102. package/src/helpers/lineOptions.ts +18 -0
  103. package/src/helpers/sort.ts +7 -0
  104. package/src/helpers/tests/computeMarginBottom.test.ts +20 -0
  105. package/src/hooks/useBarChart.js +72 -7
  106. package/src/hooks/useColorScale.ts +50 -0
  107. package/src/hooks/{useMinMax.js → useMinMax.ts} +75 -23
  108. package/src/hooks/{useRightAxis.js → useRightAxis.ts} +10 -2
  109. package/src/hooks/{useScales.js → useScales.ts} +64 -17
  110. package/src/hooks/{useTooltip.jsx → useTooltip.tsx} +84 -55
  111. package/src/scss/main.scss +70 -38
  112. package/src/types/ChartConfig.ts +178 -0
  113. package/src/types/ChartContext.ts +54 -0
  114. package/src/types/ForestPlot.ts +53 -0
  115. package/examples/feature/scatterplot/scatterplot-continuous.csv +0 -17
  116. package/src/ConfigContext.jsx +0 -5
  117. package/src/components/BarChart.StackedVertical.jsx +0 -95
  118. package/src/components/BarChart.jsx +0 -30
  119. package/src/components/ForestPlot.jsx +0 -191
  120. package/src/components/Legend.jsx +0 -277
  121. package/src/scss/LinearChart.scss +0 -0
  122. package/src/scss/editor-panel.scss +0 -745
  123. package/src/scss/legend.scss +0 -206
  124. package/src/scss/mixins.scss +0 -0
  125. package/src/scss/variables.scss +0 -1
@@ -1,20 +1,69 @@
1
- import React, { useContext } from 'react'
2
- import ConfigContext from '../ConfigContext'
3
- import { useBarChart } from '../hooks/useBarChart'
1
+ import React, { useContext, useState } from 'react'
2
+ import ConfigContext from '../../../ConfigContext'
3
+ import { type ChartContext } from '../../../types/ChartContext'
4
+ import { useBarChart } from '../../../hooks/useBarChart'
4
5
  import { Group } from '@visx/group'
5
6
  import { Text } from '@visx/text'
6
7
  import { BarGroup } from '@visx/shape'
7
- import { useHighlightedBars } from '../hooks/useHighlightedBars'
8
+ import { useHighlightedBars } from '../../../hooks/useHighlightedBars'
9
+ import { FaStar } from 'react-icons/fa'
10
+ import Regions from './../../Regions'
8
11
 
9
12
  // third party
10
13
  import chroma from 'chroma-js'
14
+ import BarChartContext, { type BarChartContextValues } from './context'
15
+
16
+ export const BarChartVertical = () => {
17
+ const { xScale, yScale, xMax, yMax, seriesScale } = useContext<BarChartContextValues>(BarChartContext)
18
+
19
+ const [barWidth, setBarWidth] = useState(0)
20
+ const [totalBarsInGroup, setTotalBarsInGroup] = useState(0)
21
+
22
+ // prettier-ignore
23
+ const {
24
+ applyRadius,
25
+ assignColorsToValues,
26
+ barBorderWidth,
27
+ generateIconSize,
28
+ getAdditionalColumn,
29
+ getHighlightedBarByValue,
30
+ getHighlightedBarColorByValue,
31
+ lollipopBarWidth,
32
+ lollipopShapeSize,
33
+ onMouseLeaveBar,
34
+ onMouseOverBar,
35
+ section
36
+ } = useBarChart()
37
+
38
+ // prettier-ignore
39
+ const {
40
+ colorScale,
41
+ config,
42
+ dashboardConfig,
43
+ formatDate,
44
+ formatNumber,
45
+ getXAxisData,
46
+ getYAxisData,
47
+ isNumber,
48
+ parseDate,
49
+ seriesHighlight,
50
+ setSharedFilter,
51
+ transformedData,
52
+ } = useContext<ChartContext>(ConfigContext)
11
53
 
12
- export const BarChartVertical = props => {
13
- const { xScale, yScale, xMax, yMax, seriesScale } = props
14
- const { transformedData: data, colorScale, seriesHighlight, config, formatNumber, formatDate, parseDate, setSharedFilter, isNumber, getXAxisData, getYAxisData } = useContext(ConfigContext)
15
- const { barBorderWidth, hasMultipleSeries, applyRadius, updateBars, assignColorsToValues, section, lollipopBarWidth, lollipopShapeSize, getHighlightedBarColorByValue, getHighlightedBarByValue } = useBarChart()
16
54
  const { HighLightedBarUtils } = useHighlightedBars(config)
55
+ const data = config.brush.active && config.brush.data?.length ? config.brush.data : transformedData
17
56
 
57
+ const getIcon = (bar, barWidth) => {
58
+ let icon = null
59
+ const iconSize = generateIconSize(barWidth)
60
+ config.suppressedData?.forEach(d => {
61
+ if (bar.key === d.column && String(bar.value) === String(d.value) && d.icon) {
62
+ icon = <FaStar color='#000' size={iconSize} />
63
+ }
64
+ })
65
+ return icon
66
+ }
18
67
  return (
19
68
  config.visualizationSubType !== 'stacked' &&
20
69
  (config.visualizationType === 'Bar' || config.visualizationType === 'Combo') &&
@@ -33,16 +82,20 @@ export const BarChartVertical = props => {
33
82
  }}
34
83
  >
35
84
  {barGroups => {
36
- return updateBars(barGroups).map((barGroup, index) => (
85
+ return barGroups.map((barGroup, index) => (
37
86
  <Group className={`bar-group-${barGroup.index}-${barGroup.x0}--${index} ${config.orientation}`} key={`bar-group-${barGroup.index}-${barGroup.x0}--${index}`} id={`bar-group-${barGroup.index}-${barGroup.x0}--${index}`} left={(xMax / barGroups.length) * barGroup.index}>
38
87
  {barGroup.bars.map((bar, index) => {
39
88
  const scaleVal = config.useLogScale ? 0.1 : 0
89
+ const suppresedBarHeight = 20
40
90
  let highlightedBarValues = config.highlightedBarValues.map(item => item.value).filter(item => item !== ('' || undefined))
41
91
  highlightedBarValues = config.xAxis.type === 'date' ? HighLightedBarUtils.formatDates(highlightedBarValues) : highlightedBarValues
42
92
  let transparentBar = config.legend.behavior === 'highlight' && seriesHighlight.length > 0 && seriesHighlight.indexOf(bar.key) === -1
43
93
  let displayBar = config.legend.behavior === 'highlight' || seriesHighlight.length === 0 || seriesHighlight.indexOf(bar.key) !== -1
44
- let barHeight = Math.abs(yScale(bar.value) - yScale(scaleVal))
45
- let barY = bar.value >= 0 && isNumber(bar.value) ? bar.y : yScale(0)
94
+ let barHeightBase = Math.abs(yScale(bar.value) - yScale(scaleVal))
95
+ let barYBase = bar.value >= 0 && isNumber(bar.value) ? bar.y : yScale(0)
96
+ const supprssedBarY = bar.value >= 0 && isNumber(bar.value) ? yScale(scaleVal) - suppresedBarHeight : yScale(0)
97
+ const barY = config.suppressedData.some(d => bar.key === d.column && String(bar.value) === String(d.value)) ? supprssedBarY : barYBase
98
+
46
99
  let barGroupWidth = (xMax / barGroups.length) * (config.barThickness || 0.8)
47
100
  let offset = ((xMax / barGroups.length) * (1 - (config.barThickness || 0.8))) / 2
48
101
  // configure left side offset of lollipop bars
@@ -51,6 +104,8 @@ export const BarChartVertical = props => {
51
104
  }
52
105
 
53
106
  let barWidth = config.isLollipopChart ? lollipopBarWidth : barGroupWidth / barGroup.bars.length
107
+ setBarWidth(barWidth)
108
+ setTotalBarsInGroup(barGroup.bars.length)
54
109
 
55
110
  let yAxisValue = formatNumber(bar.value, 'left')
56
111
  let xAxisValue = config.runtime[section].type === 'date' ? formatDate(parseDate(data[barGroup.index][config.runtime.originalXAxis.dataKey])) : data[barGroup.index][config.runtime.originalXAxis.dataKey]
@@ -58,18 +113,16 @@ export const BarChartVertical = props => {
58
113
  // create new Index for bars with negative values
59
114
  const newIndex = bar.value < 0 ? -1 : index
60
115
  const borderRadius = applyRadius(newIndex)
116
+ // tooltips
61
117
 
62
- let yAxisTooltip = config.runtime.yAxis.label ? `${config.runtime.yAxis.label}: ${yAxisValue}` : yAxisValue
118
+ const additionalColTooltip = getAdditionalColumn(bar.key, data[barGroup.index][config.runtime.originalXAxis.dataKey])
63
119
  let xAxisTooltip = config.runtime.xAxis.label ? `${config.runtime.xAxis.label}: ${xAxisValue}` : xAxisValue
64
-
65
- if (!hasMultipleSeries) {
66
- yAxisTooltip = config.isLegendValue ? `${bar.key}: ${yAxisValue}` : config.runtime.yAxis.label ? `${config.runtime.yAxis.label}: ${yAxisValue}` : yAxisValue
67
- }
120
+ const tooltipBody = `${config.runtime.seriesLabels[bar.key]}: ${yAxisValue}`
68
121
 
69
122
  const tooltip = `<ul>
70
- ${config.legend.showLegendValuesTooltip && config.runtime.seriesLabels && hasMultipleSeries ? `${config.runtime.seriesLabels[bar.key] || ''}<br/>` : ''}
71
- <li class="tooltip-heading">${yAxisTooltip}</li>
72
- <li class="tooltip-body">${xAxisTooltip}</li>
123
+ <li class="tooltip-heading">${xAxisTooltip}</li>
124
+ <li class="tooltip-body ">${tooltipBody}</li>
125
+ ${additionalColTooltip ? '<li class="tooltip-body ">' + additionalColTooltip + '</li>' : ''}
73
126
  </li></ul>`
74
127
 
75
128
  // configure colors
@@ -84,19 +137,76 @@ export const BarChartVertical = props => {
84
137
  const highlightedBar = getHighlightedBarByValue(xAxisValue)
85
138
  const borderColor = isHighlightedBar ? highlightedBarColor : config.barHasBorder === 'true' ? '#000' : 'transparent'
86
139
  const borderWidth = isHighlightedBar ? highlightedBar.borderWidth : config.isLollipopChart ? 0 : config.barHasBorder === 'true' ? barBorderWidth : 0
140
+ const barValueLabel = config.suppressedData.some(d => bar.key === d.column && bar.value === d.value) ? '' : yAxisValue
141
+ let barHeight = config.suppressedData.some(d => bar.key === d.column && String(bar.value) === String(d.value)) ? suppresedBarHeight : barHeightBase
142
+ const displaylollipopShape = config.suppressedData.some(d => bar.key === d.column && bar.value === d.value) ? 'none' : 'block'
143
+
144
+ const getBarBackgroundColor = (barColor: string, filteredOutColor?: string): string => {
145
+ let _barColor = barColor
146
+ let _filteredOutColor = filteredOutColor || '#f2f2f2'
147
+
148
+ /**
149
+ * If this is a dashboard using a setBy column on the bars
150
+ * color the bar that is using the filter with barColor and
151
+ * color the filteredOut (typically gray) bars with the filteredOutColor
152
+ */
153
+ if (dashboardConfig && dashboardConfig.dashboard.sharedFilters) {
154
+ const { sharedFilters } = dashboardConfig.dashboard
155
+
156
+ _barColor = sharedFilters.map(_sharedFilter => {
157
+ if (_sharedFilter.setBy === config.uid) {
158
+ // If the current filter is the reset filter item.
159
+ if (_sharedFilter.resetLabel === _sharedFilter.active) return barColor
160
+ // If the current filter is the bars
161
+ if (_sharedFilter.active === transformedData[barGroup.index][config.xAxis.dataKey]) return barColor
162
+ return _filteredOutColor
163
+ } else {
164
+ // If the setBy isn't the config.uid return the original barColor
165
+ return barColor
166
+ }
167
+ })[0]
168
+
169
+ if (isRegularLollipopColor) _barColor = barColor
170
+ if (isTwoToneLollipopColor) _barColor = chroma(barColor).brighten(1)
171
+ if (isHighlightedBar) _barColor = 'transparent'
172
+ return _barColor
173
+ }
87
174
 
88
- const background = () => {
89
- if (isRegularLollipopColor) return barColor
90
- if (isTwoToneLollipopColor) return chroma(barColor).brighten(1)
91
- if (isHighlightedBar) return 'transparent'
92
- return barColor
175
+ // if this is a two tone lollipop slightly lighten the bar.
176
+ if (isTwoToneLollipopColor) _barColor = chroma(barColor).brighten(1)
177
+
178
+ // if we're highlighting a bar make it invisible since it gets a border
179
+ if (isHighlightedBar) _barColor = 'transparent'
180
+ return _barColor
181
+ }
182
+
183
+ const getLeft = () => {
184
+ if (barWidth < 50 && barWidth > 15) return barWidth / 2.5
185
+ if (barWidth < 15 && barWidth > 5) return barWidth / 6
186
+ if (barWidth < 5) return 0
187
+ return barWidth / 2
93
188
  }
189
+ const iconStyle: { [key: string]: any } = {
190
+ position: 'absolute',
191
+ top: bar.value >= 0 && isNumber(bar.value) ? -suppresedBarHeight : undefined,
192
+ bottom: bar.value >= 0 && isNumber(bar.value) ? undefined : `-${suppresedBarHeight}px`,
193
+ left: getLeft()
194
+ }
195
+
196
+ if (config.isLollipopChart) {
197
+ iconStyle.left = 0
198
+ iconStyle.transform = `translateX(0)`
199
+ }
200
+
94
201
  const finalStyle = {
95
- background: background(),
202
+ background: getBarBackgroundColor(barColor),
96
203
  borderColor,
97
204
  borderStyle: 'solid',
98
- borderWidth,
99
- ...borderRadius
205
+ borderWidth: `${borderWidth}px`,
206
+ width: barWidth,
207
+ height: barHeight,
208
+ ...borderRadius,
209
+ cursor: dashboardConfig ? 'pointer' : 'default'
100
210
  }
101
211
 
102
212
  return (
@@ -104,22 +214,24 @@ export const BarChartVertical = props => {
104
214
  {/* This feels gross but inline transition was not working well*/}
105
215
  <style>
106
216
  {`
107
- .linear #barGroup${barGroup.index},
108
- .Combo #barGroup${barGroup.index} {
217
+ .linear #barGroup${barGroup.index} div,
218
+ .Combo #barGroup${barGroup.index} div {
109
219
  transform-origin: 0 ${barY + barHeight}px;
110
220
  }
111
221
  `}
112
222
  </style>
113
223
  <Group key={`bar-sub-group-${barGroup.index}-${barGroup.x0}-${barY}--${index}`}>
114
224
  <foreignObject
225
+ onMouseOver={() => onMouseOverBar(xAxisValue, bar.key)}
226
+ onMouseLeave={onMouseLeaveBar}
227
+ style={{ overflow: 'visible', transition: 'all 0.2s linear' }}
115
228
  id={`barGroup${barGroup.index}`}
116
229
  key={`bar-group-bar-${barGroup.index}-${bar.index}-${bar.value}-${bar.key}`}
117
230
  x={barWidth * bar.index + offset}
118
231
  y={barY}
119
232
  width={barWidth}
120
233
  height={barHeight}
121
- style={finalStyle}
122
- opacity={transparentBar ? 0.5 : 1}
234
+ opacity={transparentBar ? 0.2 : 1}
123
235
  display={displayBar ? 'block' : 'none'}
124
236
  data-tooltip-html={tooltip}
125
237
  data-tooltip-id={`cdc-open-viz-tooltip-${config.runtime.uniqueId}`}
@@ -130,14 +242,27 @@ export const BarChartVertical = props => {
130
242
  setSharedFilter(config.uid, bar)
131
243
  }
132
244
  }}
133
- ></foreignObject>
245
+ >
246
+ <div style={{ position: 'relative' }}>
247
+ <div style={iconStyle}>{getIcon(bar, barWidth)}</div>
248
+ <div style={{ ...finalStyle }}></div>
249
+ </div>
250
+ </foreignObject>
134
251
 
135
- <Text display={config.labels && displayBar ? 'block' : 'none'} opacity={transparentBar ? 0.5 : 1} x={barWidth * (bar.index + 0.5) + offset} y={barY - 5} fill={labelColor} textAnchor='middle'>
136
- {yAxisValue}
252
+ <Text // prettier-ignore
253
+ display={config.labels && displayBar ? 'block' : 'none'}
254
+ opacity={transparentBar ? 0.5 : 1}
255
+ x={barWidth * (bar.index + 0.5) + offset}
256
+ y={barY - 5}
257
+ fill={labelColor}
258
+ textAnchor='middle'
259
+ >
260
+ {barValueLabel}
137
261
  </Text>
138
262
 
139
263
  {config.isLollipopChart && config.lollipopShape === 'circle' && (
140
264
  <circle
265
+ display={displaylollipopShape}
141
266
  cx={barWidth * (barGroup.bars.length - bar.index - 1) + offset + lollipopShapeSize / 3.5}
142
267
  cy={bar.y}
143
268
  r={lollipopShapeSize / 2}
@@ -150,6 +275,7 @@ export const BarChartVertical = props => {
150
275
  )}
151
276
  {config.isLollipopChart && config.lollipopShape === 'square' && (
152
277
  <rect
278
+ display={displaylollipopShape}
153
279
  x={offset - lollipopBarWidth / 2}
154
280
  y={barY}
155
281
  width={lollipopShapeSize}
@@ -197,6 +323,8 @@ export const BarChartVertical = props => {
197
323
  )
198
324
  })
199
325
  : ''}
326
+
327
+ <Regions xScale={xScale} yMax={yMax} barWidth={barWidth} totalBarsInGroup={totalBarsInGroup} />
200
328
  </Group>
201
329
  )
202
330
  )
@@ -0,0 +1,39 @@
1
+ import React, { useContext } from 'react'
2
+
3
+ // visx
4
+ import { Group } from '@visx/group'
5
+ import { Bar } from '@visx/shape'
6
+
7
+ // cdc
8
+ import BarChartType from './BarChartType'
9
+ import ErrorBoundary from '@cdc/core/components/ErrorBoundary'
10
+ import ConfigContext from '../../../ConfigContext'
11
+ import BarChartContext from './context'
12
+
13
+ const BarChart = ({ xScale, yScale, seriesScale, xMax, yMax, handleTooltipMouseOver, handleTooltipMouseOff, handleTooltipClick }) => {
14
+ const { transformedData: data, config } = useContext(ConfigContext)
15
+
16
+ const contextValues = {
17
+ xScale,
18
+ yScale,
19
+ xMax,
20
+ yMax,
21
+ seriesScale
22
+ }
23
+
24
+ return (
25
+ <ErrorBoundary component='BarChart'>
26
+ <BarChartContext.Provider value={contextValues}>
27
+ <Group left={parseFloat(config.runtime.yAxis.size)}>
28
+ <BarChartType.StackedVertical />
29
+ <BarChartType.StackedHorizontal />
30
+ <BarChartType.Vertical />
31
+ <BarChartType.Horizontal />
32
+ <Bar key={'bars'} display={config.tooltips.singleSeries ? 'none' : 'block'} width={Number(xMax)} height={Number(yMax)} fill={'transparent'} fillOpacity={0.05} onMouseMove={e => handleTooltipMouseOver(e, data)} onMouseOut={handleTooltipMouseOff} onClick={e => handleTooltipClick(e, data)} />
33
+ </Group>
34
+ </BarChartContext.Provider>
35
+ </ErrorBoundary>
36
+ )
37
+ }
38
+
39
+ export default BarChart
@@ -1,5 +1,3 @@
1
- import React from 'react'
2
-
3
1
  import BarChartStackedVertical from './BarChart.StackedVertical'
4
2
  import BarChartStackedHorizontal from './BarChart.StackedHorizontal'
5
3
  import BarChartVertical from './BarChart.Vertical'
@@ -0,0 +1,13 @@
1
+ import { createContext } from 'react'
2
+
3
+ const BarChartContext = createContext(null)
4
+
5
+ export type BarChartContextValues = {
6
+ xMax: number
7
+ yMax: number
8
+ xScale: Function
9
+ yScale: Function
10
+ seriesScale: Function
11
+ }
12
+
13
+ export default BarChartContext
@@ -0,0 +1,3 @@
1
+ import BarChart from './components/BarChart'
2
+
3
+ export default BarChart
@@ -1,7 +1,7 @@
1
1
  import React, { useContext, useEffect } from 'react'
2
2
  import { BoxPlot } from '@visx/stats'
3
3
  import { Group } from '@visx/group'
4
- import ConfigContext from '../ConfigContext'
4
+ import ConfigContext from '../../ConfigContext'
5
5
  import ErrorBoundary from '@cdc/core/components/ErrorBoundary'
6
6
  import { colorPalettesChart } from '@cdc/core/data/colorPalettes'
7
7
 
@@ -0,0 +1,3 @@
1
+ import BoxPlot from './BoxPlot'
2
+
3
+ export default BoxPlot
@@ -125,7 +125,7 @@ export default function DeviationBar({ height, xScale }) {
125
125
  })
126
126
  }, [config.animate, config, animatedChart])
127
127
 
128
- if (!config || config?.series?.length !== 1) return <></>
128
+ // if (!config || config?.series?.length !== 1) return <></>
129
129
 
130
130
  return (
131
131
  <ErrorBoundary component='Deviation Bar'>
@@ -185,10 +185,11 @@ export default function DeviationBar({ height, xScale }) {
185
185
  y={barY}
186
186
  width={barWidth}
187
187
  height={barHeight}
188
- style={{ border: `${borderWidth}px solid #333`, backgroundColor: barColor[barPosition], ...borderRadius }}
189
188
  data-tooltip-html={tooltip}
190
189
  data-tooltip-id={`cdc-open-viz-tooltip-${config.runtime.uniqueId}`}
191
- />
190
+ >
191
+ <div style={{ width: barWidth, height: barHeight, border: `${borderWidth}px solid #333`, backgroundColor: barColor[barPosition], ...borderRadius }}></div>
192
+ </foreignObject>
192
193
  {config.yAxis.displayNumbersOnBar && (
193
194
  <Text verticalAnchor='middle' x={textX} y={textY} {...textProps[barPosition]}>
194
195
  {formatNumber(d[seriesKey], 'left')}