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