@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.
- package/dist/cdcchart.js +26921 -26667
- package/package.json +3 -3
- package/src/CdcChart.tsx +9 -2
- package/src/CdcChartComponent.tsx +17 -3
- package/src/components/BarChart/components/BarChart.Horizontal.tsx +11 -5
- package/src/components/BarChart/components/BarChart.StackedHorizontal.tsx +1 -1
- package/src/components/BarChart/components/BarChart.Vertical.tsx +21 -4
- package/src/components/Brush/BrushChart.tsx +65 -10
- package/src/components/Brush/BrushController.tsx +37 -5
- package/src/components/Brush/types.tsx +8 -0
- package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +2 -2
- package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +2 -34
- package/src/components/Legend/Legend.Component.tsx +16 -1
- package/src/components/Legend/Legend.tsx +3 -1
- package/src/components/LineChart/components/LineChart.BumpCircle.tsx +27 -26
- package/src/components/LinearChart.tsx +4 -4
- package/src/data/initial-state.js +11 -10
- package/src/hooks/useTooltip.tsx +1 -1
- package/src/index.jsx +6 -1
|
@@ -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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
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(
|
|
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=
|
|
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=
|
|
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,
|
|
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 =
|
|
158
|
-
const axisLabelFontSize =
|
|
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: '#
|
|
48
|
-
tickLabelColor: '#
|
|
49
|
-
tickColor: '#
|
|
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: '#
|
|
55
|
-
rightAxisTickLabelColor: '#
|
|
56
|
-
rightAxisTickColor: '#
|
|
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: '#
|
|
115
|
-
tickLabelColor: '#
|
|
116
|
-
tickColor: '#
|
|
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',
|
package/src/hooks/useTooltip.tsx
CHANGED
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
|
|
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
|
)
|