@cdc/chart 4.24.5 → 4.24.9
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 +44197 -38258
- package/examples/cases-year.json +13379 -0
- package/examples/feature/annotations/index.json +542 -0
- package/examples/gallery/bar-chart-vertical/combo-line-chart.json +76 -15
- package/examples/gallery/bar-chart-vertical/vertical-bar-chart-stacked.json +5 -5
- package/examples/xaxis.json +493 -0
- package/index.html +20 -10
- package/package.json +5 -4
- package/src/CdcChart.tsx +462 -172
- package/src/_stories/Chart.Legend.Gradient.tsx +19 -0
- package/src/_stories/Chart.stories.tsx +18 -171
- package/src/_stories/ChartAnnotation.stories.tsx +32 -0
- package/src/_stories/_mock/annotation_category_mock.json +473 -0
- package/src/_stories/_mock/annotation_date-linear_mock.json +530 -0
- package/{examples/feature/line/line-chart.json → src/_stories/_mock/annotation_date-time_mock.json} +150 -69
- package/src/_stories/_mock/legend.gradient_mock.json +236 -0
- package/src/_stories/_mock/line_chart_two_points_new_chart.json +128 -0
- package/src/_stories/_mock/line_chart_two_points_regression_test.json +127 -0
- package/src/_stories/_mock/lollipop.json +171 -0
- package/src/components/Annotations/components/AnnotationDraggable.styles.css +31 -0
- package/src/components/Annotations/components/AnnotationDraggable.tsx +207 -0
- package/src/components/Annotations/components/AnnotationDropdown.styles.css +14 -0
- package/src/components/Annotations/components/AnnotationDropdown.tsx +72 -0
- package/src/components/Annotations/components/AnnotationList.styles.css +45 -0
- package/src/components/Annotations/components/AnnotationList.tsx +42 -0
- package/src/components/Annotations/components/findNearestDatum.ts +138 -0
- package/src/components/Annotations/components/helpers/index.tsx +46 -0
- package/src/components/Annotations/index.tsx +13 -0
- package/src/components/AreaChart/components/AreaChart.Stacked.jsx +1 -1
- package/src/components/AreaChart/components/AreaChart.jsx +1 -1
- package/src/components/Axis/Categorical.Axis.tsx +145 -0
- package/src/components/BarChart/components/BarChart.Horizontal.tsx +47 -44
- package/src/components/BarChart/components/BarChart.StackedHorizontal.tsx +0 -1
- package/src/components/BarChart/components/BarChart.StackedVertical.tsx +11 -14
- package/src/components/BarChart/components/BarChart.Vertical.tsx +67 -30
- package/src/components/BarChart/helpers/index.ts +91 -0
- package/src/components/BrushChart.tsx +205 -0
- package/src/components/EditorPanel/EditorPanel.tsx +1794 -403
- package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +320 -0
- package/src/components/EditorPanel/components/Panels/Panel.General.tsx +282 -18
- package/src/components/EditorPanel/components/Panels/Panel.Sankey.tsx +43 -8
- package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +4 -4
- package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +4 -13
- package/src/components/EditorPanel/components/Panels/index.tsx +3 -1
- package/src/components/EditorPanel/components/panels.scss +4 -0
- package/src/components/EditorPanel/editor-panel.scss +35 -3
- package/src/components/EditorPanel/{useEditorPermissions.js → useEditorPermissions.ts} +105 -17
- package/src/components/Legend/Legend.Component.tsx +185 -194
- package/src/components/Legend/Legend.Suppression.tsx +146 -0
- package/src/components/Legend/Legend.tsx +21 -5
- package/src/components/Legend/helpers/createFormatLabels.tsx +1 -1
- package/src/components/Legend/helpers/index.ts +35 -0
- package/src/components/LegendWrapper.tsx +26 -0
- package/src/components/LineChart/LineChartProps.ts +1 -15
- package/src/components/LineChart/components/LineChart.BumpCircle.tsx +103 -0
- package/src/components/LineChart/components/LineChart.Circle.tsx +47 -8
- package/src/components/LineChart/helpers.ts +72 -14
- package/src/components/LineChart/index.tsx +117 -42
- package/src/components/LinearChart.jsx +179 -136
- package/src/components/LinearChart.tsx +1366 -0
- package/src/components/PairedBarChart.jsx +9 -9
- package/src/components/PieChart/PieChart.tsx +75 -18
- package/src/components/Sankey/index.tsx +89 -30
- package/src/components/ScatterPlot/ScatterPlot.jsx +22 -8
- package/src/components/Sparkline/components/SparkLine.tsx +2 -2
- package/src/components/ZoomBrush.tsx +90 -44
- package/src/data/initial-state.js +25 -7
- package/src/helpers/handleChartTabbing.ts +8 -0
- package/src/helpers/isConvertLineToBarGraph.ts +4 -0
- package/src/hooks/{useBarChart.js → useBarChart.ts} +2 -40
- package/src/hooks/useColorScale.ts +1 -1
- package/src/hooks/useLegendClasses.ts +68 -0
- package/src/hooks/useMinMax.ts +12 -7
- package/src/hooks/useScales.ts +58 -26
- package/src/hooks/useTooltip.tsx +135 -25
- package/src/scss/DataTable.scss +2 -1
- package/src/scss/main.scss +128 -28
- package/src/types/ChartConfig.ts +83 -10
- package/src/types/ChartContext.ts +14 -4
- package/tests-examples/helpers/testZeroValue.test.ts +30 -0
- package/LICENSE +0 -201
- package/src/components/BrushHandle.jsx +0 -17
- package/src/components/LineChart/index.scss +0 -1
- package/src/helpers/filterData.ts +0 -18
- package/src/helpers/tests/computeMarginBottom.test.ts +0 -21
- package/src/hooks/useLegendClasses.js +0 -31
- /package/src/hooks/{useReduceData.js → useReduceData.ts} +0 -0
|
@@ -3,7 +3,12 @@ import ConfigContext from '../../../../ConfigContext'
|
|
|
3
3
|
import { CheckBox, TextField } from '@cdc/core/components/EditorPanel/Inputs'
|
|
4
4
|
import Button from '@cdc/core/components/elements/Button'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
AccordionItem,
|
|
8
|
+
AccordionItemHeading,
|
|
9
|
+
AccordionItemPanel,
|
|
10
|
+
AccordionItemButton
|
|
11
|
+
} from 'react-accessible-accordion'
|
|
7
12
|
import EditorPanelContext, { type EditorPanelContext as EPContext } from '../../EditorPanelContext'
|
|
8
13
|
|
|
9
14
|
const SankeySettings = () => {
|
|
@@ -64,27 +69,51 @@ const SankeySettings = () => {
|
|
|
64
69
|
<AccordionItemButton>Sankey Settings</AccordionItemButton>
|
|
65
70
|
</AccordionItemHeading>
|
|
66
71
|
<AccordionItemPanel>
|
|
72
|
+
<p>
|
|
73
|
+
Node stories can provide additional details to support public health messaging. COVE can display a maximum of
|
|
74
|
+
3 node stories.
|
|
75
|
+
</p>
|
|
67
76
|
{data?.storyNodeText &&
|
|
68
77
|
data?.storyNodeText.map(({ StoryNode, segmentTextBefore, segmentTextAfter }, i) => (
|
|
69
|
-
<div
|
|
78
|
+
<div
|
|
79
|
+
key={i}
|
|
80
|
+
style={{ border: '1px solid black', margin: '15px auto', padding: '15px', borderRadius: '10px' }}
|
|
81
|
+
>
|
|
70
82
|
<label>
|
|
71
83
|
Story Node Text
|
|
72
|
-
<input
|
|
84
|
+
<input
|
|
85
|
+
type='text'
|
|
86
|
+
value={StoryNode}
|
|
87
|
+
fieldName='StoryNode'
|
|
88
|
+
label='StoryNode'
|
|
89
|
+
onChange={e => updateStoryNode('StoryNode', e.target.value, i)}
|
|
90
|
+
/>
|
|
73
91
|
</label>
|
|
74
92
|
<label>
|
|
75
93
|
Story Text Before
|
|
76
|
-
<input
|
|
94
|
+
<input
|
|
95
|
+
type='text'
|
|
96
|
+
value={segmentTextBefore}
|
|
97
|
+
fieldName='segmentTextBefore'
|
|
98
|
+
label='Segment Text Before'
|
|
99
|
+
onChange={e => updateStoryNode('segmentTextBefore', e.target.value, i)}
|
|
100
|
+
/>
|
|
77
101
|
</label>
|
|
78
102
|
<label>
|
|
79
103
|
Story Text After
|
|
80
|
-
<input
|
|
104
|
+
<input
|
|
105
|
+
type='text'
|
|
106
|
+
value={segmentTextAfter}
|
|
107
|
+
fieldName='segmentTextAfter'
|
|
108
|
+
label='Segment Text After'
|
|
109
|
+
onChange={e => updateStoryNode('segmentTextAfter', e.target.value, i)}
|
|
110
|
+
/>
|
|
81
111
|
</label>
|
|
82
112
|
<Button onClick={e => removeStoryNode(i)} className='btn' style={{ background: 'tomato' }}>
|
|
83
113
|
Remove Story Node
|
|
84
114
|
</Button>
|
|
85
115
|
</div>
|
|
86
116
|
))}
|
|
87
|
-
{`Total Story Nodes: ${data?.storyNodeText?.length}`}
|
|
88
117
|
{data?.storyNodeText?.length < 3 && (
|
|
89
118
|
<button
|
|
90
119
|
type='button'
|
|
@@ -97,8 +126,14 @@ const SankeySettings = () => {
|
|
|
97
126
|
Add StoryNode
|
|
98
127
|
</button>
|
|
99
128
|
)}
|
|
100
|
-
|
|
101
|
-
|
|
129
|
+
{config.data?.[0]?.tooltips?.length > 0 && (
|
|
130
|
+
<CheckBox
|
|
131
|
+
value={config.enableTooltips}
|
|
132
|
+
fieldName='enableTooltips'
|
|
133
|
+
label='Enable Tooltips'
|
|
134
|
+
updateField={updateField}
|
|
135
|
+
/>
|
|
136
|
+
)}
|
|
102
137
|
</AccordionItemPanel>
|
|
103
138
|
</AccordionItem>
|
|
104
139
|
)
|
|
@@ -59,7 +59,7 @@ const SeriesDropdownLineType = props => {
|
|
|
59
59
|
const supportsLineType = () => {
|
|
60
60
|
let supported = false
|
|
61
61
|
if (config.visualizationSubType === 'stacked') return supported
|
|
62
|
-
const supportedCharts = ['Line', 'dashed-sm', 'dashed-md', 'dashed-lg', 'Area Chart']
|
|
62
|
+
const supportedCharts = ['Line', 'dashed-sm', 'dashed-md', 'dashed-lg', 'Area Chart', 'Bump Chart']
|
|
63
63
|
if (supportedCharts.some(item => item.includes(series.type))) {
|
|
64
64
|
supported = true
|
|
65
65
|
}
|
|
@@ -111,7 +111,7 @@ const SeriesDropdownSeriesType = props => {
|
|
|
111
111
|
Forecasting: 'Forecasting'
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
if (config.visualizationType === 'Line') {
|
|
114
|
+
if (config.visualizationType === 'Line' || config.visualizationType === 'Bump Chart') {
|
|
115
115
|
return {
|
|
116
116
|
Line: 'Line',
|
|
117
117
|
'dashed-sm': 'Small Dashed',
|
|
@@ -122,7 +122,7 @@ const SeriesDropdownSeriesType = props => {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
// Allowable changes
|
|
125
|
-
if (!['Line', 'Combo'].includes(config.visualizationType)) return
|
|
125
|
+
if (!['Line', 'Combo', 'Bump Chart'].includes(config.visualizationType)) return
|
|
126
126
|
return (
|
|
127
127
|
<InputSelect
|
|
128
128
|
initial='Select an option'
|
|
@@ -468,7 +468,7 @@ const SeriesInputWeight = props => {
|
|
|
468
468
|
const SeriesInputName = props => {
|
|
469
469
|
const { series, index: i } = props
|
|
470
470
|
const { config, updateConfig } = useContext(ConfigContext)
|
|
471
|
-
const adjustableNameSeriesTypes = ['Bar', 'Line', 'Area Chart', 'Combo', 'Deviation
|
|
471
|
+
const adjustableNameSeriesTypes = ['Bump Chart', 'Bar', 'Line', 'Area Chart', 'Combo', 'Deviation', 'Paired', 'Scatter', 'dashed-sm', 'dashed-md', 'dashed-lg']
|
|
472
472
|
|
|
473
473
|
if (!adjustableNameSeriesTypes.includes(series.type)) return
|
|
474
474
|
|
|
@@ -22,7 +22,8 @@ const PanelVisual: FC<PanelProps> = props => {
|
|
|
22
22
|
const { config, updateConfig, colorPalettes, twoColorPalette } = useContext<ChartContext>(ConfigContext)
|
|
23
23
|
const { visual } = config
|
|
24
24
|
const { setLollipopShape, updateField } = useEditorPanelContext()
|
|
25
|
-
const { visHasBarBorders, visCanAnimate, visSupportsNonSequentialPallete, headerColors, visSupportsTooltipOpacity, visSupportsTooltipLines, visSupportsBarSpace, visSupportsBarThickness, visHasDataCutoff, visSupportsSequentialPallete, visSupportsReverseColorPalette } =
|
|
25
|
+
const { visHasBarBorders, visCanAnimate, visSupportsNonSequentialPallete, headerColors, visSupportsTooltipOpacity, visSupportsTooltipLines, visSupportsBarSpace, visSupportsBarThickness, visHasDataCutoff, visSupportsSequentialPallete, visSupportsReverseColorPalette, visHasSingleSeriesTooltip } =
|
|
26
|
+
useEditorPermissions()
|
|
26
27
|
const { twoColorPalettes, sequential, nonSequential } = useColorPalette(config, updateConfig)
|
|
27
28
|
|
|
28
29
|
const updateColor = (property, _value) => {
|
|
@@ -56,7 +57,7 @@ const PanelVisual: FC<PanelProps> = props => {
|
|
|
56
57
|
<AccordionItemButton>Visual</AccordionItemButton>
|
|
57
58
|
</AccordionItemHeading>
|
|
58
59
|
<AccordionItemPanel>
|
|
59
|
-
{config.isLollipopChart && (
|
|
60
|
+
{(config.barStyle === 'lollipop' || config.isLollipopChart) && (
|
|
60
61
|
<>
|
|
61
62
|
<fieldset className='header'>
|
|
62
63
|
<legend className='edit-label'>Lollipop Shape</legend>
|
|
@@ -79,7 +80,6 @@ const PanelVisual: FC<PanelProps> = props => {
|
|
|
79
80
|
<Select value={config.lollipopSize ? config.lollipopSize : 'small'} fieldName='lollipopSize' label='Lollipop Size' updateField={updateField} options={['small', 'medium', 'large']} />
|
|
80
81
|
</>
|
|
81
82
|
)}
|
|
82
|
-
|
|
83
83
|
{config.visualizationType === 'Box Plot' && (
|
|
84
84
|
<fieldset className='fieldset fieldset--boxplot'>
|
|
85
85
|
<legend className=''>Box Plot Settings</legend>
|
|
@@ -88,20 +88,16 @@ const PanelVisual: FC<PanelProps> = props => {
|
|
|
88
88
|
<CheckBox value={config.boxplot.plotNonOutlierValues} fieldName='plotNonOutlierValues' section='boxplot' label='Plot non-outlier values' updateField={updateField} />
|
|
89
89
|
</fieldset>
|
|
90
90
|
)}
|
|
91
|
-
|
|
92
91
|
<Select value={config.fontSize} fieldName='fontSize' label='Font Size' updateField={updateField} options={['small', 'medium', 'large']} />
|
|
93
92
|
{visHasBarBorders() && <Select value={config.barHasBorder} fieldName='barHasBorder' label='Bar Borders' updateField={updateField} options={['true', 'false']} />}
|
|
94
93
|
{visCanAnimate() && <CheckBox value={config.animate} fieldName='animate' label='Animate Visualization' updateField={updateField} />}
|
|
95
|
-
|
|
96
94
|
{/*<CheckBox value={config.animateReplay} fieldName="animateReplay" label="Replay Animation When Filters Are Changed" updateField={updateField} />*/}
|
|
97
|
-
|
|
98
95
|
{((config.series?.some(series => series.type === 'Line' || series.type === 'dashed-lg' || series.type === 'dashed-sm' || series.type === 'dashed-md') && config.visualizationType === 'Combo') || config.visualizationType === 'Line') && (
|
|
99
96
|
<>
|
|
100
97
|
<Select value={config.lineDatapointStyle} fieldName='lineDatapointStyle' label='Line Datapoint Style' updateField={updateField} options={['hidden', 'hover', 'always show']} />
|
|
101
98
|
<Select value={config.lineDatapointColor} fieldName='lineDatapointColor' label='Line Datapoint Color' updateField={updateField} options={['Same as Line', 'Lighter than Line']} />
|
|
102
99
|
</>
|
|
103
100
|
)}
|
|
104
|
-
|
|
105
101
|
{/* eslint-disable */}
|
|
106
102
|
<label className='header'>
|
|
107
103
|
<span className='edit-label'>Header Theme</span>
|
|
@@ -247,7 +243,6 @@ const PanelVisual: FC<PanelProps> = props => {
|
|
|
247
243
|
</ul>
|
|
248
244
|
</>
|
|
249
245
|
)}
|
|
250
|
-
|
|
251
246
|
{visHasDataCutoff() && (
|
|
252
247
|
<>
|
|
253
248
|
<TextField
|
|
@@ -274,7 +269,6 @@ const PanelVisual: FC<PanelProps> = props => {
|
|
|
274
269
|
{((config.visualizationType === 'Bar' && config.orientation !== 'horizontal') || config.visualizationType === 'Combo') && <TextField value={config.barThickness} type='number' fieldName='barThickness' label='Bar Thickness' updateField={updateField} />}
|
|
275
270
|
{visSupportsBarSpace() && <TextField type='number' value={config.barSpace || '15'} fieldName='barSpace' label='Bar Space' updateField={updateField} min={0} />}
|
|
276
271
|
{(config.visualizationType === 'Bar' || config.visualizationType === 'Line' || config.visualizationType === 'Combo') && <CheckBox value={config.topAxis.hasLine} section='topAxis' fieldName='hasLine' label='Add Top Axis Line' updateField={updateField} />}
|
|
277
|
-
|
|
278
272
|
{config.visualizationType === 'Spark Line' && (
|
|
279
273
|
<div className='cove-accordion__panel-section checkbox-group'>
|
|
280
274
|
<CheckBox value={visual?.border} section='visual' fieldName='border' label='Show Border' updateField={updateField} />
|
|
@@ -284,10 +278,8 @@ const PanelVisual: FC<PanelProps> = props => {
|
|
|
284
278
|
<CheckBox value={visual?.hideBackgroundColor} section='visual' fieldName='hideBackgroundColor' label='Hide Background Color' updateField={updateField} />
|
|
285
279
|
</div>
|
|
286
280
|
)}
|
|
287
|
-
|
|
288
281
|
{(config.visualizationType === 'Line' || config.visualizationType === 'Combo') && <CheckBox value={config.showLineSeriesLabels} fieldName='showLineSeriesLabels' label='Append Series Name to End of Line Charts' updateField={updateField} />}
|
|
289
282
|
{(config.visualizationType === 'Line' || config.visualizationType === 'Combo') && config.showLineSeriesLabels && <CheckBox value={config.colorMatchLineSeriesLabels} fieldName='colorMatchLineSeriesLabels' label='Match Series Color to Name at End of Line Charts' updateField={updateField} />}
|
|
290
|
-
|
|
291
283
|
{visSupportsTooltipLines() && (
|
|
292
284
|
<>
|
|
293
285
|
<CheckBox value={visual.verticalHoverLine} fieldName='verticalHoverLine' section='visual' label='Vertical Hover Line' updateField={updateField} />
|
|
@@ -312,8 +304,7 @@ const PanelVisual: FC<PanelProps> = props => {
|
|
|
312
304
|
/>
|
|
313
305
|
</label>
|
|
314
306
|
)}
|
|
315
|
-
{
|
|
316
|
-
|
|
307
|
+
{visHasSingleSeriesTooltip() && <CheckBox value={config.tooltips.singleSeries} fieldName='singleSeries' section='tooltips' label='SHOW HOVER FOR SINGLE DATA SERIES' updateField={updateField} />}
|
|
317
308
|
<label>
|
|
318
309
|
<span className='edit-label column-heading'>No Data Message</span>
|
|
319
310
|
<input
|
|
@@ -5,6 +5,7 @@ import General from './Panel.General'
|
|
|
5
5
|
import BoxPlot from './Panel.BoxPlot'
|
|
6
6
|
import Visual from './Panel.Visual'
|
|
7
7
|
import Sankey from './Panel.Sankey'
|
|
8
|
+
import Annotate from './Panel.Annotate'
|
|
8
9
|
|
|
9
10
|
const Panels = {
|
|
10
11
|
ForestPlot: ForestPlotSettings,
|
|
@@ -13,7 +14,8 @@ const Panels = {
|
|
|
13
14
|
General,
|
|
14
15
|
BoxPlot,
|
|
15
16
|
Visual,
|
|
16
|
-
Sankey
|
|
17
|
+
Sankey,
|
|
18
|
+
Annotate
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
export default Panels
|
|
@@ -7,9 +7,41 @@
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
.cdc-open-viz-module.type-chart {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
.viewport-overrides {
|
|
11
|
+
button {
|
|
12
|
+
width: 100%;
|
|
13
|
+
padding: 1em;
|
|
14
|
+
margin-top: 1em;
|
|
15
|
+
text-align: left;
|
|
16
|
+
|
|
17
|
+
span {
|
|
18
|
+
display: inline-block;
|
|
19
|
+
float: right;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.edit-block {
|
|
24
|
+
margin-top: 0;
|
|
25
|
+
padding: 1em;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.viewport-overrides {
|
|
30
|
+
button {
|
|
31
|
+
width: 100%;
|
|
32
|
+
padding: 1em;
|
|
33
|
+
margin-top: 1em;
|
|
34
|
+
text-align: left;
|
|
35
|
+
|
|
36
|
+
span {
|
|
37
|
+
display: inline-block;
|
|
38
|
+
float: right;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.edit-block {
|
|
43
|
+
margin-top: 0;
|
|
44
|
+
padding: 1em;
|
|
13
45
|
}
|
|
14
46
|
}
|
|
15
47
|
}
|
|
@@ -11,6 +11,7 @@ export const useEditorPermissions = () => {
|
|
|
11
11
|
'Area Chart',
|
|
12
12
|
'Bar',
|
|
13
13
|
'Box Plot',
|
|
14
|
+
'Bump Chart',
|
|
14
15
|
'Combo',
|
|
15
16
|
'Deviation Bar',
|
|
16
17
|
'Forecasting',
|
|
@@ -23,7 +24,19 @@ export const useEditorPermissions = () => {
|
|
|
23
24
|
'Sankey'
|
|
24
25
|
]
|
|
25
26
|
|
|
26
|
-
const headerColors = [
|
|
27
|
+
const headerColors = [
|
|
28
|
+
'theme-blue',
|
|
29
|
+
'theme-purple',
|
|
30
|
+
'theme-brown',
|
|
31
|
+
'theme-teal',
|
|
32
|
+
'theme-pink',
|
|
33
|
+
'theme-orange',
|
|
34
|
+
'theme-slate',
|
|
35
|
+
'theme-indigo',
|
|
36
|
+
'theme-cyan',
|
|
37
|
+
'theme-green',
|
|
38
|
+
'theme-amber'
|
|
39
|
+
]
|
|
27
40
|
|
|
28
41
|
const visSupportsDateCategoryAxis = () => {
|
|
29
42
|
const disabledCharts = ['Forest Plot', 'Sankey']
|
|
@@ -44,13 +57,30 @@ export const useEditorPermissions = () => {
|
|
|
44
57
|
}
|
|
45
58
|
|
|
46
59
|
const visHasLabelOnData = () => {
|
|
47
|
-
const disabledCharts = [
|
|
60
|
+
const disabledCharts = [
|
|
61
|
+
'Area Chart',
|
|
62
|
+
'Box Plot',
|
|
63
|
+
'Pie',
|
|
64
|
+
'Scatter Plot',
|
|
65
|
+
'Forest Plot',
|
|
66
|
+
'Spark Line',
|
|
67
|
+
'Sankey',
|
|
68
|
+
'Bump Chart'
|
|
69
|
+
]
|
|
48
70
|
if (disabledCharts.includes(visualizationType)) return false
|
|
49
71
|
return true
|
|
50
72
|
}
|
|
51
73
|
|
|
52
74
|
const visCanAnimate = () => {
|
|
53
|
-
const disabledCharts = [
|
|
75
|
+
const disabledCharts = [
|
|
76
|
+
'Area Chart',
|
|
77
|
+
'Scatter Plot',
|
|
78
|
+
'Box Plot',
|
|
79
|
+
'Forest Plot',
|
|
80
|
+
'Spark Line',
|
|
81
|
+
'Sankey',
|
|
82
|
+
'Bump Chart'
|
|
83
|
+
]
|
|
54
84
|
if (disabledCharts.includes(visualizationType)) return false
|
|
55
85
|
return true
|
|
56
86
|
}
|
|
@@ -72,7 +102,19 @@ export const useEditorPermissions = () => {
|
|
|
72
102
|
|
|
73
103
|
const visHasNumbersOnBars = () => {
|
|
74
104
|
if (visualizationType === 'Forest Plot') return false
|
|
75
|
-
if (
|
|
105
|
+
if (
|
|
106
|
+
config.orientation === 'horizontal' &&
|
|
107
|
+
(config.yAxis.labelPlacement === 'Below Bar' ||
|
|
108
|
+
config.yAxis.labelPlacement === 'On Date/Category Axis' ||
|
|
109
|
+
config.visualizationType === 'Paired Bar' ||
|
|
110
|
+
config.visualizationType === 'Deviation Bar')
|
|
111
|
+
)
|
|
112
|
+
return true
|
|
113
|
+
return false
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const visHasaAdditionalLabelsOnBars = () => {
|
|
117
|
+
if (['Bar', 'Combo', 'Line'].includes(config.visualizationType)) return true
|
|
76
118
|
return false
|
|
77
119
|
}
|
|
78
120
|
|
|
@@ -99,13 +141,17 @@ export const useEditorPermissions = () => {
|
|
|
99
141
|
}
|
|
100
142
|
}
|
|
101
143
|
const visHasBrushChart = () => {
|
|
144
|
+
return false
|
|
145
|
+
if (config.xAxis.type === 'categorical') return false
|
|
102
146
|
return ['Line', 'Bar', 'Area Chart', 'Combo'].includes(visualizationType) && orientation === 'vertical'
|
|
103
147
|
}
|
|
104
148
|
|
|
105
149
|
const visHasBarBorders = () => {
|
|
106
|
-
const disabledCharts = ['Box Plot', 'Scatter Plot', 'Pie']
|
|
150
|
+
const disabledCharts = ['Box Plot', 'Scatter Plot', 'Pie', 'Line']
|
|
107
151
|
if (disabledCharts.includes(visualizationType)) return false
|
|
108
|
-
return series?.some(
|
|
152
|
+
return series?.some(
|
|
153
|
+
series => series.type === 'Bar' || series.type === 'Paired Bar' || series.type === 'Deviation Bar'
|
|
154
|
+
)
|
|
109
155
|
}
|
|
110
156
|
|
|
111
157
|
const visHasDataCutoff = () => {
|
|
@@ -129,6 +175,9 @@ export const useEditorPermissions = () => {
|
|
|
129
175
|
const visHasLegendAxisAlign = () => {
|
|
130
176
|
return visualizationType === 'Bar' && visualizationSubType === 'stacked' && config.legend.behavior === 'isolate'
|
|
131
177
|
}
|
|
178
|
+
const visHasLegendColorCategory = () => {
|
|
179
|
+
return visualizationType === 'Bar' && visualizationSubType === 'regular' && config.series?.length === 1
|
|
180
|
+
}
|
|
132
181
|
|
|
133
182
|
const visSupportsTooltipOpacity = () => {
|
|
134
183
|
const disabledCharts = ['Spark Line', 'Sankey']
|
|
@@ -161,7 +210,7 @@ export const useEditorPermissions = () => {
|
|
|
161
210
|
}
|
|
162
211
|
|
|
163
212
|
const visSupportsDateCategoryAxisLabel = () => {
|
|
164
|
-
const disabledCharts = ['Forest Plot', 'Spark Line']
|
|
213
|
+
const disabledCharts = ['Forest Plot', 'Spark Line', 'Bump Chart']
|
|
165
214
|
if (disabledCharts.includes(visualizationType)) return false
|
|
166
215
|
return true
|
|
167
216
|
}
|
|
@@ -243,7 +292,7 @@ export const useEditorPermissions = () => {
|
|
|
243
292
|
|
|
244
293
|
// implement later
|
|
245
294
|
const visSupportsValueAxisLabels = () => {
|
|
246
|
-
const disabledCharts = ['Forest Plot']
|
|
295
|
+
const disabledCharts = ['Forest Plot', 'Bump Chart']
|
|
247
296
|
if (disabledCharts.includes(visualizationType)) return false
|
|
248
297
|
return true
|
|
249
298
|
}
|
|
@@ -266,6 +315,12 @@ export const useEditorPermissions = () => {
|
|
|
266
315
|
if (disabledCharts.includes(visualizationType)) return false
|
|
267
316
|
return true
|
|
268
317
|
}
|
|
318
|
+
const visSupportsMobileChartHeight = () => {
|
|
319
|
+
// TODO: this is a soft release. Support should eventually match visSupportsChartHeight
|
|
320
|
+
const enabledCharts = ['Bar', 'Line', 'Combo', 'Area Chart']
|
|
321
|
+
if (enabledCharts.includes(visualizationType)) return true
|
|
322
|
+
return false
|
|
323
|
+
}
|
|
269
324
|
|
|
270
325
|
const visSupportsLeftValueAxis = () => {
|
|
271
326
|
const disabledCharts = ['Spark Line', 'Sankey']
|
|
@@ -280,7 +335,7 @@ export const useEditorPermissions = () => {
|
|
|
280
335
|
}
|
|
281
336
|
|
|
282
337
|
const visSupportsDateCategoryHeight = () => {
|
|
283
|
-
const disabledCharts = ['Spark Line', 'Sankey']
|
|
338
|
+
const disabledCharts = ['Spark Line', 'Sankey', 'Bump Chart']
|
|
284
339
|
if (disabledCharts.includes(visualizationType)) return false
|
|
285
340
|
return true
|
|
286
341
|
}
|
|
@@ -290,27 +345,54 @@ export const useEditorPermissions = () => {
|
|
|
290
345
|
}
|
|
291
346
|
|
|
292
347
|
const visSupportsReactTooltip = () => {
|
|
293
|
-
if (
|
|
348
|
+
if (config.yAxis.type === 'categorical') return true
|
|
349
|
+
if (
|
|
350
|
+
['Deviation Bar', 'Box Plot', 'Scatter Plot', 'Paired Bar'].includes(visualizationType) ||
|
|
351
|
+
(visualizationType === 'Bar' && config.tooltips.singleSeries)
|
|
352
|
+
) {
|
|
294
353
|
return true
|
|
295
354
|
}
|
|
296
355
|
}
|
|
297
356
|
|
|
298
357
|
const visSupportsPreliminaryData = () => {
|
|
299
|
-
|
|
300
|
-
const lineExist = config?.series.some(item => ['Line', 'dashed-sm', 'dashed-md', 'dashed-lg'].includes(item?.type))
|
|
301
|
-
if (visualizationType === 'Line') {
|
|
358
|
+
if (['Line', 'Bar', 'Combo'].includes(visualizationType)) {
|
|
302
359
|
return true
|
|
303
360
|
}
|
|
304
|
-
|
|
361
|
+
|
|
362
|
+
return false
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const visSupportsDynamicSeries = () => {
|
|
366
|
+
return (
|
|
367
|
+
visualizationType === 'Line' ||
|
|
368
|
+
visualizationType === 'Bar' ||
|
|
369
|
+
visualizationType === 'Scatter Plot' ||
|
|
370
|
+
visualizationType === 'Area Chart'
|
|
371
|
+
)
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const visHasSingleSeriesTooltip = () => {
|
|
375
|
+
if (visualizationType === 'Bar' || visualizationType === 'Line') {
|
|
305
376
|
return true
|
|
306
377
|
}
|
|
307
|
-
|
|
308
|
-
if (visualizationType === 'Combo') {
|
|
378
|
+
if (visualizationType === 'Area Chart' && visualizationSubType === 'stacked') {
|
|
309
379
|
return true
|
|
310
380
|
}
|
|
311
381
|
return false
|
|
312
382
|
}
|
|
313
383
|
|
|
384
|
+
const visHasCategoricalAxis = () => {
|
|
385
|
+
if (
|
|
386
|
+
(visualizationType === 'Line' ||
|
|
387
|
+
visualizationType === 'Bar' ||
|
|
388
|
+
visualizationType === 'Combo' ||
|
|
389
|
+
visualizationType === 'Area Chart') &&
|
|
390
|
+
config.yAxis.type === 'categorical' &&
|
|
391
|
+
orientation === 'vertical'
|
|
392
|
+
)
|
|
393
|
+
return true
|
|
394
|
+
}
|
|
395
|
+
|
|
314
396
|
return {
|
|
315
397
|
enabledChartTypes,
|
|
316
398
|
headerColors,
|
|
@@ -322,11 +404,14 @@ export const useEditorPermissions = () => {
|
|
|
322
404
|
visHasDataSuppression,
|
|
323
405
|
visHasLegend,
|
|
324
406
|
visHasLegendAxisAlign,
|
|
407
|
+
visHasLegendColorCategory,
|
|
325
408
|
visHasBrushChart,
|
|
326
409
|
visHasNumbersOnBars,
|
|
410
|
+
visHasaAdditionalLabelsOnBars,
|
|
327
411
|
visSupportsBarSpace,
|
|
328
412
|
visSupportsBarThickness,
|
|
329
413
|
visSupportsChartHeight,
|
|
414
|
+
visSupportsMobileChartHeight,
|
|
330
415
|
visSupportsDateCategoryAxis,
|
|
331
416
|
visSupportsDateCategoryAxisLabel,
|
|
332
417
|
visSupportsDateCategoryAxisLine,
|
|
@@ -355,6 +440,9 @@ export const useEditorPermissions = () => {
|
|
|
355
440
|
visSupportsValueAxisTicks,
|
|
356
441
|
visSupportsReactTooltip,
|
|
357
442
|
visSupportsValueAxisMax,
|
|
358
|
-
visSupportsValueAxisMin
|
|
443
|
+
visSupportsValueAxisMin,
|
|
444
|
+
visSupportsDynamicSeries,
|
|
445
|
+
visHasSingleSeriesTooltip,
|
|
446
|
+
visHasCategoricalAxis
|
|
359
447
|
}
|
|
360
448
|
}
|