@cdc/chart 4.25.3 → 4.25.5-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 (72) hide show
  1. package/dist/cdcchart.js +36051 -36995
  2. package/index.html +2 -1
  3. package/package.json +22 -27
  4. package/src/CdcChartComponent.tsx +10 -10
  5. package/src/_stories/Chart.CI.stories.tsx +10 -0
  6. package/src/_stories/Chart.DynamicSeries.stories.tsx +68 -49
  7. package/src/_stories/Chart.stories.tsx +7 -0
  8. package/{examples/private/line-issue.json → src/_stories/_mock/barchart_labels.mock.json} +150 -35
  9. package/src/_stories/_mock/dynamic_series_bar_config.json +1 -1
  10. package/src/_stories/_mock/dynamic_series_suppression_mock.json +610 -0
  11. package/src/components/Annotations/components/AnnotationDropdown.tsx +2 -2
  12. package/src/components/AreaChart/components/AreaChart.jsx +33 -5
  13. package/src/components/Axis/Categorical.Axis.tsx +2 -2
  14. package/src/components/BarChart/components/BarChart.Horizontal.tsx +50 -40
  15. package/src/components/BarChart/components/BarChart.StackedHorizontal.tsx +18 -8
  16. package/src/components/BarChart/components/BarChart.StackedVertical.tsx +19 -8
  17. package/src/components/BarChart/components/BarChart.Vertical.tsx +47 -30
  18. package/src/components/BarChart/components/{BarChart.jsx → BarChart.tsx} +23 -5
  19. package/src/components/BarChart/components/context.tsx +20 -2
  20. package/src/components/BarChart/helpers/getBarHeights.ts +47 -0
  21. package/src/components/BarChart/helpers/index.ts +5 -2
  22. package/src/components/BarChart/helpers/tests/getBarHeights.test.ts +83 -0
  23. package/src/{hooks → components/BarChart/helpers}/useBarChart.ts +9 -46
  24. package/src/components/BoxPlot/BoxPlot.tsx +2 -1
  25. package/src/components/DeviationBar.jsx +2 -1
  26. package/src/components/EditorPanel/components/Panels/Panel.General.tsx +34 -34
  27. package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +51 -25
  28. package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +10 -3
  29. package/src/components/EditorPanel/useEditorPermissions.ts +1 -4
  30. package/src/components/ForestPlot/ForestPlot.tsx +2 -2
  31. package/src/components/Legend/Legend.Component.tsx +1 -1
  32. package/src/components/Legend/Legend.Suppression.tsx +12 -22
  33. package/src/components/Legend/helpers/createFormatLabels.tsx +28 -0
  34. package/src/components/LineChart/LineChartProps.ts +3 -1
  35. package/src/components/LineChart/components/LineChart.Circle.tsx +72 -119
  36. package/src/components/LineChart/helpers.ts +133 -56
  37. package/src/components/LineChart/index.tsx +107 -53
  38. package/src/components/LinearChart.tsx +40 -89
  39. package/src/components/PairedBarChart.jsx +3 -2
  40. package/src/components/PieChart/PieChart.tsx +71 -91
  41. package/src/components/ScatterPlot/ScatterPlot.jsx +5 -0
  42. package/src/components/Sparkline/components/SparkLine.tsx +80 -18
  43. package/src/components/ZoomBrush.tsx +4 -4
  44. package/src/data/initial-state.js +3 -1
  45. package/src/helpers/countNumOfTicks.ts +1 -1
  46. package/src/helpers/dataHelpers.ts +23 -2
  47. package/src/helpers/sizeHelpers.ts +1 -1
  48. package/src/hooks/useMinMax.ts +21 -28
  49. package/src/hooks/useRightAxis.ts +4 -2
  50. package/src/hooks/useScales.ts +10 -6
  51. package/src/hooks/useTooltip.tsx +204 -203
  52. package/src/index.jsx +2 -2
  53. package/src/scss/main.scss +13 -6
  54. package/src/types/ChartConfig.ts +5 -0
  55. package/LICENSE +0 -201
  56. package/examples/private/DEV-8850-2.json +0 -493
  57. package/examples/private/DEV-9822.json +0 -574
  58. package/examples/private/DEV-9840.json +0 -553
  59. package/examples/private/DEV-9850-3.json +0 -461
  60. package/examples/private/chart.json +0 -1084
  61. package/examples/private/ci_formatted.json +0 -202
  62. package/examples/private/ci_issue.json +0 -3016
  63. package/examples/private/completed.json +0 -634
  64. package/examples/private/dem-data-long.csv +0 -20
  65. package/examples/private/dem-data-long.json +0 -36
  66. package/examples/private/demographic_data.csv +0 -157
  67. package/examples/private/demographic_data.json +0 -2654
  68. package/examples/private/demographic_dynamic.json +0 -443
  69. package/examples/private/demographic_standard.json +0 -560
  70. package/examples/private/ehdi.json +0 -29939
  71. package/examples/private/not-loading.json +0 -360
  72. package/examples/private/test.json +0 -493
