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