@cdc/chart 4.23.11 → 4.24.2
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 +35740 -35027
- package/examples/feature/bar/additional-column-tooltip.json +446 -0
- package/examples/feature/bar/tall-data.json +98 -0
- package/examples/feature/forest-plot/forest-plot.json +63 -19
- package/examples/feature/forest-plot/linear.json +52 -3
- package/examples/feature/forest-plot/log.json +26 -0
- package/examples/feature/forest-plot/logarithmic.json +0 -35
- package/examples/feature/line/line-chart-preliminary.json +393 -0
- package/examples/feature/regions/index.json +9 -5
- package/examples/feature/scatterplot/scatterplot.json +272 -33
- package/index.html +10 -8
- package/package.json +2 -2
- package/src/CdcChart.tsx +70 -234
- package/src/ConfigContext.tsx +6 -0
- package/src/_stories/ChartEditor.stories.tsx +22 -0
- package/src/_stories/ChartLine.preliminary.tsx +19 -0
- package/src/_stories/_mock/pie_config.json +192 -0
- package/src/_stories/_mock/pie_data.json +218 -0
- package/src/_stories/_mock/preliminary_mock.json +346 -0
- package/src/components/{AreaChart.Stacked.jsx → AreaChart/components/AreaChart.Stacked.jsx} +2 -2
- package/src/components/{AreaChart.jsx → AreaChart/components/AreaChart.jsx} +2 -26
- package/src/components/AreaChart/index.tsx +4 -0
- package/src/components/{BarChart.Horizontal.tsx → BarChart/components/BarChart.Horizontal.tsx} +8 -8
- package/src/components/{BarChart.StackedHorizontal.tsx → BarChart/components/BarChart.StackedHorizontal.tsx} +37 -7
- package/src/components/BarChart/components/BarChart.StackedVertical.tsx +108 -0
- package/src/components/{BarChart.Vertical.tsx → BarChart/components/BarChart.Vertical.tsx} +53 -70
- package/src/components/BarChart/components/BarChart.jsx +39 -0
- package/src/components/{BarChartType.jsx → BarChart/components/BarChartType.jsx} +0 -2
- package/src/components/BarChart/components/context.tsx +13 -0
- package/src/components/BarChart/index.tsx +3 -0
- package/src/components/{BoxPlot.jsx → BoxPlot/BoxPlot.jsx} +10 -9
- package/src/components/BoxPlot/index.tsx +3 -0
- package/src/components/EditorPanel/EditorPanel.tsx +2776 -0
- package/src/components/EditorPanel/EditorPanelContext.ts +40 -0
- package/src/components/EditorPanel/components/PanelProps.ts +3 -0
- package/src/components/EditorPanel/components/Panels/Panel.BoxPlot.tsx +148 -0
- package/src/components/{ForestPlotSettings.jsx → EditorPanel/components/Panels/Panel.ForestPlotSettings.tsx} +97 -167
- package/src/components/EditorPanel/components/Panels/Panel.General.tsx +160 -0
- package/src/components/EditorPanel/components/Panels/Panel.Regions.tsx +168 -0
- package/src/components/{Series.jsx → EditorPanel/components/Panels/Panel.Series.tsx} +4 -4
- package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +297 -0
- package/src/components/EditorPanel/components/Panels/index.tsx +17 -0
- package/src/components/EditorPanel/components/panels.scss +72 -0
- package/src/components/EditorPanel/editor-panel.scss +739 -0
- package/src/components/EditorPanel/index.tsx +3 -0
- package/src/{hooks → components/EditorPanel}/useEditorPermissions.js +34 -2
- package/src/components/{Forecasting.jsx → Forecasting/Forecasting.jsx} +1 -1
- package/src/components/Forecasting/index.tsx +3 -0
- package/src/components/ForestPlot/ForestPlot.tsx +254 -0
- package/src/components/ForestPlot/ForestPlotProps.ts +7 -0
- package/src/components/ForestPlot/index.tsx +1 -209
- package/src/components/Legend/Legend.Component.tsx +199 -0
- package/src/components/Legend/Legend.tsx +28 -0
- package/src/components/Legend/helpers/createFormatLabels.tsx +140 -0
- package/src/components/Legend/index.tsx +3 -0
- package/src/components/LineChart/LineChartProps.ts +29 -0
- package/src/components/LineChart/components/LineChart.Circle.tsx +147 -0
- package/src/components/LineChart/helpers.ts +45 -0
- package/src/components/LineChart/index.tsx +111 -23
- package/src/components/LinearChart.jsx +55 -72
- package/src/components/PairedBarChart.jsx +4 -2
- package/src/components/{PieChart.jsx → PieChart/PieChart.tsx} +93 -31
- package/src/components/PieChart/index.tsx +3 -0
- package/src/components/Regions/components/Regions.tsx +144 -0
- package/src/components/Regions/index.tsx +3 -0
- package/src/components/{ScatterPlot.jsx → ScatterPlot/ScatterPlot.jsx} +3 -3
- package/src/components/ScatterPlot/index.tsx +3 -0
- package/src/components/{SparkLine.jsx → Sparkline/SparkLine.jsx} +2 -2
- package/src/components/Sparkline/index.tsx +3 -0
- package/src/data/initial-state.js +10 -8
- package/src/helpers/abbreviateNumber.ts +17 -0
- package/src/helpers/computeMarginBottom.ts +55 -0
- package/src/helpers/filterData.ts +18 -0
- package/src/helpers/generateColorsArray.ts +8 -0
- package/src/helpers/getQuartiles.ts +30 -0
- package/src/helpers/handleChartAriaLabels.ts +19 -0
- package/src/helpers/handleLineType.ts +18 -0
- package/src/helpers/lineOptions.ts +18 -0
- package/src/helpers/sort.ts +7 -0
- package/src/helpers/tests/computeMarginBottom.test.ts +20 -0
- package/src/hooks/useBarChart.js +7 -6
- package/src/hooks/useHighlightedBars.js +1 -1
- package/src/hooks/useMinMax.ts +3 -3
- package/src/hooks/useScales.ts +19 -6
- package/src/hooks/{useTooltip.jsx → useTooltip.tsx} +31 -25
- package/src/scss/main.scss +0 -3
- package/src/types/ChartConfig.ts +167 -23
- package/src/types/ChartContext.ts +34 -12
- package/src/types/ForestPlot.ts +7 -14
- package/src/types/Label.ts +7 -0
- package/examples/feature/scatterplot/scatterplot-continuous.csv +0 -17
- package/src/ConfigContext.jsx +0 -5
- package/src/components/BarChart.StackedVertical.tsx +0 -91
- package/src/components/BarChart.jsx +0 -30
- package/src/components/EditorPanel.jsx +0 -3356
- package/src/components/ForestPlot/Readme.md +0 -0
- package/src/components/Legend.jsx +0 -310
- package/src/components/LineChart/LineChart.Circle.tsx +0 -105
- package/src/scss/LinearChart.scss +0 -0
- package/src/scss/editor-panel.scss +0 -745
- package/src/scss/legend.scss +0 -206
- package/src/scss/mixins.scss +0 -0
- package/src/scss/variables.scss +0 -1
- package/src/types/ChartProps.ts +0 -7
|
@@ -1,30 +1,55 @@
|
|
|
1
1
|
import React, { useContext, useState } from 'react'
|
|
2
|
-
import ConfigContext from '
|
|
3
|
-
import {
|
|
2
|
+
import ConfigContext from '../../../ConfigContext'
|
|
3
|
+
import { type ChartContext } from '../../../types/ChartContext'
|
|
4
|
+
import { useBarChart } from '../../../hooks/useBarChart'
|
|
4
5
|
import { Group } from '@visx/group'
|
|
5
6
|
import { Text } from '@visx/text'
|
|
6
7
|
import { BarGroup } from '@visx/shape'
|
|
7
|
-
import { useHighlightedBars } from '
|
|
8
|
+
import { useHighlightedBars } from '../../../hooks/useHighlightedBars'
|
|
8
9
|
import { FaStar } from 'react-icons/fa'
|
|
10
|
+
import Regions from './../../Regions'
|
|
9
11
|
|
|
10
12
|
// third party
|
|
11
13
|
import chroma from 'chroma-js'
|
|
14
|
+
import BarChartContext, { type BarChartContextValues } from './context'
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export const BarChartVertical = (props: BarChartProps) => {
|
|
16
|
-
const { xScale, yScale, xMax, yMax, seriesScale } = props
|
|
16
|
+
export const BarChartVertical = () => {
|
|
17
|
+
const { xScale, yScale, xMax, yMax, seriesScale } = useContext<BarChartContextValues>(BarChartContext)
|
|
17
18
|
|
|
18
19
|
const [barWidth, setBarWidth] = useState(0)
|
|
19
20
|
const [totalBarsInGroup, setTotalBarsInGroup] = useState(0)
|
|
20
21
|
|
|
21
|
-
const { barBorderWidth, hasMultipleSeries, applyRadius, updateBars, assignColorsToValues, section, lollipopBarWidth, lollipopShapeSize, getHighlightedBarColorByValue, getHighlightedBarByValue, generateIconSize, getAdditionalColumn, hoveredBar, onMouseOverBar, onMouseLeaveBar } = useBarChart()
|
|
22
|
-
|
|
23
|
-
// CONTEXT VALUES
|
|
24
22
|
// prettier-ignore
|
|
25
|
-
const {
|
|
23
|
+
const {
|
|
24
|
+
applyRadius,
|
|
25
|
+
assignColorsToValues,
|
|
26
|
+
barBorderWidth,
|
|
27
|
+
generateIconSize,
|
|
28
|
+
getAdditionalColumn,
|
|
29
|
+
getHighlightedBarByValue,
|
|
30
|
+
getHighlightedBarColorByValue,
|
|
31
|
+
lollipopBarWidth,
|
|
32
|
+
lollipopShapeSize,
|
|
33
|
+
onMouseLeaveBar,
|
|
34
|
+
onMouseOverBar,
|
|
35
|
+
section
|
|
36
|
+
} = useBarChart()
|
|
26
37
|
|
|
27
|
-
|
|
38
|
+
// prettier-ignore
|
|
39
|
+
const {
|
|
40
|
+
colorScale,
|
|
41
|
+
config,
|
|
42
|
+
dashboardConfig,
|
|
43
|
+
formatDate,
|
|
44
|
+
formatNumber,
|
|
45
|
+
getXAxisData,
|
|
46
|
+
getYAxisData,
|
|
47
|
+
isNumber,
|
|
48
|
+
parseDate,
|
|
49
|
+
seriesHighlight,
|
|
50
|
+
setSharedFilter,
|
|
51
|
+
transformedData,
|
|
52
|
+
} = useContext<ChartContext>(ConfigContext)
|
|
28
53
|
|
|
29
54
|
const { HighLightedBarUtils } = useHighlightedBars(config)
|
|
30
55
|
const data = config.brush.active && config.brush.data?.length ? config.brush.data : transformedData
|
|
@@ -48,7 +73,10 @@ export const BarChartVertical = (props: BarChartProps) => {
|
|
|
48
73
|
data={data}
|
|
49
74
|
keys={config.runtime.barSeriesKeys || config.runtime.seriesKeys}
|
|
50
75
|
height={yMax}
|
|
51
|
-
x0={d =>
|
|
76
|
+
x0={d => {
|
|
77
|
+
const rawXValue = d[config.runtime.originalXAxis.dataKey]
|
|
78
|
+
return config.runtime.xAxis.type === 'date' ? parseDate(rawXValue) : rawXValue
|
|
79
|
+
}}
|
|
52
80
|
x0Scale={xScale}
|
|
53
81
|
x1Scale={seriesScale}
|
|
54
82
|
yScale={yScale}
|
|
@@ -58,7 +86,7 @@ export const BarChartVertical = (props: BarChartProps) => {
|
|
|
58
86
|
>
|
|
59
87
|
{barGroups => {
|
|
60
88
|
return barGroups.map((barGroup, index) => (
|
|
61
|
-
<Group className={`bar-group-${barGroup.index}-${barGroup.x0}--${index} ${config.orientation}`} key={`bar-group-${barGroup.index}-${barGroup.x0}--${index}`} id={`bar-group-${barGroup.index}-${barGroup.x0}--${index}`} left={
|
|
89
|
+
<Group className={`bar-group-${barGroup.index}-${barGroup.x0}--${index} ${config.orientation}`} key={`bar-group-${barGroup.index}-${barGroup.x0}--${index}`} id={`bar-group-${barGroup.index}-${barGroup.x0}--${index}`} left={barGroup.x0}>
|
|
62
90
|
{barGroup.bars.map((bar, index) => {
|
|
63
91
|
const scaleVal = config.useLogScale ? 0.1 : 0
|
|
64
92
|
const suppresedBarHeight = 20
|
|
@@ -71,14 +99,10 @@ export const BarChartVertical = (props: BarChartProps) => {
|
|
|
71
99
|
const supprssedBarY = bar.value >= 0 && isNumber(bar.value) ? yScale(scaleVal) - suppresedBarHeight : yScale(0)
|
|
72
100
|
const barY = config.suppressedData.some(d => bar.key === d.column && String(bar.value) === String(d.value)) ? supprssedBarY : barYBase
|
|
73
101
|
|
|
74
|
-
let barGroupWidth =
|
|
75
|
-
let offset = ((xMax / barGroups.length) * (1 - (config.barThickness || 0.8))) / 2
|
|
76
|
-
// configure left side offset of lollipop bars
|
|
77
|
-
if (config.isLollipopChart) {
|
|
78
|
-
offset = xMax / barGroups.length / 2 - lollipopBarWidth / 2
|
|
79
|
-
}
|
|
102
|
+
let barGroupWidth = seriesScale.range()[1]
|
|
80
103
|
|
|
81
104
|
let barWidth = config.isLollipopChart ? lollipopBarWidth : barGroupWidth / barGroup.bars.length
|
|
105
|
+
let barX = bar.x + (config.isLollipopChart ? (((barGroupWidth / barGroup.bars.length) - lollipopBarWidth) / 2) : 0) - (config.xAxis.type === 'date' && config.xAxis.sortDates ? barGroupWidth / 2 : 0)
|
|
82
106
|
setBarWidth(barWidth)
|
|
83
107
|
setTotalBarsInGroup(barGroup.bars.length)
|
|
84
108
|
|
|
@@ -89,14 +113,15 @@ export const BarChartVertical = (props: BarChartProps) => {
|
|
|
89
113
|
const newIndex = bar.value < 0 ? -1 : index
|
|
90
114
|
const borderRadius = applyRadius(newIndex)
|
|
91
115
|
// tooltips
|
|
92
|
-
|
|
116
|
+
|
|
117
|
+
const additionalColTooltip = getAdditionalColumn(bar.key, data[barGroup.index][config.runtime.originalXAxis.dataKey])
|
|
93
118
|
let xAxisTooltip = config.runtime.xAxis.label ? `${config.runtime.xAxis.label}: ${xAxisValue}` : xAxisValue
|
|
94
119
|
const tooltipBody = `${config.runtime.seriesLabels[bar.key]}: ${yAxisValue}`
|
|
95
120
|
|
|
96
121
|
const tooltip = `<ul>
|
|
97
122
|
<li class="tooltip-heading">${xAxisTooltip}</li>
|
|
98
123
|
<li class="tooltip-body ">${tooltipBody}</li>
|
|
99
|
-
|
|
124
|
+
${additionalColTooltip ? '<li class="tooltip-body ">' + additionalColTooltip + '</li>' : ''}
|
|
100
125
|
</li></ul>`
|
|
101
126
|
|
|
102
127
|
// configure colors
|
|
@@ -201,7 +226,7 @@ export const BarChartVertical = (props: BarChartProps) => {
|
|
|
201
226
|
style={{ overflow: 'visible', transition: 'all 0.2s linear' }}
|
|
202
227
|
id={`barGroup${barGroup.index}`}
|
|
203
228
|
key={`bar-group-bar-${barGroup.index}-${bar.index}-${bar.value}-${bar.key}`}
|
|
204
|
-
x={
|
|
229
|
+
x={barX}
|
|
205
230
|
y={barY}
|
|
206
231
|
width={barWidth}
|
|
207
232
|
height={barHeight}
|
|
@@ -226,7 +251,7 @@ export const BarChartVertical = (props: BarChartProps) => {
|
|
|
226
251
|
<Text // prettier-ignore
|
|
227
252
|
display={config.labels && displayBar ? 'block' : 'none'}
|
|
228
253
|
opacity={transparentBar ? 0.5 : 1}
|
|
229
|
-
x={
|
|
254
|
+
x={barX + barWidth / 2}
|
|
230
255
|
y={barY - 5}
|
|
231
256
|
fill={labelColor}
|
|
232
257
|
textAnchor='middle'
|
|
@@ -237,7 +262,7 @@ export const BarChartVertical = (props: BarChartProps) => {
|
|
|
237
262
|
{config.isLollipopChart && config.lollipopShape === 'circle' && (
|
|
238
263
|
<circle
|
|
239
264
|
display={displaylollipopShape}
|
|
240
|
-
cx={
|
|
265
|
+
cx={barX + lollipopShapeSize / 3.5}
|
|
241
266
|
cy={bar.y}
|
|
242
267
|
r={lollipopShapeSize / 2}
|
|
243
268
|
fill={barColor}
|
|
@@ -250,7 +275,7 @@ export const BarChartVertical = (props: BarChartProps) => {
|
|
|
250
275
|
{config.isLollipopChart && config.lollipopShape === 'square' && (
|
|
251
276
|
<rect
|
|
252
277
|
display={displaylollipopShape}
|
|
253
|
-
x={
|
|
278
|
+
x={barX - lollipopBarWidth / 2}
|
|
254
279
|
y={barY}
|
|
255
280
|
width={lollipopShapeSize}
|
|
256
281
|
height={lollipopShapeSize}
|
|
@@ -278,7 +303,7 @@ export const BarChartVertical = (props: BarChartProps) => {
|
|
|
278
303
|
let upperPos
|
|
279
304
|
let lowerPos
|
|
280
305
|
let tickWidth = 5
|
|
281
|
-
xPos = xScale(getXAxisData(d))
|
|
306
|
+
xPos = xScale(getXAxisData(d)) + (config.xAxis.type !== 'date' || !config.xAxis.sortDates ? seriesScale.range()[1] / 2 : 0)
|
|
282
307
|
upperPos = yScale(getYAxisData(d, config.confidenceKeys.lower))
|
|
283
308
|
lowerPos = yScale(getYAxisData(d, config.confidenceKeys.upper))
|
|
284
309
|
return (
|
|
@@ -298,49 +323,7 @@ export const BarChartVertical = (props: BarChartProps) => {
|
|
|
298
323
|
})
|
|
299
324
|
: ''}
|
|
300
325
|
|
|
301
|
-
{
|
|
302
|
-
? config.regions.map(region => {
|
|
303
|
-
if (!Object.keys(region).includes('from') || !Object.keys(region).includes('to')) return null
|
|
304
|
-
|
|
305
|
-
let from
|
|
306
|
-
let to
|
|
307
|
-
let width
|
|
308
|
-
|
|
309
|
-
if (config.xAxis.type === 'date') {
|
|
310
|
-
from = xScale(parseDate(region.from).getTime()) - (barWidth * totalBarsInGroup) / 2
|
|
311
|
-
to = xScale(parseDate(region.to).getTime()) + (barWidth * totalBarsInGroup) / 2
|
|
312
|
-
|
|
313
|
-
width = to - from
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
if (config.xAxis.type === 'categorical') {
|
|
317
|
-
from = xScale(region.from)
|
|
318
|
-
to = xScale(region.to)
|
|
319
|
-
width = to - from
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
if (!from) return null
|
|
323
|
-
if (!to) return null
|
|
324
|
-
|
|
325
|
-
return (
|
|
326
|
-
<Group className='regions' left={0} key={region.label}>
|
|
327
|
-
<path
|
|
328
|
-
stroke='#333'
|
|
329
|
-
d={`M${from} -5
|
|
330
|
-
L${from} 5
|
|
331
|
-
M${from} 0
|
|
332
|
-
L${to} 0
|
|
333
|
-
M${to} -5
|
|
334
|
-
L${to} 5`}
|
|
335
|
-
/>
|
|
336
|
-
<rect x={from} y={0} width={width} height={yMax} fill={region.background} opacity={0.3} />
|
|
337
|
-
<Text x={from + width / 2} y={5} fill={region.color} verticalAnchor='start' textAnchor='middle'>
|
|
338
|
-
{region.label}
|
|
339
|
-
</Text>
|
|
340
|
-
</Group>
|
|
341
|
-
)
|
|
342
|
-
})
|
|
343
|
-
: ''}
|
|
326
|
+
<Regions xScale={xScale} yMax={yMax} barWidth={barWidth} totalBarsInGroup={totalBarsInGroup} />
|
|
344
327
|
</Group>
|
|
345
328
|
)
|
|
346
329
|
)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, { useContext } from 'react'
|
|
2
|
+
|
|
3
|
+
// visx
|
|
4
|
+
import { Group } from '@visx/group'
|
|
5
|
+
import { Bar } from '@visx/shape'
|
|
6
|
+
|
|
7
|
+
// cdc
|
|
8
|
+
import BarChartType from './BarChartType'
|
|
9
|
+
import ErrorBoundary from '@cdc/core/components/ErrorBoundary'
|
|
10
|
+
import ConfigContext from '../../../ConfigContext'
|
|
11
|
+
import BarChartContext from './context'
|
|
12
|
+
|
|
13
|
+
const BarChart = ({ xScale, yScale, seriesScale, xMax, yMax, handleTooltipMouseOver, handleTooltipMouseOff, handleTooltipClick }) => {
|
|
14
|
+
const { transformedData: data, config } = useContext(ConfigContext)
|
|
15
|
+
|
|
16
|
+
const contextValues = {
|
|
17
|
+
xScale,
|
|
18
|
+
yScale,
|
|
19
|
+
xMax,
|
|
20
|
+
yMax,
|
|
21
|
+
seriesScale
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<ErrorBoundary component='BarChart'>
|
|
26
|
+
<BarChartContext.Provider value={contextValues}>
|
|
27
|
+
<Group left={parseFloat(config.runtime.yAxis.size)}>
|
|
28
|
+
<BarChartType.StackedVertical />
|
|
29
|
+
<BarChartType.StackedHorizontal />
|
|
30
|
+
<BarChartType.Vertical />
|
|
31
|
+
<BarChartType.Horizontal />
|
|
32
|
+
<Bar key={'bars'} display={config.tooltips.singleSeries ? 'none' : 'block'} width={Number(xMax)} height={Number(yMax)} fill={'transparent'} fillOpacity={0.05} onMouseMove={e => handleTooltipMouseOver(e, data)} onMouseOut={handleTooltipMouseOff} onClick={e => handleTooltipClick(e, data)} />
|
|
33
|
+
</Group>
|
|
34
|
+
</BarChartContext.Provider>
|
|
35
|
+
</ErrorBoundary>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default BarChart
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createContext } from 'react'
|
|
2
|
+
|
|
3
|
+
const BarChartContext = createContext(null)
|
|
4
|
+
|
|
5
|
+
export type BarChartContextValues = {
|
|
6
|
+
xMax: number
|
|
7
|
+
yMax: number
|
|
8
|
+
xScale: Function
|
|
9
|
+
yScale: Function
|
|
10
|
+
seriesScale: Function
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default BarChartContext
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React, { useContext, useEffect } from 'react'
|
|
2
2
|
import { BoxPlot } from '@visx/stats'
|
|
3
3
|
import { Group } from '@visx/group'
|
|
4
|
-
import ConfigContext from '
|
|
4
|
+
import ConfigContext from '../../ConfigContext'
|
|
5
5
|
import ErrorBoundary from '@cdc/core/components/ErrorBoundary'
|
|
6
6
|
import { colorPalettesChart } from '@cdc/core/data/colorPalettes'
|
|
7
7
|
|
|
8
8
|
const CoveBoxPlot = ({ xScale, yScale }) => {
|
|
9
9
|
const { config, setConfig } = useContext(ConfigContext)
|
|
10
|
+
const { boxplot } = config
|
|
10
11
|
|
|
11
12
|
useEffect(() => {
|
|
12
13
|
if (config.legend.hide === false) {
|
|
@@ -25,10 +26,10 @@ const CoveBoxPlot = ({ xScale, yScale }) => {
|
|
|
25
26
|
const handleTooltip = d => {
|
|
26
27
|
return `
|
|
27
28
|
<strong>${d.columnCategory}</strong></br>
|
|
28
|
-
${
|
|
29
|
-
${
|
|
30
|
-
${
|
|
31
|
-
${
|
|
29
|
+
${boxplot.labels.q1}: ${d.columnFirstQuartile}<br/>
|
|
30
|
+
${boxplot.labels.q3}: ${d.columnThirdQuartile}<br/>
|
|
31
|
+
${boxplot.labels.iqr}: ${d.columnIqr}<br/>
|
|
32
|
+
${boxplot.labels.median}: ${d.columnMedian}
|
|
32
33
|
`
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -46,12 +47,12 @@ const CoveBoxPlot = ({ xScale, yScale }) => {
|
|
|
46
47
|
return (
|
|
47
48
|
<ErrorBoundary component='BoxPlot'>
|
|
48
49
|
<Group className='boxplot' key={`boxplot-group`}>
|
|
49
|
-
{
|
|
50
|
+
{boxplot.plots.map((d, i) => {
|
|
50
51
|
const offset = boxWidth - constrainedWidth
|
|
51
52
|
const radius = 4
|
|
52
53
|
return (
|
|
53
54
|
<Group key={`boxplotplot-${i}`}>
|
|
54
|
-
{
|
|
55
|
+
{boxplot.plotNonOutlierValues &&
|
|
55
56
|
d.nonOutlierValues.map((value, index) => {
|
|
56
57
|
return <circle cx={xScale(d.columnCategory) + Number(config.yAxis.size) + boxWidth / 2} cy={yScale(value)} r={radius} fill={'#ccc'} style={{ opacity: 1, fillOpacity: 1, stroke: 'black' }} key={`boxplot-${i}--circle-${index}`} />
|
|
57
58
|
})}
|
|
@@ -69,7 +70,7 @@ const CoveBoxPlot = ({ xScale, yScale }) => {
|
|
|
69
70
|
fillOpacity={fillOpacity}
|
|
70
71
|
stroke='black'
|
|
71
72
|
valueScale={yScale}
|
|
72
|
-
outliers={
|
|
73
|
+
outliers={boxplot.plotOutlierValues ? d.columnOutliers : []}
|
|
73
74
|
outlierProps={{
|
|
74
75
|
style: {
|
|
75
76
|
fill: `${color_0}`,
|
|
@@ -84,7 +85,7 @@ const CoveBoxPlot = ({ xScale, yScale }) => {
|
|
|
84
85
|
boxProps={{
|
|
85
86
|
style: {
|
|
86
87
|
stroke: 'black',
|
|
87
|
-
strokeWidth:
|
|
88
|
+
strokeWidth: boxplot.borders === 'true' ? 1 : 0
|
|
88
89
|
}
|
|
89
90
|
}}
|
|
90
91
|
maxProps={{
|