@cdc/chart 4.25.3-6 → 4.25.5-1
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-1a1724a1.es.js +4886 -0
- package/dist/cdcchart.js +50347 -75521
- package/index.html +1 -0
- package/package.json +22 -27
- package/src/CdcChart.tsx +1 -22
- package/src/CdcChartComponent.tsx +35 -21
- package/src/_stories/Chart.CI.stories.tsx +43 -0
- package/src/_stories/Chart.DynamicSeries.stories.tsx +68 -49
- package/src/_stories/Chart.Legend.Gradient.stories.tsx +6 -0
- package/src/_stories/Chart.stories.tsx +7 -16
- package/src/_stories/_mock/bar_chart_ci_labels.json +620 -0
- package/src/_stories/_mock/barchart_labels.mock.json +612 -0
- package/src/_stories/_mock/dynamic_series_bar_config.json +1 -1
- package/src/_stories/_mock/dynamic_series_suppression_mock.json +610 -0
- package/{examples/private/line-issue.json → src/_stories/_mock/legend_groupBy_mock.json} +46 -69
- package/src/components/Annotations/components/AnnotationDropdown.tsx +2 -2
- package/src/components/AreaChart/components/AreaChart.jsx +33 -5
- package/src/components/Axis/Categorical.Axis.tsx +2 -2
- package/src/components/BarChart/components/BarChart.Horizontal.tsx +51 -41
- package/src/components/BarChart/components/BarChart.StackedHorizontal.tsx +19 -9
- package/src/components/BarChart/components/BarChart.StackedVertical.tsx +20 -9
- package/src/components/BarChart/components/BarChart.Vertical.tsx +48 -31
- package/src/components/BarChart/components/{BarChart.jsx → BarChart.tsx} +23 -5
- package/src/components/BarChart/components/context.tsx +20 -2
- package/src/components/BarChart/helpers/getBarHeights.ts +47 -0
- package/src/components/BarChart/helpers/index.ts +5 -2
- package/src/components/BarChart/helpers/tests/getBarHeights.test.ts +83 -0
- package/src/{hooks → components/BarChart/helpers}/useBarChart.ts +11 -47
- package/src/components/BoxPlot/BoxPlot.tsx +2 -1
- package/src/components/DeviationBar.jsx +2 -1
- package/src/components/EditorPanel/EditorPanel.tsx +60 -24
- package/src/components/EditorPanel/components/Panels/Panel.General.tsx +34 -34
- package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +51 -25
- package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +10 -3
- package/src/components/EditorPanel/helpers/updateFieldRankByValue.ts +4 -3
- package/src/components/EditorPanel/useEditorPermissions.ts +1 -4
- package/src/components/ForestPlot/ForestPlot.tsx +2 -2
- package/src/components/Legend/Legend.Component.tsx +69 -58
- package/src/components/Legend/Legend.Suppression.tsx +12 -22
- package/src/components/Legend/Legend.tsx +3 -1
- package/src/components/Legend/LegendGroup/LegendGroup.styles.css +40 -0
- package/src/components/Legend/LegendGroup/LegendGroup.tsx +103 -0
- package/src/components/Legend/LegendGroup/index.tsx +3 -0
- package/src/components/Legend/helpers/createFormatLabels.tsx +28 -0
- package/src/components/LineChart/LineChartProps.ts +3 -1
- package/src/components/LineChart/components/LineChart.Circle.tsx +77 -119
- package/src/components/LineChart/helpers.ts +133 -56
- package/src/components/LineChart/index.tsx +125 -60
- package/src/components/LinearChart.tsx +74 -115
- package/src/components/PairedBarChart.jsx +3 -2
- package/src/components/PieChart/PieChart.tsx +71 -91
- package/src/components/ScatterPlot/ScatterPlot.jsx +5 -0
- package/src/components/Sparkline/components/SparkLine.tsx +80 -18
- package/src/components/ZoomBrush.tsx +4 -4
- package/src/data/initial-state.js +4 -2
- package/src/helpers/countNumOfTicks.ts +1 -1
- package/src/helpers/dataHelpers.ts +31 -0
- package/src/helpers/sizeHelpers.ts +23 -0
- package/src/hooks/useMinMax.ts +21 -28
- package/src/hooks/useRightAxis.ts +4 -2
- package/src/hooks/useScales.ts +12 -14
- package/src/hooks/useTooltip.tsx +204 -203
- package/src/index.jsx +2 -2
- package/src/scss/main.scss +13 -6
- package/src/store/chart.actions.ts +1 -1
- package/src/types/ChartConfig.ts +7 -1
- package/LICENSE +0 -201
- package/examples/private/DEV-8850-2.json +0 -493
- package/examples/private/DEV-9822.json +0 -574
- package/examples/private/DEV-9840.json +0 -553
- package/examples/private/DEV-9850-3.json +0 -461
- package/examples/private/chart.json +0 -1084
- package/examples/private/ci_formatted.json +0 -202
- package/examples/private/ci_issue.json +0 -3016
- package/examples/private/completed.json +0 -634
- package/examples/private/dem-data-long.csv +0 -20
- package/examples/private/dem-data-long.json +0 -36
- package/examples/private/demographic_data.csv +0 -157
- package/examples/private/demographic_data.json +0 -2654
- package/examples/private/demographic_dynamic.json +0 -443
- package/examples/private/demographic_standard.json +0 -560
- package/examples/private/ehdi.json +0 -29939
- package/examples/private/not-loading.json +0 -360
- package/examples/private/test.json +0 -493
package/index.html
CHANGED
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
-->
|
|
46
46
|
|
|
47
47
|
<!-- GENERIC CHART TYPES -->
|
|
48
|
+
<!-- <div class="react-container" data-config="/examples/private/ari-other-conditions-1.json"></div> -->
|
|
48
49
|
<!-- <div class="react-container" data-config="/examples/private/Viral-Respiratory-Deaths-Age.json"></div> -->
|
|
49
50
|
<!-- <div class="react-container" data-config="/examples/cases-year.json"></div>-->
|
|
50
51
|
<!-- <div class="react-container" data-config="/examples/test.json"></div> -->
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdc/chart",
|
|
3
|
-
"version": "4.25.
|
|
3
|
+
"version": "4.25.5-1",
|
|
4
4
|
"description": "React component for visualizing tabular data in various types of charts",
|
|
5
5
|
"moduleName": "CdcChart",
|
|
6
6
|
"main": "dist/cdcchart",
|
|
@@ -27,43 +27,38 @@
|
|
|
27
27
|
"license": "Apache-2.0",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@hello-pangea/dnd": "^16.2.0",
|
|
30
|
-
"@
|
|
31
|
-
"@visx/
|
|
32
|
-
"@visx/
|
|
33
|
-
"@visx/
|
|
34
|
-
"@visx/
|
|
35
|
-
"@visx/
|
|
36
|
-
"@visx/
|
|
37
|
-
"@visx/
|
|
38
|
-
"@visx/
|
|
39
|
-
"@visx/
|
|
40
|
-
"@visx/
|
|
41
|
-
"@visx/
|
|
42
|
-
"@visx/
|
|
43
|
-
"
|
|
44
|
-
"chroma-js": "^2.1.2",
|
|
45
|
-
"d3-array": "^2.8.0",
|
|
30
|
+
"@react-spring/web": "^9.7.5",
|
|
31
|
+
"@visx/axis": "3.12.0",
|
|
32
|
+
"@visx/curve": "3.12.0",
|
|
33
|
+
"@visx/event": "3.12.0",
|
|
34
|
+
"@visx/glyph": "3.12.0",
|
|
35
|
+
"@visx/gradient": "3.12.0",
|
|
36
|
+
"@visx/marker": "3.12.0",
|
|
37
|
+
"@visx/mock-data": "3.12.0",
|
|
38
|
+
"@visx/scale": "3.12.0",
|
|
39
|
+
"@visx/shape": "3.12.0",
|
|
40
|
+
"@visx/stats": "3.12.0",
|
|
41
|
+
"@visx/text": "3.12.0",
|
|
42
|
+
"@visx/tooltip": "3.12.0",
|
|
43
|
+
"d3-array": "3.2.4",
|
|
46
44
|
"d3-format": "^3.1.0",
|
|
47
45
|
"d3-sankey": "^0.12.3",
|
|
48
|
-
"d3-time-format": "
|
|
49
|
-
"html-react-parser": "^3.0.8",
|
|
46
|
+
"d3-time-format": "4.1.0",
|
|
50
47
|
"js-base64": "^2.5.2",
|
|
51
|
-
"papaparse": "^5.3.0",
|
|
52
48
|
"react-accessible-accordion": "^3.3.4",
|
|
53
|
-
"react-icons": "
|
|
54
|
-
"
|
|
55
|
-
"react-table": "^7.5.0",
|
|
56
|
-
"react-tooltip": "5.8.2-beta.3",
|
|
57
|
-
"use-debounce": "^6.0.1",
|
|
58
|
-
"whatwg-fetch": "^3.6.2"
|
|
49
|
+
"react-icons": "5.5.0",
|
|
50
|
+
"use-debounce": "^6.0.1"
|
|
59
51
|
},
|
|
60
52
|
"peerDependencies": {
|
|
61
53
|
"react": "^18.2.0",
|
|
62
54
|
"react-dom": "^18.2.0"
|
|
63
55
|
},
|
|
64
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "1d0a6e716bc113e6bea3636fcae90ebf2d19bb5c",
|
|
65
57
|
"devDependencies": {
|
|
58
|
+
"@types/d3-array": "^3.2.1",
|
|
59
|
+
"@types/d3-format": "^3.0.4",
|
|
66
60
|
"@types/d3-sankey": "^0.12.4",
|
|
61
|
+
"@types/d3-time-format": "^4.0.3",
|
|
67
62
|
"resize-observer-polyfill": "^1.5.1"
|
|
68
63
|
}
|
|
69
64
|
}
|
package/src/CdcChart.tsx
CHANGED
|
@@ -69,12 +69,7 @@ const CdcChartWrapper: React.FC<CdcChartProps> = ({ configUrl, isEditor, isDebug
|
|
|
69
69
|
setIsLoading(true)
|
|
70
70
|
try {
|
|
71
71
|
const loadedConfig = await loadConfig(configUrl)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
setConfig({
|
|
75
|
-
...loadedConfig,
|
|
76
|
-
data
|
|
77
|
-
})
|
|
72
|
+
setConfig(loadedConfig)
|
|
78
73
|
} catch (error) {
|
|
79
74
|
console.error('Failed to load configuration or data', error)
|
|
80
75
|
} finally {
|
|
@@ -124,19 +119,3 @@ const fetchAndParseData = async (url: string, ext: string) => {
|
|
|
124
119
|
return []
|
|
125
120
|
}
|
|
126
121
|
}
|
|
127
|
-
|
|
128
|
-
const loadDataFromConfig = async (response: any) => {
|
|
129
|
-
if (!response.dataUrl || _.some(_.get(response, 'filters', []), { type: 'url' })) {
|
|
130
|
-
return response.data || []
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const ext = getFileExtension(response.dataUrl)
|
|
134
|
-
const urlWithCacheBuster = `${response.dataUrl}`
|
|
135
|
-
|
|
136
|
-
try {
|
|
137
|
-
return await fetchAndParseData(urlWithCacheBuster, ext)
|
|
138
|
-
} catch {
|
|
139
|
-
console.error(`Cannot parse URL: ${response.dataUrl}`)
|
|
140
|
-
return []
|
|
141
|
-
}
|
|
142
|
-
}
|
|
@@ -64,6 +64,7 @@ import getViewport from '@cdc/core/helpers/getViewport'
|
|
|
64
64
|
import isNumber from '@cdc/core/helpers/isNumber'
|
|
65
65
|
import coveUpdateWorker from '@cdc/core/helpers/coveUpdateWorker'
|
|
66
66
|
import EditorContext from '../../editor/src/ConfigContext'
|
|
67
|
+
import { EDITOR_WIDTH } from '@cdc/core/helpers/constants'
|
|
67
68
|
// Local helpers
|
|
68
69
|
import { isConvertLineToBarGraph } from './helpers/isConvertLineToBarGraph'
|
|
69
70
|
import { getBoxPlotConfig } from './helpers/getBoxPlotConfig'
|
|
@@ -140,8 +141,6 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
140
141
|
dispatch({ type: 'SET_DRAG_ANNOTATIONS', payload: isDragging })
|
|
141
142
|
}
|
|
142
143
|
|
|
143
|
-
if (isDebug) console.log('Chart config, isEditor', config, isEditor)
|
|
144
|
-
|
|
145
144
|
// Destructure items from config for more readable JSX
|
|
146
145
|
let { legend, title } = config
|
|
147
146
|
|
|
@@ -179,8 +178,8 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
179
178
|
if (newConfig.visualizationType === 'Bump Chart') {
|
|
180
179
|
newConfig.xAxis.type === 'date-time'
|
|
181
180
|
}
|
|
182
|
-
|
|
183
|
-
return
|
|
181
|
+
if (!isDashboard) return coveUpdateWorker(newConfig)
|
|
182
|
+
return newConfig
|
|
184
183
|
}
|
|
185
184
|
|
|
186
185
|
const updateConfig = (_config: AllChartsConfig, dataOverride?: any[]) => {
|
|
@@ -278,14 +277,15 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
278
277
|
newConfig.series.forEach(series => {
|
|
279
278
|
newConfig.runtime.areaSeriesKeys.push({ ...series, type: 'Area Chart' })
|
|
280
279
|
})
|
|
280
|
+
newConfig.visualizationSubType = 'stacked'
|
|
281
281
|
}
|
|
282
282
|
|
|
283
283
|
if (
|
|
284
284
|
(newConfig.visualizationType === 'Bar' && newConfig.orientation === 'horizontal') ||
|
|
285
285
|
['Deviation Bar', 'Paired Bar', 'Forest Plot'].includes(newConfig.visualizationType)
|
|
286
286
|
) {
|
|
287
|
-
newConfig.runtime.xAxis = newConfig.yAxis
|
|
288
|
-
newConfig.runtime.yAxis = newConfig.xAxis
|
|
287
|
+
newConfig.runtime.xAxis = _.cloneDeep(newConfig.yAxis.yAxis || newConfig.yAxis)
|
|
288
|
+
newConfig.runtime.yAxis = _.cloneDeep(newConfig.xAxis.xAxis || newConfig.xAxis)
|
|
289
289
|
newConfig.runtime.yAxis.labelOffset *= -1
|
|
290
290
|
|
|
291
291
|
newConfig.runtime.horizontal = false
|
|
@@ -344,10 +344,8 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
344
344
|
const resizeObserver = new ResizeObserver(entries => {
|
|
345
345
|
for (let entry of entries) {
|
|
346
346
|
let { width, height } = entry.contentRect
|
|
347
|
-
const svgMarginWidth = 15
|
|
348
|
-
const editorWidth = 350
|
|
349
347
|
|
|
350
|
-
width = isEditor ? width -
|
|
348
|
+
width = isEditor ? width - EDITOR_WIDTH : width
|
|
351
349
|
|
|
352
350
|
const newViewport = getViewport(width)
|
|
353
351
|
|
|
@@ -357,7 +355,7 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
357
355
|
width = width - 2.5
|
|
358
356
|
}
|
|
359
357
|
|
|
360
|
-
width = width
|
|
358
|
+
width = width
|
|
361
359
|
dispatch({ type: 'SET_DIMENSIONS', payload: [width, height] })
|
|
362
360
|
}
|
|
363
361
|
})
|
|
@@ -397,17 +395,16 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
397
395
|
newConfig.data = transform.developerStandardize(newConfig.data, newConfig.dataDescription)
|
|
398
396
|
}
|
|
399
397
|
} catch (err) {
|
|
400
|
-
console.
|
|
398
|
+
console.error('Error on prepareData function ', err)
|
|
401
399
|
}
|
|
402
400
|
return newConfig
|
|
403
401
|
}
|
|
404
|
-
|
|
405
402
|
useEffect(() => {
|
|
406
403
|
const load = async () => {
|
|
407
404
|
try {
|
|
408
405
|
if (configObj) {
|
|
409
406
|
const preparedConfig = await prepareConfig(configObj)
|
|
410
|
-
|
|
407
|
+
const preppedData = await prepareData(preparedConfig)
|
|
411
408
|
dispatch({ type: 'SET_STATE_DATA', payload: preppedData.data })
|
|
412
409
|
dispatch({ type: 'SET_EXCLUDED_DATA', payload: preppedData.data })
|
|
413
410
|
updateConfig(preparedConfig, preppedData.data)
|
|
@@ -565,6 +562,7 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
565
562
|
addColRoundTo,
|
|
566
563
|
{ index, length } = { index: null, length: null }
|
|
567
564
|
) => {
|
|
565
|
+
if (num === '') return 'N/A'
|
|
568
566
|
// if num is NaN return num
|
|
569
567
|
if (isNaN(num) || !num) return num
|
|
570
568
|
// Check if the input number is negative
|
|
@@ -749,9 +747,10 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
749
747
|
if (!Array.isArray(data)) return []
|
|
750
748
|
if (config.visualizationType === 'Forecasting') return data
|
|
751
749
|
// specify keys that needs to be cleaned to render chart and skip rest
|
|
752
|
-
const CIkeys: string[] = Object.values(config
|
|
753
|
-
const seriesKeys: string[] = config
|
|
754
|
-
const keysToClean: string[] = seriesKeys
|
|
750
|
+
const CIkeys: string[] = Object.values(_.get(config, 'confidenceKeys', {})) as string[]
|
|
751
|
+
const seriesKeys: string[] = _.get(config, 'series', []).map((s: any) => s.dataKey)
|
|
752
|
+
const keysToClean: string[] = [...(seriesKeys ?? []), ...(CIkeys ?? [])]
|
|
753
|
+
|
|
755
754
|
// key that does not need to be cleaned
|
|
756
755
|
const excludedKey = config.xAxis.dataKey
|
|
757
756
|
return config?.xAxis?.dataKey ? transform.cleanData(data, excludedKey, keysToClean) : data
|
|
@@ -881,7 +880,10 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
881
880
|
className={
|
|
882
881
|
legend.hide || isLegendWrapViewport(currentViewport)
|
|
883
882
|
? 'w-100'
|
|
884
|
-
: legend.position === 'bottom' ||
|
|
883
|
+
: legend.position === 'bottom' ||
|
|
884
|
+
legend.position === 'top' ||
|
|
885
|
+
visualizationType === 'Sankey' ||
|
|
886
|
+
visualizationType === 'Spark Line'
|
|
885
887
|
? 'w-100'
|
|
886
888
|
: 'w-75'
|
|
887
889
|
}
|
|
@@ -913,11 +915,23 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
913
915
|
</ParentSize>
|
|
914
916
|
</div>
|
|
915
917
|
) : (
|
|
916
|
-
<div ref={parentRef} style={{ width:
|
|
918
|
+
<div ref={parentRef} style={{ width: '100%' }}>
|
|
917
919
|
<ParentSize>
|
|
918
|
-
{parent =>
|
|
919
|
-
|
|
920
|
-
|
|
920
|
+
{parent => {
|
|
921
|
+
const labelMargin = 120
|
|
922
|
+
const widthReduction =
|
|
923
|
+
config.showLineSeriesLabels &&
|
|
924
|
+
(config.legend.position !== 'right' || config.legend.hide)
|
|
925
|
+
? labelMargin
|
|
926
|
+
: 0
|
|
927
|
+
return (
|
|
928
|
+
<LinearChart
|
|
929
|
+
ref={svgRef}
|
|
930
|
+
parentWidth={parent.width - widthReduction}
|
|
931
|
+
parentHeight={parent.height}
|
|
932
|
+
/>
|
|
933
|
+
)
|
|
934
|
+
}}
|
|
921
935
|
</ParentSize>
|
|
922
936
|
</div>
|
|
923
937
|
))}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
|
+
import barChartCiLabels from './_mock/bar_chart_ci_labels.json'
|
|
3
|
+
import lineChartDynamicCI from './_mock/line_chart_dynamic_ci.json'
|
|
4
|
+
import lineChartNonDynamicCI from './_mock/line_chart_non_dynamic_ci.json'
|
|
5
|
+
|
|
6
|
+
import Chart from '../CdcChartComponent'
|
|
7
|
+
|
|
8
|
+
const meta: Meta<typeof Chart> = {
|
|
9
|
+
title: 'Components/Templates/Chart/Confidence Intervals',
|
|
10
|
+
component: Chart
|
|
11
|
+
}
|
|
12
|
+
type Story = StoryObj<typeof Chart>
|
|
13
|
+
export const bar_chart_with_labels: Story = {
|
|
14
|
+
args: {
|
|
15
|
+
config: barChartCiLabels,
|
|
16
|
+
isEditor: false
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export const bar_chart_horizontal_labels: Story = {
|
|
20
|
+
args: {
|
|
21
|
+
config: {
|
|
22
|
+
...barChartCiLabels,
|
|
23
|
+
orientation: 'horizontal',
|
|
24
|
+
yAxis: { ...barChartCiLabels.yAxis, displayNumbersOnBar: true }
|
|
25
|
+
},
|
|
26
|
+
isEditor: false
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const line_Chart_Dynamic_Confidence_Intervals: Story = {
|
|
31
|
+
args: {
|
|
32
|
+
config: lineChartDynamicCI,
|
|
33
|
+
isEditor: false
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const line_Chart_Non_Dynamic_Confidence_Intervals: Story = {
|
|
38
|
+
args: {
|
|
39
|
+
config: lineChartNonDynamicCI,
|
|
40
|
+
isEditor: false
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export default meta
|
|
@@ -1,49 +1,68 @@
|
|
|
1
|
-
import DynamicSeriesConfig from './_mock/dynamic_series_config.json'
|
|
2
|
-
import DynamicSeriesBarConfig from './_mock/dynamic_series_bar_config.json'
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
1
|
+
import DynamicSeriesConfig from './_mock/dynamic_series_config.json'
|
|
2
|
+
import DynamicSeriesBarConfig from './_mock/dynamic_series_bar_config.json'
|
|
3
|
+
import DynamicSeriesSuppression from './_mock/dynamic_series_suppression_mock.json'
|
|
4
|
+
import { Meta, StoryObj } from '@storybook/react'
|
|
5
|
+
import Chart from '../CdcChartComponent'
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof Chart> = {
|
|
8
|
+
title: 'Components/Templates/Chart/Dynamic Series',
|
|
9
|
+
component: Chart
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type Story = StoryObj<typeof Chart>
|
|
13
|
+
|
|
14
|
+
// data with a line break
|
|
15
|
+
const data = DynamicSeriesConfig.data.map((d, i) => (i === 4 ? { ...d, Data_Value: null } : d))
|
|
16
|
+
export const LineShowPoints: Story = {
|
|
17
|
+
args: {
|
|
18
|
+
config: {
|
|
19
|
+
...DynamicSeriesConfig,
|
|
20
|
+
data,
|
|
21
|
+
originalFormattedData: data,
|
|
22
|
+
formattedData: data,
|
|
23
|
+
lineDatapointStyle: 'always show'
|
|
24
|
+
},
|
|
25
|
+
isEditor: false
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const LineSuppression: Story = {
|
|
30
|
+
args: {
|
|
31
|
+
config: DynamicSeriesSuppression,
|
|
32
|
+
isEditor: false
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const LineHoverPoints: Story = {
|
|
37
|
+
args: {
|
|
38
|
+
config: DynamicSeriesConfig,
|
|
39
|
+
isEditor: false
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const Bar_Vertical: Story = {
|
|
44
|
+
args: {
|
|
45
|
+
config: DynamicSeriesBarConfig,
|
|
46
|
+
isEditor: false
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const Bar_Horizontal: Story = {
|
|
51
|
+
args: {
|
|
52
|
+
config: { ...DynamicSeriesBarConfig, orientation: 'horizontal' },
|
|
53
|
+
isEditor: false
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const Legend_Order: Story = {
|
|
58
|
+
args: {
|
|
59
|
+
config: {
|
|
60
|
+
...DynamicSeriesBarConfig,
|
|
61
|
+
orientation: 'vertical',
|
|
62
|
+
legend: { ...DynamicSeriesBarConfig, order: 'desc' }
|
|
63
|
+
},
|
|
64
|
+
isEditor: false
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default meta
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
2
|
import chartGradientConfig from './_mock/legend.gradient_mock.json'
|
|
3
|
+
import chartGroupedLagend from './_mock/legend_groupBy_mock.json'
|
|
3
4
|
import SimplifiedLineConfig from './_mock/simplified_line.json'
|
|
4
5
|
|
|
5
6
|
import Chart from '../CdcChartComponent'
|
|
@@ -17,6 +18,11 @@ export const Legend_Gradient_Smooth: Story = {
|
|
|
17
18
|
config: chartGradientConfig
|
|
18
19
|
}
|
|
19
20
|
}
|
|
21
|
+
export const Legend_Group_By: Story = {
|
|
22
|
+
args: {
|
|
23
|
+
config: chartGroupedLagend
|
|
24
|
+
}
|
|
25
|
+
}
|
|
20
26
|
|
|
21
27
|
export const Legend_Gradient_Linear_Blocks: Story = {
|
|
22
28
|
args: {
|
|
@@ -7,12 +7,11 @@ import lollipop from './_mock/lollipop.json'
|
|
|
7
7
|
import forestPlot from '../../examples/feature/forest-plot/forest-plot.json'
|
|
8
8
|
import pairedBar from './_mock/paired-bar.json'
|
|
9
9
|
import horizontalBarConfig from './_mock/horizontal_bar.json'
|
|
10
|
+
import barChartLabels from './_mock/barchart_labels.mock.json'
|
|
10
11
|
import pieConfig from './_mock/pie_with_data.json'
|
|
11
12
|
import boxPlotConfig from './_mock/boxplot_multiseries.json'
|
|
12
13
|
import areaChartStacked from './_mock/area_chart_stacked.json'
|
|
13
14
|
import multipleLines from './_mock/short_dates.json'
|
|
14
|
-
import lineChartDynamicCI from './_mock/line_chart_dynamic_ci.json'
|
|
15
|
-
import lineChartNonDynamicCI from './_mock/line_chart_non_dynamic_ci.json'
|
|
16
15
|
import { editConfigKeys } from '../helpers/configHelpers'
|
|
17
16
|
|
|
18
17
|
const meta: Meta<typeof Chart> = {
|
|
@@ -22,20 +21,6 @@ const meta: Meta<typeof Chart> = {
|
|
|
22
21
|
|
|
23
22
|
type Story = StoryObj<typeof Chart>
|
|
24
23
|
|
|
25
|
-
export const line_Chart_Dynamic_Confidence_Intervals: Story = {
|
|
26
|
-
args: {
|
|
27
|
-
config: lineChartDynamicCI,
|
|
28
|
-
isEditor: false
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const line_Chart_Non_Dynamic_Confidence_Intervals: Story = {
|
|
33
|
-
args: {
|
|
34
|
-
config: lineChartNonDynamicCI,
|
|
35
|
-
isEditor: false
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
24
|
export const line_Chart_Two_Points_Regression_Test: Story = {
|
|
40
25
|
args: {
|
|
41
26
|
config: lineChartTwoPointsRegressionTest,
|
|
@@ -74,6 +59,12 @@ export const Horizontal_Bar: Story = {
|
|
|
74
59
|
}
|
|
75
60
|
}
|
|
76
61
|
|
|
62
|
+
export const BarChart_Labels: Story = {
|
|
63
|
+
args: {
|
|
64
|
+
config: barChartLabels
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
77
68
|
export const Pie: Story = {
|
|
78
69
|
args: {
|
|
79
70
|
config: pieConfig
|