@@ -28,7 +28,6 @@ const LineChart = (props: LineChartProps) => {
28
28
  const {
29
29
  getXAxisData,
30
30
  getYAxisData,
31
- handleTooltipClick,
32
31
  handleTooltipMouseOff,
33
32
  handleTooltipMouseOver,
34
33
  tooltipData,
@@ -36,53 +35,53 @@ const LineChart = (props: LineChartProps) => {
36
35
  xScale,
37
36
  yMax,
38
37
  yScale,
39
- } = props
38
+ } = props
40
39
 
41
40
  // prettier-ignore
42
41
  const { colorScale, config, formatNumber, handleLineType, parseDate, seriesHighlight, tableData, transformedData, updateConfig, brushConfig,clean } = useContext<ChartContext>(ConfigContext)
43
42
  const { yScaleRight } = useRightAxis({ config, yMax, data: transformedData, updateConfig })
44
- if (!handleTooltipMouseOver) return
43
+ const showSingleSeries = config.tooltips.singleSeries
45
44
 
46
45
  const DEBUG = false
47
46
  const { lineDatapointStyle, showLineSeriesLabels, legend } = config
48
- let data = transformedData
49
- let tableD = tableData
47
+ const isBrushOn = brushConfig.data.length > 0 && config.brush?.active
50
48
  // if brush on use brush data and clean
51
- if (brushConfig.data.length > 0 && config.brush?.active) {
52
- data = clean(brushConfig.data)
53
- tableD = clean(brushConfig.data)
54
- }
49
+ const data = isBrushOn ? clean(brushConfig.data) : transformedData
50
+ const _tableData = isBrushOn ? clean(brushConfig.data) : tableData
55
51
 
56
52
  const xPos = d => {
57
53
  return xScale(getXAxisData(d)) + (xScale.bandwidth ? xScale.bandwidth() / 2 : 0)
58
54
  }
59
55
 
56
+ const tooltipPoints = []
57
+
60
58
  return (
61
59
  <ErrorBoundary component='LineChart'>
62
- <Group left={Number(config.runtime.yAxis.size)}>
63
- {' '}
60
+ <Group left={Number(config.runtime.yAxis.size)} className='line-chart-group'>
64
61
  {/* left - expects a number not a string */}
65
62
  {(config.runtime.lineSeriesKeys || config.runtime.seriesKeys).map((seriesKey, index) => {
66
63
  const seriesData = config.runtime.series.find(item => item.dataKey === seriesKey)
64
+ const _seriesKey = seriesData.dynamicCategory ? seriesData.originalDataKey : seriesKey
67
65
  const lineType = seriesData.type
68
66
  const seriesAxis = seriesData.axis || 'left'
69
67
  const displayArea =
70
68
  legend.behavior === 'highlight' || seriesHighlight.length === 0 || seriesHighlight.indexOf(seriesKey) !== -1
71
69
 
72
- const suppressedSegments = createDataSegments(
73
- tableData,
70
+ const suppressedSegments = createDataSegments({
71
+ data: tableData,
74
72
  seriesKey,
75
- config.preliminaryData,
76
- config.xAxis.dataKey
77
- )
73
+ preliminaryData: config.preliminaryData,
74
+ dynamicCategory: seriesData.dynamicCategory,
75
+ originalSeriesKey: _seriesKey,
76
+ colorScale
77
+ })
78
78
  const isSplitLine =
79
79
  config?.preliminaryData?.filter(pd => pd.style && !pd.style.includes('Circles')).length > 0
80
80
 
81
81
  const _data = seriesData.dynamicCategory
82
82
  ? data.filter(d => d[seriesData.dynamicCategory] === seriesKey)
83
83
  : data
84
- const _seriesKey = seriesData.dynamicCategory ? seriesData.originalDataKey : seriesKey
85
- const circleData = filterCircles(config?.preliminaryData, tableD, _seriesKey)
84
+ const circleData = filterCircles(config?.preliminaryData, tableData, _seriesKey)
86
85
  return (
87
86
  <Group
88
87
  key={`series-${seriesKey}-${index}`}
@@ -108,11 +107,15 @@ const LineChart = (props: LineChartProps) => {
108
107
  height={Number(yMax)}
109
108
  fill={DEBUG ? 'red' : 'transparent'}
110
109
  fillOpacity={0.05}
111
- onMouseMove={e => handleTooltipMouseOver(e, tableData)}
112
- onMouseOut={handleTooltipMouseOff}
113
- onClick={e => handleTooltipClick(e, data)}
114
110
  />
115
111
  {_data.map((d, dataIndex) => {
112
+ tooltipPoints.push({
113
+ color: colorScale(config.runtime.seriesLabels[seriesKey]),
114
+ seriesKey: _seriesKey,
115
+ seriesIndex: index,
116
+ xValue: d[config.xAxis.dataKey],
117
+ yValue: d[_seriesKey]
118
+ })
116
119
  return (
117
120
  isNumber(d[_seriesKey]) && (
118
121
  <React.Fragment key={`series-${seriesKey}-point-${dataIndex}`}>
@@ -136,7 +139,6 @@ const LineChart = (props: LineChartProps) => {
136
139
  <LineChartCircle
137
140
  mode='ALWAYS_SHOW_POINTS'
138
141
  dataIndex={dataIndex}
139
- circleData={circleData}
140
142
  tableData={tableData}
141
143
  data={_data}
142
144
  d={d}
@@ -155,18 +157,37 @@ const LineChart = (props: LineChartProps) => {
155
157
  />
156
158
  )}
157
159
 
160
+ {(lineDatapointStyle === 'hover' || lineDatapointStyle === 'hidden') && (
161
+ <LineChartCircle
162
+ mode='HOVER_POINTS'
163
+ dataIndex={dataIndex}
164
+ tableData={tableData}
165
+ data={_data}
166
+ d={d}
167
+ config={config}
168
+ seriesKey={_seriesKey}
169
+ displayArea={displayArea}
170
+ xScale={xScale}
171
+ yScale={yScale}
172
+ colorScale={colorScale}
173
+ parseDate={parseDate}
174
+ yScaleRight={yScaleRight}
175
+ seriesAxis={seriesAxis}
176
+ seriesIndex={index}
177
+ key={`line-hover-circle--${dataIndex}`}
178
+ />
179
+ )}
180
+
158
181
  <LineChartCircle
159
182
  mode='ISOLATED_POINTS'
160
183
  seriesIndex={index}
161
184
  dataIndex={dataIndex}
162
185
  tableData={tableData}
163
- circleData={circleData}
164
186
  data={_data}
165
187
  d={d}
166
188
  config={config}
167
189
  seriesKey={_seriesKey}
168
190
  displayArea={displayArea}
169
- tooltipData={tooltipData}
170
191
  xScale={xScale}
171
192
  yScale={yScale}
172
193
  colorScale={colorScale}
@@ -179,28 +200,6 @@ const LineChart = (props: LineChartProps) => {
179
200
  )
180
201
  )
181
202
  })}
182
- <>
183
- {lineDatapointStyle === 'hover' && (
184
- <LineChartCircle
185
- seriesIndex={index}
186
- tableData={tableData}
187
- dataIndex={0}
188
- mode='HOVER_POINTS'
189
- circleData={circleData}
190
- data={_data}
191
- config={config}
192
- seriesKey={seriesKey}
193
- displayArea={displayArea}
194
- tooltipData={tooltipData}
195
- xScale={xScale}
196
- yScale={yScale}
197
- colorScale={colorScale}
198
- parseDate={parseDate}
199
- yScaleRight={yScaleRight}
200
- seriesAxis={seriesAxis}
201
- />
202
- )}
203
- </>
204
203
 
205
204
  {/* SPLIT LINE */}
206
205
  {isSplitLine ? (
@@ -217,15 +216,17 @@ const LineChart = (props: LineChartProps) => {
217
216
  }
218
217
  styles={createStyles({
219
218
  preliminaryData: config.preliminaryData,
220
- data: tableD,
219
+ data: tableData,
221
220
  stroke: colorScale(config.runtime.seriesLabels[seriesKey]),
222
221
  strokeWidth: seriesData.weight || 2,
223
222
  handleLineType,
224
223
  lineType,
225
- seriesKey
224
+ seriesKey,
225
+ dynamicCategory: seriesData.dynamicCategory,
226
+ originalSeriesKey: _seriesKey
226
227
  })}
227
228
  defined={(item, i) => {
228
- return item[seriesKey] !== '' && item[seriesKey] !== null && item[seriesKey] !== undefined
229
+ return item[_seriesKey] !== '' && item[_seriesKey] !== null && item[_seriesKey] !== undefined
229
230
  }}
230
231
  />
231
232
 
@@ -238,16 +239,22 @@ const LineChart = (props: LineChartProps) => {
238
239
  x={d => xPos(d)}
239
240
  y={d =>
240
241
  seriesAxis === 'Right'
241
- ? yScaleRight(getYAxisData(d, seriesKey))
242
- : yScale(Number(getYAxisData(d, seriesKey)))
242
+ ? yScaleRight(getYAxisData(d, _seriesKey))
243
+ : yScale(Number(getYAxisData(d, _seriesKey)))
244
+ }
245
+ stroke={
246
+ seriesData.dynamicCategory
247
+ ? segment.color
248
+ : colorScale(config.runtime.seriesLabels[seriesKey])
243
249
  }
244
- stroke={colorScale(config.runtime.seriesLabels[seriesKey])}
245
250
  strokeWidth={seriesData[0]?.weight || 2}
246
251
  strokeOpacity={1}
247
252
  shapeRendering='geometricPrecision'
248
253
  strokeDasharray={handleLineType(segment.style)}
249
254
  defined={(item, i) => {
250
- return item[seriesKey] !== '' && item[seriesKey] !== null && item[seriesKey] !== undefined
255
+ return (
256
+ item[_seriesKey] !== '' && item[_seriesKey] !== null && item[_seriesKey] !== undefined
257
+ )
251
258
  }}
252
259
  />
253
260
  )
@@ -269,6 +276,7 @@ const LineChart = (props: LineChartProps) => {
269
276
  return (
270
277
  <AreaClosed
271
278
  key={`area-closed-${seriesKey}-${categoryIndex}`}
279
+ className='confidence-interval'
272
280
  data={categoryData}
273
281
  x={d => xPos(d)}
274
282
  y0={d => yScale(d[config.confidenceKeys.lower])} // Lower bound of the confidence interval
@@ -432,6 +440,52 @@ const LineChart = (props: LineChartProps) => {
432
440
  </Text>
433
441
  )}
434
442
  </Group>
443
+ <Group left={Number(config.runtime.yAxis.size)} className='glyph-tooltip-group'>
444
+ <Group key={`tooltip-group`} display={'block'}>
445
+ {/* tooltips */}
446
+ <Bar
447
+ key={'tooltip bars'}
448
+ width={Number(xMax)}
449
+ height={Number(yMax)}
450
+ fill={DEBUG ? 'red' : 'transparent'}
451
+ fillOpacity={0.05}
452
+ onMouseMove={e => {
453
+ if (showSingleSeries) return
454
+ handleTooltipMouseOver(e, tableData)
455
+ }}
456
+ onMouseOut={handleTooltipMouseOff}
457
+ />
458
+ {tooltipPoints.map((d, dataIndex) => {
459
+ const { _data, seriesKey, seriesIndex, color } = d
460
+ return (
461
+ <React.Fragment key={`series-${seriesKey}-point-${dataIndex}`}>
462
+ <LineChartCircle
463
+ mode='TOOLTIP_POINTS'
464
+ dataIndex={dataIndex}
465
+ tooltipPoint={d}
466
+ tableData={tableData}
467
+ data={_data}
468
+ d={d}
469
+ config={config}
470
+ seriesKey={seriesKey}
471
+ displayArea={true}
472
+ tooltipData={tooltipData}
473
+ xScale={xScale}
474
+ yScale={yScale}
475
+ colorScale={colorScale}
476
+ parseDate={parseDate}
477
+ yScaleRight={yScaleRight}
478
+ seriesAxis={'[circle]'}
479
+ seriesIndex={seriesIndex}
480
+ key={`line-circle--${dataIndex}`}
481
+ handleTooltipMouseOver={handleTooltipMouseOver}
482
+ handleTooltipMouseOff={handleTooltipMouseOff}
483
+ />
484
+ </React.Fragment>
485
+ )
486
+ })}
487
+ </Group>
488
+ </Group>
435
489
  {config.visualizationType === 'Bump Chart' && (
436
490
  <LineChartBumpCircle config={config} xScale={xScale} yScale={yScale} />
437
491
  )}
@@ -4,8 +4,8 @@ import React, { forwardRef, useContext, useEffect, useMemo, useRef, useState } f
4
4
  import { AxisLeft, AxisBottom, AxisRight, AxisTop } from '@visx/axis'
5
5
  import { Group } from '@visx/group'
6
6
  import { Line, Bar } from '@visx/shape'
7
- import { Text } from '@visx/text'
8
7
  import { Tooltip as ReactTooltip } from 'react-tooltip'
8
+ import { Text } from '@visx/text'
9
9
  import { useTooltip, TooltipWithBounds } from '@visx/tooltip'
10
10
  import _ from 'lodash'
11
11
 
@@ -226,7 +226,10 @@ const LinearChart = forwardRef<SVGAElement, LinearChartProps>(({ parentHeight, p
226
226
  leftMax,
227
227
  rightMax,
228
228
  dimensions,
229
- xMax: parentWidth - Number(config.orientation === 'horizontal' ? config.xAxis.size : config.yAxis.size)
229
+ xMax:
230
+ parentWidth -
231
+ Number(config.orientation === 'horizontal' ? config.xAxis.size : config.yAxis.size) -
232
+ (hasRightAxis ? config.yAxis.rightAxisSize : 0)
230
233
  })
231
234
 
232
235
  const [yTickCount, xTickCount] = ['yAxis', 'xAxis'].map(axis =>
@@ -243,10 +246,10 @@ const LinearChart = forwardRef<SVGAElement, LinearChartProps>(({ parentHeight, p
243
246
  handleTooltipClick,
244
247
  handleTooltipMouseOff,
245
248
  TooltipListItem,
246
- getXValueFromCoordinate
247
249
  } = useCoveTooltip({
248
250
  xScale,
249
251
  yScale,
252
+ seriesScale,
250
253
  showTooltip,
251
254
  hideTooltip
252
255
  })
@@ -256,7 +259,7 @@ const LinearChart = forwardRef<SVGAElement, LinearChartProps>(({ parentHeight, p
256
259
  data.length && isDateTime
257
260
  ? [0, data.length - 1].map(i => parseDate(data[i][dataKey])).reduce((a, b) => Math.abs(a - b)) / MONTH_AS_MS
258
261
  : 0
259
- const useDateSpanMonths = isDateTime && dateSpanMonths > xTickCount
262
+ const useDateSpanMonths = isDateTime && dateSpanMonths > xTickCount && !config.runtime.xAxis.manual
260
263
 
261
264
  // GETTERS & FUNCTIONS
262
265
  const handleLeftTickFormatting = (tick, index, ticks) => {
@@ -438,7 +441,9 @@ const LinearChart = forwardRef<SVGAElement, LinearChartProps>(({ parentHeight, p
438
441
  }, [maxValue])
439
442
 
440
443
  useEffect(() => {
441
- if (orientation === 'horizontal' || !labelsOverflow || config.yAxis?.max) {
444
+ if (!yScale?.ticks) return
445
+ const ticks = yScale.ticks(handleNumTicks)
446
+ if (orientation === 'horizontal' || !labelsOverflow || config.yAxis?.max || ticks.length === 0) {
442
447
  setYAxisAutoPadding(0)
443
448
  return
444
449
  }
@@ -446,13 +451,12 @@ const LinearChart = forwardRef<SVGAElement, LinearChartProps>(({ parentHeight, p
446
451
  // minimum percentage of the max value that the distance should be from the top grid line
447
452
  const MINIMUM_DISTANCE_PERCENTAGE = 0.025
448
453
 
449
- const topGridLine = Math.max(...yScale.ticks(handleNumTicks))
454
+ const topGridLine = Math.max(...ticks)
450
455
  const needsPaddingThreshold = topGridLine - maxValue * MINIMUM_DISTANCE_PERCENTAGE
451
456
  const maxValueIsGreaterThanThreshold = maxValue > needsPaddingThreshold
452
457
 
453
458
  if (!maxValueIsGreaterThanThreshold) return
454
459
 
455
- const ticks = yScale.ticks(handleNumTicks)
456
460
  const tickGap = ticks.length === 1 ? ticks[0] : ticks[1] - ticks[0]
457
461
  const nextTick = Math.max(...yScale.ticks(handleNumTicks)) + tickGap
458
462
  const divideBy = minValue < 0 ? maxValue / 2 : maxValue
@@ -611,7 +615,6 @@ const LinearChart = forwardRef<SVGAElement, LinearChartProps>(({ parentHeight, p
611
615
  </>
612
616
  )
613
617
  }
614
-
615
618
  return isNaN(width) ? (
616
619
  <React.Fragment></React.Fragment>
617
620
  ) : (
@@ -624,7 +627,7 @@ const LinearChart = forwardRef<SVGAElement, LinearChartProps>(({ parentHeight, p
624
627
  <svg
625
628
  ref={svgRef}
626
629
  onMouseMove={onMouseMove}
627
- width={parentWidth}
630
+ width={parentWidth + config.yAxis.rightAxisSize}
628
631
  height={isNoDataAvailable ? 1 : parentHeight}
629
632
  className={`linear ${config.animate ? 'animated' : ''} ${animatedChart && config.animate ? 'animate' : ''} ${
630
633
  debugSvg && 'debug'
@@ -717,24 +720,8 @@ const LinearChart = forwardRef<SVGAElement, LinearChartProps>(({ parentHeight, p
717
720
  yScale={yScale}
718
721
  />
719
722
  )}
720
- {((visualizationType === 'Area Chart' && config.visualizationSubType === 'regular') ||
721
- (visualizationType === 'Combo' && config.visualizationSubType === 'regular')) && (
722
- <AreaChart
723
- xScale={xScale}
724
- yScale={yScale}
725
- yMax={yMax}
726
- xMax={xMax}
727
- chartRef={svgRef}
728
- width={xMax}
729
- height={yMax}
730
- handleTooltipMouseOver={handleTooltipMouseOver}
731
- handleTooltipMouseOff={handleTooltipMouseOff}
732
- tooltipData={tooltipData}
733
- showTooltip={showTooltip}
734
- />
735
- )}
736
723
  {((visualizationType === 'Area Chart' && config.visualizationSubType === 'stacked') ||
737
- (visualizationType === 'Combo' && config.visualizationSubType === 'stacked')) && (
724
+ visualizationType === 'Combo') && (
738
725
  <AreaChartStacked
739
726
  xScale={xScale}
740
727
  yScale={yScale}
@@ -768,9 +755,7 @@ const LinearChart = forwardRef<SVGAElement, LinearChartProps>(({ parentHeight, p
768
755
  chartRef={svgRef}
769
756
  />
770
757
  )}
771
- {((visualizationType === 'Line' && !convertLineToBarGraph) ||
772
- visualizationType === 'Combo' ||
773
- visualizationType === 'Bump Chart') && (
758
+ {(visualizationType === 'Combo' || visualizationType === 'Bump Chart') && (
774
759
  <LineChart
775
760
  xScale={xScale}
776
761
  yScale={yScale}
@@ -784,7 +769,6 @@ const LinearChart = forwardRef<SVGAElement, LinearChartProps>(({ parentHeight, p
784
769
  handleTooltipClick={handleTooltipClick}
785
770
  tooltipData={tooltipData}
786
771
  showTooltip={showTooltip}
787
- chartRef={svgRef}
788
772
  />
789
773
  )}
790
774
  {(visualizationType === 'Forecasting' || visualizationType === 'Combo') && (
@@ -798,7 +782,6 @@ const LinearChart = forwardRef<SVGAElement, LinearChartProps>(({ parentHeight, p
798
782
  height={yMax}
799
783
  xScaleNoPadding={xScaleNoPadding}
800
784
  chartRef={svgRef}
801
- getXValueFromCoordinate={getXValueFromCoordinate}
802
785
  handleTooltipMouseOver={handleTooltipMouseOver}
803
786
  handleTooltipMouseOff={handleTooltipMouseOff}
804
787
  isBrush={false}
@@ -842,6 +825,9 @@ const LinearChart = forwardRef<SVGAElement, LinearChartProps>(({ parentHeight, p
842
825
  xMax={xMax}
843
826
  yMax={yMax}
844
827
  seriesStyle={config.runtime.series}
828
+ tooltipData={tooltipData}
829
+ handleTooltipMouseOver={handleTooltipMouseOver}
830
+ handleTooltipMouseOff={handleTooltipMouseOff}
845
831
  />
846
832
  </>
847
833
  )}
@@ -926,79 +912,45 @@ const LinearChart = forwardRef<SVGAElement, LinearChartProps>(({ parentHeight, p
926
912
  width={width}
927
913
  />
928
914
  )}
929
- {chartHasTooltipGuides && showTooltip && tooltipData && config.visual.verticalHoverLine && (
930
- <Group key='tooltipLine-vertical' className='vertical-tooltip-line'>
915
+ {isNoDataAvailable && (
916
+ <Text
917
+ x={Number(config.yAxis.size) + Number(xMax / 2)}
918
+ y={initialHeight / 2 - (config.xAxis.padding || 0) / 2}
919
+ textAnchor='middle'
920
+ >
921
+ {config.chartMessage.noData}
922
+ </Text>
923
+ )}
924
+ {config.visual.horizontalHoverLine && tooltipData && (
925
+ <Group
926
+ key={`tooltipLine-horizontal${point.y}${point.x}`}
927
+ className='horizontal-tooltip-line'
928
+ left={config.yAxis.size ? config.yAxis.size : 0}
929
+ >
931
930
  <Line
932
- from={{ x: tooltipData.dataXPosition - 10, y: 0 }}
933
- to={{ x: tooltipData.dataXPosition - 10, y: yMax }}
931
+ from={{ x: 0, y: point.y }}
932
+ to={{ x: xMax, y: point.y }}
934
933
  stroke={'black'}
935
934
  strokeWidth={1}
936
935
  pointerEvents='none'
937
936
  strokeDasharray='5,5'
938
- className='vertical-tooltip-line'
937
+ className='horizontal-tooltip-line'
939
938
  />
940
939
  </Group>
941
940
  )}
942
- {chartHasTooltipGuides && showTooltip && tooltipData && config.visual.horizontalHoverLine && (
943
- <Group
944
- key='tooltipLine-horizontal'
945
- className='horizontal-tooltip-line'
946
- left={config.yAxis.size ? config.yAxis.size : 0}
947
- >
941
+ {config.visual.verticalHoverLine && tooltipData && (
942
+ <Group key={`tooltipLine-vertical${point.y}${point.x}`} className='vertical-tooltip-line'>
948
943
  <Line
949
- from={{ x: 0, y: tooltipData.dataYPosition }}
950
- to={{ x: xMax, y: tooltipData.dataYPosition }}
944
+ from={{ x: point.x, y: 0 }}
945
+ to={{ x: point.x, y: yMax }}
951
946
  stroke={'black'}
952
947
  strokeWidth={1}
953
948
  pointerEvents='none'
954
949
  strokeDasharray='5,5'
955
- className='horizontal-tooltip-line'
950
+ className='vertical-tooltip-line'
956
951
  />
957
952
  </Group>
958
953
  )}
959
- {isNoDataAvailable && (
960
- <Text
961
- x={Number(config.yAxis.size) + Number(xMax / 2)}
962
- y={initialHeight / 2 - (config.xAxis.padding || 0) / 2}
963
- textAnchor='middle'
964
- >
965
- {config.chartMessage.noData}
966
- </Text>
967
- )}
968
- {(config.visualizationType === 'Bar' || convertLineToBarGraph) &&
969
- config.tooltips.singleSeries &&
970
- config.visual.horizontalHoverLine && (
971
- <Group
972
- key='tooltipLine-horizontal'
973
- className='horizontal-tooltip-line'
974
- left={config.yAxis.size ? config.yAxis.size : 0}
975
- >
976
- <Line
977
- from={{ x: 0, y: point.y }}
978
- to={{ x: xMax, y: point.y }}
979
- stroke={'black'}
980
- strokeWidth={1}
981
- pointerEvents='none'
982
- strokeDasharray='5,5'
983
- className='horizontal-tooltip-line'
984
- />
985
- </Group>
986
- )}
987
- {(config.visualizationType === 'Bar' || convertLineToBarGraph) &&
988
- config.tooltips.singleSeries &&
989
- config.visual.verticalHoverLine && (
990
- <Group key='tooltipLine-vertical' className='vertical-tooltip-line'>
991
- <Line
992
- from={{ x: point.x, y: 0 }}
993
- to={{ x: point.x, y: yMax }}
994
- stroke={'black'}
995
- strokeWidth={1}
996
- pointerEvents='none'
997
- strokeDasharray='5,5'
998
- className='vertical-tooltip-line'
999
- />
1000
- </Group>
1001
- )}
1002
954
  <Group left={Number(config.runtime.yAxis.size)}>
1003
955
  <Annotation.Draggable
1004
956
  xScale={xScale}
@@ -1564,7 +1516,6 @@ const LinearChart = forwardRef<SVGAElement, LinearChartProps>(({ parentHeight, p
1564
1516
  </TooltipWithBounds>
1565
1517
  </>
1566
1518
  )}
1567
-
1568
1519
  {config.visualizationType === 'Bump Chart' && (
1569
1520
  <ReactTooltip
1570
1521
  id={`bump-chart`}
@@ -6,6 +6,7 @@ import { Text } from '@visx/text'
6
6
 
7
7
  import ConfigContext from '../ConfigContext'
8
8
  import { getContrastColor } from '@cdc/core/helpers/cove/accessibility'
9
+ import { APP_FONT_COLOR } from '@cdc/core/helpers/constants'
9
10
  import { getTextWidth } from '@cdc/core/helpers/getTextWidth'
10
11
 
11
12
  const PairedBarChart = ({ width, height, originalWidth }) => {
@@ -47,8 +48,8 @@ const PairedBarChart = ({ width, height, originalWidth }) => {
47
48
  })
48
49
 
49
50
  // Set label color
50
- groupOne.labelColor = groupOne.color ? getContrastColor('#000', groupOne.color) : '#000'
51
- groupTwo.labelColor = groupTwo.color ? getContrastColor('#000', groupTwo.color) : '#000'
51
+ groupOne.labelColor = groupOne.color ? getContrastColor(APP_FONT_COLOR, groupOne.color) : APP_FONT_COLOR
52
+ groupTwo.labelColor = groupTwo.color ? getContrastColor(APP_FONT_COLOR, groupTwo.color) : APP_FONT_COLOR
52
53
 
53
54
  const label = config.yAxis.label ? `${config.yAxis.label}: ` : ''
54
55