@cdc/chart 4.22.10 → 4.22.11
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/README.md +5 -5
- package/dist/cdcchart.js +4 -4
- package/examples/age-adjusted-rates.json +1486 -1218
- package/examples/case-rate-example-config.json +1 -1
- package/examples/covid-confidence-example-config.json +33 -33
- package/examples/covid-example-config.json +34 -34
- package/examples/covid-example-data-confidence.json +30 -30
- package/examples/covid-example-data.json +20 -20
- package/examples/cutoff-example-config.json +36 -36
- package/examples/cutoff-example-data.json +36 -36
- package/examples/date-exclusions-config.json +1 -1
- package/examples/dynamic-legends.json +124 -124
- package/examples/gallery/bar-chart-horizontal/horizontal-bar-chart-with-numbers-on-bar.json +191 -197
- package/examples/gallery/bar-chart-horizontal/horizontal-bar-chart.json +230 -240
- package/examples/gallery/bar-chart-horizontal/horizontal-stacked.json +239 -247
- package/examples/gallery/bar-chart-vertical/combo-line-chart.json +136 -136
- package/examples/gallery/bar-chart-vertical/vertical-bar-chart-categorical.json +79 -79
- package/examples/gallery/bar-chart-vertical/vertical-bar-chart-stacked.json +80 -80
- package/examples/gallery/bar-chart-vertical/vertical-bar-chart-with-confidence.json +67 -67
- package/examples/gallery/bar-chart-vertical/vertical-bar-chart.json +110 -110
- package/examples/gallery/lollipop/lollipop-style-horizontal.json +215 -219
- package/examples/gallery/paired-bar/paired-bar-chart.json +195 -195
- package/examples/horizontal-chart.json +35 -35
- package/examples/horizontal-stacked-bar-chart.json +34 -34
- package/examples/line-chart.json +75 -75
- package/examples/paired-bar-data.json +16 -14
- package/examples/paired-bar-example.json +48 -48
- package/examples/paired-bar-formatted.json +36 -36
- package/examples/planet-chart-horizontal-example-config.json +33 -33
- package/examples/planet-combo-example-config.json +34 -31
- package/examples/planet-example-config.json +35 -33
- package/examples/planet-example-data.json +56 -56
- package/examples/planet-pie-example-config.json +28 -28
- package/examples/private/filters.json +170 -0
- package/examples/private/line-test-data.json +21 -21
- package/examples/private/line-test-two.json +209 -215
- package/examples/private/line-test.json +101 -101
- package/examples/private/new.json +48800 -0
- package/examples/private/shawn.json +1105 -1295
- package/examples/private/test.json +10123 -10123
- package/examples/private/yaxis-test.json +4 -3
- package/examples/private/yaxis.json +26 -26
- package/examples/stacked-vertical-bar-example.json +1 -1
- package/examples/temp-example-config.json +61 -54
- package/examples/temp-example-data.json +1 -1
- package/package.json +2 -2
- package/src/CdcChart.tsx +339 -380
- package/src/components/BarChart.tsx +425 -469
- package/src/components/DataTable.tsx +164 -195
- package/src/components/EditorPanel.js +1009 -710
- package/src/components/Legend.js +279 -329
- package/src/components/LineChart.tsx +90 -79
- package/src/components/LinearChart.tsx +376 -434
- package/src/components/PairedBarChart.tsx +197 -213
- package/src/components/PieChart.tsx +95 -151
- package/src/components/SparkLine.js +179 -201
- package/src/components/useIntersectionObserver.tsx +17 -20
- package/src/context.tsx +3 -3
- package/src/data/initial-state.js +37 -16
- package/src/hooks/useActiveElement.js +13 -13
- package/src/hooks/useChartClasses.js +34 -28
- package/src/hooks/useColorPalette.ts +56 -63
- package/src/hooks/useLegendClasses.js +18 -10
- package/src/hooks/useReduceData.ts +62 -78
- package/src/hooks/useRightAxis.js +25 -0
- package/src/hooks/useTopAxis.js +6 -0
- package/src/index.html +45 -45
- package/src/index.tsx +13 -16
- package/src/scss/DataTable.scss +5 -4
- package/src/scss/editor-panel.scss +71 -69
- package/src/scss/main.scss +157 -114
- package/src/scss/variables.scss +1 -1
|
@@ -1,207 +1,185 @@
|
|
|
1
|
-
import React, { useContext, useEffect } from 'react'
|
|
2
|
-
|
|
3
|
-
import * as allCurves from '@visx/curve'
|
|
4
|
-
import { Group } from '@visx/group'
|
|
5
|
-
import { LinePath } from '@visx/shape'
|
|
6
|
-
import { Text } from '@visx/text'
|
|
7
|
-
import { scaleLinear, scalePoint } from '@visx/scale'
|
|
8
|
-
import { AxisBottom } from '@visx/axis'
|
|
9
|
-
import { MarkerArrow } from '@visx/marker'
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
height={parentHeight}
|
|
117
|
-
style={{ height: parentHeight}}
|
|
118
|
-
top={margin.top}
|
|
119
|
-
key={`series-${seriesKey}`}
|
|
120
|
-
opacity={config.legend.behavior === "highlight" && seriesHighlight.length > 0 && seriesHighlight.indexOf(seriesKey) === -1 ? 0.5 : 1}
|
|
121
|
-
display={config.legend.behavior === "highlight" || seriesHighlight.length === 0 || seriesHighlight.indexOf(seriesKey) !== -1 ? 'block' : 'none'}
|
|
122
|
-
>
|
|
123
|
-
{data.map((d, dataIndex) => {
|
|
124
|
-
let yAxisTooltip = config.runtime.yAxis.label ? `${config.runtime.yAxis.label}: ${formatNumber(getYAxisData(d, seriesKey))}` : formatNumber(getYAxisData(d, seriesKey))
|
|
125
|
-
let xAxisTooltip = config.runtime.xAxis.label ? `${config.runtime.xAxis.label}: ${d[config.runtime.xAxis.dataKey]}` : d[config.runtime.xAxis.dataKey]
|
|
126
|
-
|
|
127
|
-
const tooltip = `<div>
|
|
1
|
+
import React, { useContext, useEffect } from 'react'
|
|
2
|
+
|
|
3
|
+
import * as allCurves from '@visx/curve'
|
|
4
|
+
import { Group } from '@visx/group'
|
|
5
|
+
import { LinePath } from '@visx/shape'
|
|
6
|
+
import { Text } from '@visx/text'
|
|
7
|
+
import { scaleLinear, scalePoint } from '@visx/scale'
|
|
8
|
+
import { AxisBottom } from '@visx/axis'
|
|
9
|
+
import { MarkerArrow } from '@visx/marker'
|
|
10
|
+
|
|
11
|
+
import ErrorBoundary from '@cdc/core/components/ErrorBoundary'
|
|
12
|
+
|
|
13
|
+
import ReactTooltip from 'react-tooltip'
|
|
14
|
+
|
|
15
|
+
import useReduceData from '../hooks/useReduceData'
|
|
16
|
+
|
|
17
|
+
import Context from '../context'
|
|
18
|
+
|
|
19
|
+
export default function SparkLine({ width: parentWidth, height: parentHeight }) {
|
|
20
|
+
const { transformedData: data, dimensions, config, parseDate, formatDate, currentViewport, seriesHighlight, formatNumber, colorScale, handleChartAriaLabels } = useContext(Context)
|
|
21
|
+
let width = parentWidth
|
|
22
|
+
const { minValue, maxValue } = useReduceData(config, data)
|
|
23
|
+
|
|
24
|
+
const margin = { top: 5, right: 10, bottom: 10, left: 10 }
|
|
25
|
+
const height = parentHeight
|
|
26
|
+
|
|
27
|
+
const xMax = width - config.runtime.yAxis.size
|
|
28
|
+
const yMax = height - margin.top - 20
|
|
29
|
+
|
|
30
|
+
const getXAxisData = d => (config.runtime.xAxis.type === 'date' ? parseDate(d[config.runtime.originalXAxis.dataKey]).getTime() : d[config.runtime.originalXAxis.dataKey])
|
|
31
|
+
const getYAxisData = (d, seriesKey) => d[seriesKey]
|
|
32
|
+
|
|
33
|
+
let xScale
|
|
34
|
+
let yScale
|
|
35
|
+
let seriesScale
|
|
36
|
+
const { max: enteredMaxValue, min: enteredMinValue } = config.runtime.yAxis
|
|
37
|
+
const isMaxValid = Number(enteredMaxValue) >= Number(maxValue)
|
|
38
|
+
const isMinValid = Number(enteredMinValue) <= Number(minValue)
|
|
39
|
+
|
|
40
|
+
if (data) {
|
|
41
|
+
let min = enteredMinValue && isMinValid ? enteredMinValue : minValue
|
|
42
|
+
let max = enteredMaxValue && isMaxValid ? enteredMaxValue : Number.MIN_VALUE
|
|
43
|
+
|
|
44
|
+
if (max === Number.MIN_VALUE) {
|
|
45
|
+
max = maxValue
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//Adds Y Axis data padding if applicable
|
|
49
|
+
if (config.runtime.yAxis.paddingPercent) {
|
|
50
|
+
let paddingValue = (max - min) * config.runtime.yAxis.paddingPercent
|
|
51
|
+
min -= paddingValue
|
|
52
|
+
max += paddingValue
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let xAxisDataMapped = data.map(d => getXAxisData(d))
|
|
56
|
+
|
|
57
|
+
if (config.runtime.horizontal) {
|
|
58
|
+
xScale = scaleLinear({
|
|
59
|
+
domain: [min, max],
|
|
60
|
+
range: [0, xMax]
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
yScale = config.runtime.xAxis.type === 'date' ? scaleLinear({ domain: [Math.min(...xAxisDataMapped), Math.max(...xAxisDataMapped)] }) : scalePoint({ domain: xAxisDataMapped, padding: 0.5 })
|
|
64
|
+
|
|
65
|
+
seriesScale = scalePoint({
|
|
66
|
+
domain: config.runtime.barSeriesKeys || config.runtime.seriesKeys,
|
|
67
|
+
range: [0, yMax]
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
yScale.rangeRound([0, yMax])
|
|
71
|
+
} else {
|
|
72
|
+
min = min < 0 ? min * 1.11 : min
|
|
73
|
+
|
|
74
|
+
yScale = scaleLinear({
|
|
75
|
+
domain: [min, max],
|
|
76
|
+
range: [yMax - margin.bottom, margin.top]
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
xScale = scalePoint({
|
|
80
|
+
domain: xAxisDataMapped,
|
|
81
|
+
range: [margin.left, width - margin.right]
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
seriesScale = scalePoint({
|
|
85
|
+
domain: config.runtime.barSeriesKeys || config.runtime.seriesKeys,
|
|
86
|
+
range: [0, xMax]
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const handleSparkLineTicks = [xScale.domain()[0], xScale.domain()[xScale.domain().length - 1]]
|
|
92
|
+
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
ReactTooltip.rebuild()
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<ErrorBoundary component='SparkLine'>
|
|
99
|
+
<svg role='img' aria-label={handleChartAriaLabels(config)} width={width} height={height} className={'sparkline'} tabIndex={0}>
|
|
100
|
+
{(config.runtime.lineSeriesKeys || config.runtime.seriesKeys).map((seriesKey, index) => (
|
|
101
|
+
<>
|
|
102
|
+
<Group
|
|
103
|
+
className='sparkline-group'
|
|
104
|
+
height={parentHeight}
|
|
105
|
+
style={{ height: parentHeight }}
|
|
106
|
+
top={margin.top}
|
|
107
|
+
key={`series-${seriesKey}`}
|
|
108
|
+
opacity={config.legend.behavior === 'highlight' && seriesHighlight.length > 0 && seriesHighlight.indexOf(seriesKey) === -1 ? 0.5 : 1}
|
|
109
|
+
display={config.legend.behavior === 'highlight' || seriesHighlight.length === 0 || seriesHighlight.indexOf(seriesKey) !== -1 ? 'block' : 'none'}
|
|
110
|
+
>
|
|
111
|
+
{data.map((d, dataIndex) => {
|
|
112
|
+
let yAxisTooltip = config.runtime.yAxis.label ? `${config.runtime.yAxis.label}: ${formatNumber(getYAxisData(d, seriesKey))}` : formatNumber(getYAxisData(d, seriesKey))
|
|
113
|
+
let xAxisTooltip = config.runtime.xAxis.label ? `${config.runtime.xAxis.label}: ${d[config.runtime.xAxis.dataKey]}` : d[config.runtime.xAxis.dataKey]
|
|
114
|
+
|
|
115
|
+
const tooltip = `<div>
|
|
128
116
|
${yAxisTooltip}<br />
|
|
129
117
|
${xAxisTooltip}<br />
|
|
130
118
|
${config.seriesLabel ? `${config.seriesLabel}: ${seriesKey}` : ''}
|
|
131
119
|
</div>`
|
|
132
120
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
})}
|
|
198
|
-
|
|
199
|
-
/>
|
|
200
|
-
</>
|
|
201
|
-
))
|
|
202
|
-
}
|
|
203
|
-
</svg>
|
|
204
|
-
</ErrorBoundary>
|
|
205
|
-
|
|
206
|
-
);
|
|
121
|
+
let circleRadii = 4.5
|
|
122
|
+
return (
|
|
123
|
+
<Group key={`series-${seriesKey}-point-${dataIndex}`}>
|
|
124
|
+
<Text display={config.labels ? 'block' : 'none'} x={xScale(getXAxisData(d))} y={yScale(getYAxisData(d, seriesKey))} fill={colorScale ? colorScale(config.runtime.seriesLabels ? config.runtime.seriesLabels[seriesKey] : seriesKey) : '#000'} textAnchor='middle'>
|
|
125
|
+
{formatNumber(d[seriesKey])}
|
|
126
|
+
</Text>
|
|
127
|
+
|
|
128
|
+
{dataIndex + 1 !== data.length && (config.lineDatapointStyle === 'always show' || config.lineDatapointStyle === 'hover') && (
|
|
129
|
+
<circle
|
|
130
|
+
key={`${seriesKey}-${dataIndex}`}
|
|
131
|
+
r={circleRadii}
|
|
132
|
+
cx={xScale(getXAxisData(d))}
|
|
133
|
+
cy={yScale(getYAxisData(d, seriesKey))}
|
|
134
|
+
fill={colorScale ? colorScale(config.runtime.seriesLabels ? config.runtime.seriesLabels[seriesKey] : seriesKey) : '#000'}
|
|
135
|
+
style={{ fill: colorScale ? colorScale(config.runtime.seriesLabels ? config.runtime.seriesLabels[seriesKey] : seriesKey) : '#000' }}
|
|
136
|
+
data-tip={tooltip}
|
|
137
|
+
data-for={`cdc-open-viz-tooltip-${config.runtime.uniqueId}`}
|
|
138
|
+
/>
|
|
139
|
+
)}
|
|
140
|
+
</Group>
|
|
141
|
+
)
|
|
142
|
+
})}
|
|
143
|
+
<LinePath
|
|
144
|
+
curve={allCurves.curveLinear}
|
|
145
|
+
data={data}
|
|
146
|
+
x={d => xScale(getXAxisData(d))}
|
|
147
|
+
y={d => yScale(getYAxisData(d, seriesKey))}
|
|
148
|
+
stroke={colorScale ? colorScale(config.runtime.seriesLabels ? config.runtime.seriesLabels[seriesKey] : seriesKey) : '#000'}
|
|
149
|
+
strokeWidth={2}
|
|
150
|
+
strokeOpacity={1}
|
|
151
|
+
shapeRendering='geometricPrecision'
|
|
152
|
+
marker-end={`url(#${'arrow'}--${index})`}
|
|
153
|
+
/>
|
|
154
|
+
<MarkerArrow
|
|
155
|
+
id={`arrow--${index}`}
|
|
156
|
+
refX={2}
|
|
157
|
+
size={6}
|
|
158
|
+
marker-end={`url(#${'arrow'}--${index})`}
|
|
159
|
+
strokeOpacity={1}
|
|
160
|
+
fillOpacity={1}
|
|
161
|
+
// stroke={colorScale ? colorScale(config.runtime.seriesLabels ? config.runtime.seriesLabels[seriesKey] : seriesKey) : '#000'}
|
|
162
|
+
fill={colorScale ? colorScale(config.runtime.seriesLabels ? config.runtime.seriesLabels[seriesKey] : seriesKey) : '#000'}
|
|
163
|
+
/>
|
|
164
|
+
</Group>
|
|
165
|
+
<AxisBottom
|
|
166
|
+
top={yMax + margin.top}
|
|
167
|
+
hideAxisLine
|
|
168
|
+
hideTicks
|
|
169
|
+
scale={xScale}
|
|
170
|
+
tickValues={handleSparkLineTicks}
|
|
171
|
+
tickFormat={formatDate}
|
|
172
|
+
stroke={'black'}
|
|
173
|
+
tickStroke={'black'}
|
|
174
|
+
tickLabelProps={() => ({
|
|
175
|
+
fill: 'black',
|
|
176
|
+
fontSize: 11,
|
|
177
|
+
textAnchor: 'middle'
|
|
178
|
+
})}
|
|
179
|
+
/>
|
|
180
|
+
</>
|
|
181
|
+
))}
|
|
182
|
+
</svg>
|
|
183
|
+
</ErrorBoundary>
|
|
184
|
+
)
|
|
207
185
|
}
|
|
@@ -1,30 +1,27 @@
|
|
|
1
|
-
import {useEffect, useState} from
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
2
|
|
|
3
|
-
export default function useIntersectionObserver(
|
|
4
|
-
|
|
5
|
-
{ threshold = 0, root = null, rootMargin = "0%", freezeOnceVisible = false }
|
|
6
|
-
) {
|
|
7
|
-
const [entry, setEntry] = useState<any>();
|
|
3
|
+
export default function useIntersectionObserver(elementRef, { threshold = 0, root = null, rootMargin = '0%', freezeOnceVisible = false }) {
|
|
4
|
+
const [entry, setEntry] = useState<any>()
|
|
8
5
|
|
|
9
|
-
|
|
6
|
+
const frozen = entry?.isIntersecting && freezeOnceVisible
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const updateEntry = ([entry]) => {
|
|
9
|
+
setEntry(entry)
|
|
10
|
+
}
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const node = elementRef?.current
|
|
14
|
+
const hasIOSupport = !!window.IntersectionObserver
|
|
18
15
|
|
|
19
|
-
|
|
16
|
+
if (!hasIOSupport || frozen || !node) return
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
const observerParams = { threshold, root, rootMargin }
|
|
19
|
+
const observer = new IntersectionObserver(updateEntry, observerParams)
|
|
23
20
|
|
|
24
|
-
|
|
21
|
+
observer.observe(node)
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
return () => observer.disconnect()
|
|
24
|
+
}, [elementRef, threshold, root, rootMargin, frozen])
|
|
28
25
|
|
|
29
|
-
|
|
26
|
+
return entry
|
|
30
27
|
}
|
package/src/context.tsx
CHANGED
|
@@ -10,22 +10,37 @@ export default {
|
|
|
10
10
|
lollipopShape: 'circle',
|
|
11
11
|
lollipopColorStyle: 'two-tone',
|
|
12
12
|
visualizationSubType: 'regular',
|
|
13
|
-
barStyle:'',
|
|
14
|
-
roundingStyle:'standard',
|
|
15
|
-
tipRounding:'top',
|
|
13
|
+
barStyle: '',
|
|
14
|
+
roundingStyle: 'standard',
|
|
15
|
+
tipRounding: 'top',
|
|
16
16
|
padding: {
|
|
17
17
|
left: 5,
|
|
18
18
|
right: 5
|
|
19
19
|
},
|
|
20
20
|
yAxis: {
|
|
21
21
|
hideAxis: false,
|
|
22
|
-
displayNumbersOnBar:false,
|
|
22
|
+
displayNumbersOnBar: false,
|
|
23
23
|
hideLabel: false,
|
|
24
24
|
hideTicks: false,
|
|
25
25
|
size: 50,
|
|
26
26
|
gridLines: false,
|
|
27
|
-
min:'',
|
|
28
|
-
max:'',
|
|
27
|
+
min: '',
|
|
28
|
+
max: '',
|
|
29
|
+
labelColor: '#333',
|
|
30
|
+
tickLabelColor: '#333',
|
|
31
|
+
tickColor: '#333',
|
|
32
|
+
rightHideAxis: true,
|
|
33
|
+
rightAxisSize: 50,
|
|
34
|
+
rightLabelOffsetSize: 0,
|
|
35
|
+
rightAxisLabelColor: '#333',
|
|
36
|
+
rightAxisTickLabelColor: '#333',
|
|
37
|
+
rightAxisTickColor: '#333',
|
|
38
|
+
isLegendValue:false,
|
|
39
|
+
numTicks:''
|
|
40
|
+
|
|
41
|
+
},
|
|
42
|
+
topAxis: {
|
|
43
|
+
hasLine: false
|
|
29
44
|
},
|
|
30
45
|
barThickness: 0.35,
|
|
31
46
|
barHeight: 25,
|
|
@@ -38,27 +53,33 @@ export default {
|
|
|
38
53
|
size: 75,
|
|
39
54
|
tickRotation: 0,
|
|
40
55
|
min: '',
|
|
41
|
-
max:'',
|
|
56
|
+
max: '',
|
|
57
|
+
labelColor: '#333',
|
|
58
|
+
tickLabelColor: '#333',
|
|
59
|
+
tickColor: '#333',
|
|
60
|
+
isLegendValue:false,
|
|
61
|
+
numTicks:''
|
|
42
62
|
},
|
|
43
63
|
table: {
|
|
44
64
|
label: 'Data Table',
|
|
45
65
|
expanded: true,
|
|
46
|
-
limitHeight:false,
|
|
47
|
-
height:
|
|
48
|
-
caption:
|
|
66
|
+
limitHeight: false,
|
|
67
|
+
height: '',
|
|
68
|
+
caption: ''
|
|
49
69
|
},
|
|
50
70
|
orientation: 'vertical',
|
|
51
71
|
legend: {
|
|
52
72
|
behavior: 'isolate',
|
|
53
73
|
position: 'right',
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
74
|
+
singleRow: false,
|
|
75
|
+
colorCode: '',
|
|
76
|
+
reverseLabelOrder: false,
|
|
77
|
+
description: '',
|
|
57
78
|
dynamicLegend: false,
|
|
58
|
-
dynamicLegendDefaultText:
|
|
79
|
+
dynamicLegendDefaultText: 'Show All',
|
|
59
80
|
dynamicLegendItemLimit: 5,
|
|
60
81
|
dynamicLegendItemLimitMessage: 'Dynamic Legend Item Limit Hit.',
|
|
61
|
-
dynamicLegendChartMessage: 'Select Options from the Legend'
|
|
82
|
+
dynamicLegendChartMessage: 'Select Options from the Legend'
|
|
62
83
|
},
|
|
63
84
|
exclusions: {
|
|
64
85
|
active: false,
|
|
@@ -67,7 +88,7 @@ export default {
|
|
|
67
88
|
palette: 'qualitative-bold',
|
|
68
89
|
isPaletteReversed: false,
|
|
69
90
|
labels: false,
|
|
70
|
-
dataFormat: {commas:false,prefix:'',suffix:
|
|
91
|
+
dataFormat: { commas: false, prefix: '', suffix: '' },
|
|
71
92
|
confidenceKeys: {},
|
|
72
93
|
visual: {
|
|
73
94
|
border: true,
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {useState, useEffect} from 'react'
|
|
1
|
+
import { useState, useEffect } from 'react'
|
|
2
2
|
// Use for accessibility testing
|
|
3
3
|
const useActiveElement = () => {
|
|
4
|
-
|
|
4
|
+
const [active, setActive] = useState(document.activeElement)
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const handleFocusIn = e => {
|
|
7
|
+
setActive(document.activeElement)
|
|
8
|
+
}
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
document.addEventListener('focusin', handleFocusIn)
|
|
12
|
+
return () => {
|
|
13
|
+
document.removeEventListener('focusin', handleFocusIn)
|
|
14
|
+
}
|
|
15
|
+
}, [])
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
return active
|
|
18
18
|
}
|
|
19
|
-
export default useActiveElement
|
|
19
|
+
export default useActiveElement
|
|
@@ -1,35 +1,41 @@
|
|
|
1
1
|
export default function useChartClasses(config) {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
let lineDatapointClass = ''
|
|
3
|
+
let barBorderClass = ''
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
if (config.lineDatapointStyle === 'hover') {
|
|
6
|
+
lineDatapointClass = ' chart-line--hover'
|
|
7
|
+
}
|
|
8
|
+
if (config.lineDatapointStyle === 'always show') {
|
|
9
|
+
lineDatapointClass = ' chart-line--always'
|
|
10
|
+
}
|
|
11
|
+
if (config.barHasBorder === 'false') {
|
|
12
|
+
barBorderClass = ' chart-bar--no-border'
|
|
13
|
+
}
|
|
8
14
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
let innerContainerClasses = ['cove-component__inner']
|
|
16
|
+
config.title && innerContainerClasses.push('component--has-title')
|
|
17
|
+
config.subtext && innerContainerClasses.push('component--has-subtext')
|
|
18
|
+
config.biteStyle && innerContainerClasses.push(`bite__style--${config.biteStyle}`)
|
|
19
|
+
config.general?.isCompactStyle && innerContainerClasses.push(`component--isCompactStyle`)
|
|
14
20
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
let contentClasses = ['cove-component__content']
|
|
22
|
+
config.visualizationType === 'Spark Line' && contentClasses.push('sparkline')
|
|
23
|
+
!config.visual?.border && contentClasses.push('no-borders')
|
|
24
|
+
config.visual?.borderColorTheme && contentClasses.push('component--has-borderColorTheme')
|
|
25
|
+
config.visual?.accent && contentClasses.push('component--has-accent')
|
|
26
|
+
config.visual?.background && contentClasses.push('component--has-background')
|
|
27
|
+
config.visual?.hideBackgroundColor && contentClasses.push('component--hideBackgroundColor')
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
let sparkLineStyles = {
|
|
30
|
+
width: '100%',
|
|
31
|
+
height: '100px'
|
|
32
|
+
}
|
|
27
33
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
return {
|
|
35
|
+
barBorderClass,
|
|
36
|
+
lineDatapointClass,
|
|
37
|
+
contentClasses,
|
|
38
|
+
innerContainerClasses,
|
|
39
|
+
sparkLineStyles
|
|
40
|
+
}
|
|
35
41
|
}
|