@cdc/chart 4.25.7 → 4.25.8

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.
@@ -3,13 +3,14 @@ import { Group } from '@visx/group'
3
3
  import { type Column } from '@cdc/core/types/Column'
4
4
  import React from 'react'
5
5
  import { type ChartConfig } from '../../../types/ChartConfig'
6
+ import { APP_FONT_COLOR } from '@cdc/core/helpers/constants'
6
7
 
7
8
  type LineChartBumpCircleProp = {
8
- config: ChartConfig,
9
- xScale: any,
10
- yScale: any,
11
- parseDate: any
12
- }
9
+ config: ChartConfig
10
+ xScale: any
11
+ yScale: any
12
+ parseDate: any
13
+ }
13
14
 
14
15
  const LineChartBumpCircle = (props: LineChartBumpCircleProp) => {
15
16
  const { config, xScale, yScale, parseDate } = props
@@ -33,47 +34,47 @@ const LineChartBumpCircle = (props: LineChartBumpCircleProp) => {
33
34
  return xScale.bandwidth ? xScale.bandwidth() / 2 + Number(xValue) : Number(xValue)
34
35
  }
35
36
 
36
-
37
37
  const getListItems = dataRow => {
38
38
  return Object.values(config.columns)
39
- ?.filter(column => column.tooltips).map(column => {
40
- const label = column.label || column.name;
41
- return `
39
+ ?.filter(column => column.tooltips)
40
+ .map(column => {
41
+ const label = column.label || column.name
42
+ return `
42
43
  <li className='tooltip-body'>
43
44
  <strong>${label}</strong>: ${dataRow[column.name]}
44
- </li>`;
45
- })
46
- .join(' ');
47
- }
45
+ </li>`
46
+ })
47
+ .join(' ')
48
+ }
48
49
 
49
50
  const getTooltip = dataRow => `<ul> ${getListItems(dataRow)} </ul>`
50
51
 
51
- const circles = config.runtime?.series.map((series) => {
52
+ const circles = config.runtime?.series.map(series => {
52
53
  return config.data.map((d, dataIndex) => {
53
54
  let series_dataKey = d[series.dataKey]
54
55
  let axis_dataKey = d[config.xAxis.dataKey]
55
56
  return (
56
57
  <React.Fragment key={`bump-circle-${series_dataKey}-${dataIndex}`}>
57
- <Group left={Number(config.runtime.yAxis.size)}>
58
+ <Group left={Number(config.runtime.yAxis.size)}>
58
59
  {series_dataKey && (
59
60
  <>
60
- <circle
61
+ <circle
61
62
  key={`bump-circle-${series_dataKey}-${dataIndex}`}
62
- data-tooltip-html={getTooltip(d)}
63
- data-tooltip-id={`bump-chart`}
64
- r={10}
65
- cx={Number(checkBandScale(xScale(handleX(axis_dataKey))))}
66
- cy={Number(yScale(series_dataKey))}
67
- stroke='#CACACA'
68
- strokeWidth={1}
69
- fill='#E5E4E2'
63
+ data-tooltip-html={getTooltip(d)}
64
+ data-tooltip-id={`bump-chart`}
65
+ r={10}
66
+ cx={Number(checkBandScale(xScale(handleX(axis_dataKey))))}
67
+ cy={Number(yScale(series_dataKey))}
68
+ stroke='#CACACA'
69
+ strokeWidth={1}
70
+ fill='#E5E4E2'
70
71
  />
71
72
  {series_dataKey.toString().length === 2 ? (
72
73
  // prettier-ignore
73
74
  <text
74
75
  x={Number(checkBandScale(xScale(handleX(axis_dataKey)))) - 7}
75
76
  y={Number(yScale(series_dataKey)) + 4}
76
- fill='#000000'
77
+ fill={APP_FONT_COLOR}
77
78
  fontSize={11.5}
78
79
  >
79
80
  {series_dataKey}
@@ -83,7 +84,7 @@ const LineChartBumpCircle = (props: LineChartBumpCircleProp) => {
83
84
  <text
84
85
  x={Number(checkBandScale(xScale(handleX(axis_dataKey)))) - 4}
85
86
  y={Number(yScale(series_dataKey)) + 4}
86
- fill='#000000'
87
+ fill={APP_FONT_COLOR}
87
88
  fontSize={11.5}
88
89
  >
89
90
  {series_dataKey}
@@ -29,7 +29,7 @@ import CategoricalYAxis from './Axis/Categorical.Axis'
29
29
  import BrushChart from './Brush/BrushController'
30
30
 
31
31
  // Helpers
32
- import { isLegendWrapViewport, isMobileHeightViewport } from '@cdc/core/helpers/viewports'
32
+ import { isLegendWrapViewport, isMobileFontViewport } from '@cdc/core/helpers/viewports'
33
33
  import { getTextWidth } from '@cdc/core/helpers/getTextWidth'
34
34
  import { calcInitialHeight, handleAutoPaddingRight } from '../helpers/sizeHelpers'
35
35
  import { filterAndShiftLinearDateTicks } from '../helpers/filterAndShiftLinearDateTicks'
@@ -97,7 +97,7 @@ const LinearChart = forwardRef<SVGAElement, LinearChartProps>(({ parentHeight, p
97
97
  tableData,
98
98
  transformedData: data,
99
99
  seriesHighlight,
100
-
100
+
101
101
  } = useContext(ConfigContext)
102
102
 
103
103
  // CONFIG
@@ -154,8 +154,8 @@ const LinearChart = forwardRef<SVGAElement, LinearChartProps>(({ parentHeight, p
154
154
  const labelsOverflow = inlineLabel && !inlineLabelHasNoSpace
155
155
  const padding = orientation === 'horizontal' ? Number(config.xAxis.size) : Number(config.yAxis.size)
156
156
  const yLabelOffset = isNaN(parseInt(`${runtime.yAxis.labelOffset}`)) ? 0 : parseInt(`${runtime.yAxis.labelOffset}`)
157
- const tickLabelFontSize = isMobileHeightViewport(currentViewport) ? TICK_LABEL_FONT_SIZE_SMALL : TICK_LABEL_FONT_SIZE
158
- const axisLabelFontSize = isMobileHeightViewport(currentViewport) ? AXIS_LABEL_FONT_SIZE_SMALL : AXIS_LABEL_FONT_SIZE
157
+ const tickLabelFontSize = isMobileFontViewport(currentViewport) ? TICK_LABEL_FONT_SIZE_SMALL : TICK_LABEL_FONT_SIZE
158
+ const axisLabelFontSize = isMobileFontViewport(currentViewport) ? AXIS_LABEL_FONT_SIZE_SMALL : AXIS_LABEL_FONT_SIZE
159
159
  const GET_TEXT_WIDTH_FONT = `normal ${tickLabelFontSize}px Nunito, sans-serif`
160
160
 
161
161
  // zero if not forest plot
@@ -44,16 +44,16 @@ export default {
44
44
  enablePadding: false,
45
45
  min: '',
46
46
  max: '',
47
- labelColor: '#333',
48
- tickLabelColor: '#333',
49
- tickColor: '#333',
47
+ labelColor: '#1c1d1f',
48
+ tickLabelColor: '#1c1d1f',
49
+ tickColor: '#1c1d1f',
50
50
  rightHideAxis: false,
51
51
  rightAxisSize: 0,
52
52
  rightLabel: '',
53
53
  rightLabelOffsetSize: 0,
54
- rightAxisLabelColor: '#333',
55
- rightAxisTickLabelColor: '#333',
56
- rightAxisTickColor: '#333',
54
+ rightAxisLabelColor: '#1c1d1f',
55
+ rightAxisTickLabelColor: '#1c1d1f',
56
+ rightAxisTickColor: '#1c1d1f',
57
57
  numTicks: '',
58
58
  axisPadding: 0,
59
59
  scalePadding: 10,
@@ -111,9 +111,9 @@ export default {
111
111
  tickRotation: 0,
112
112
  min: '',
113
113
  max: '',
114
- labelColor: '#333',
115
- tickLabelColor: '#333',
116
- tickColor: '#333',
114
+ labelColor: '#1c1d1f',
115
+ tickLabelColor: '#1c1d1f',
116
+ tickColor: '#1c1d1f',
117
117
  numTicks: '',
118
118
  labelOffset: 0,
119
119
  axisPadding: 200,
@@ -138,7 +138,8 @@ export default {
138
138
  showVertical: true,
139
139
  dateDisplayFormat: '',
140
140
  showMissingDataLabel: true,
141
- showSuppressedSymbol: true
141
+ showSuppressedSymbol: true,
142
+ collapsible: true
142
143
  },
143
144
  orientation: 'vertical',
144
145
  color: 'pinkpurple',
@@ -594,7 +594,7 @@ export const useTooltip = props => {
594
594
 
595
595
  return (
596
596
  <li style={style} className='tooltip-body mb-1'>
597
- {parse(displayText)}
597
+ {displayText !== undefined ? parse(String(displayText)) : displayText}
598
598
  </li>
599
599
  )
600
600
  }
package/src/index.jsx CHANGED
@@ -14,6 +14,11 @@ let domContainer = document.getElementsByClassName('react-container')[0]
14
14
 
15
15
  ReactDOM.createRoot(domContainer).render(
16
16
  <React.StrictMode>
17
- <CdcChart configUrl={domContainer.attributes['data-config'].value} isEditor={isEditor} isDebug={isDebug} />
17
+ <CdcChart
18
+ interactionLabel={domContainer.attributes['data-config']?.value}
19
+ configUrl={domContainer.attributes['data-config'].value}
20
+ isEditor={isEditor}
21
+ isDebug={isDebug}
22
+ />
18
23
  </React.StrictMode>
19
24
  )