@cdc/chart 4.25.3 → 4.25.6
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 +46641 -42561
- package/index.html +130 -129
- package/package.json +22 -27
- package/src/CdcChartComponent.tsx +75 -35
- package/src/_stories/Chart.CI.stories.tsx +10 -0
- package/src/_stories/Chart.DynamicSeries.stories.tsx +68 -49
- package/src/_stories/Chart.stories.tsx +99 -86
- package/src/_stories/ChartPrefixSuffix.stories.tsx +29 -32
- package/{examples/private/line-issue.json → src/_stories/_mock/barchart_labels.mock.json} +150 -35
- 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/not-loading.json → src/_stories/_mock/pie_calculated_area.json} +152 -95
- 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 +38 -37
- package/src/components/BarChart/components/BarChart.StackedHorizontal.tsx +18 -8
- package/src/components/BarChart/components/BarChart.StackedVertical.tsx +8 -8
- package/src/components/BarChart/components/BarChart.Vertical.tsx +47 -36
- 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 +9 -46
- package/src/components/BoxPlot/BoxPlot.tsx +2 -1
- package/src/components/Brush/BrushChart.tsx +73 -0
- package/src/components/Brush/BrushController..tsx +39 -0
- package/src/components/DeviationBar.jsx +2 -2
- package/src/components/EditorPanel/EditorPanel.tsx +232 -147
- package/src/components/EditorPanel/components/Panels/Panel.General.tsx +36 -36
- package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +52 -25
- package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +12 -4
- package/src/components/EditorPanel/components/Panels/panelVisual.styles.css +8 -0
- package/src/components/EditorPanel/useEditorPermissions.ts +5 -5
- package/src/components/ForestPlot/ForestPlot.tsx +2 -2
- package/src/components/HoverLine/HoverLine.tsx +74 -0
- package/src/components/Legend/Legend.Component.tsx +1 -1
- package/src/components/Legend/Legend.Suppression.tsx +59 -25
- package/src/components/Legend/helpers/createFormatLabels.tsx +28 -0
- package/src/components/Legend/helpers/index.ts +1 -1
- package/src/components/LineChart/LineChartProps.ts +3 -1
- package/src/components/LineChart/components/LineChart.Circle.tsx +72 -119
- package/src/components/LineChart/helpers.ts +133 -56
- package/src/components/LineChart/index.tsx +106 -55
- package/src/components/LinearChart.tsx +178 -198
- package/src/components/PairedBarChart.jsx +3 -2
- package/src/components/PieChart/PieChart.tsx +127 -102
- package/src/components/ScatterPlot/ScatterPlot.jsx +5 -0
- package/src/components/Sparkline/components/SparkLine.tsx +80 -18
- package/src/data/initial-state.js +11 -6
- package/src/helpers/countNumOfTicks.ts +1 -1
- package/src/helpers/dataHelpers.ts +23 -2
- package/src/helpers/getNewRuntime.ts +35 -0
- package/src/helpers/getPiePercent.ts +22 -0
- package/src/helpers/getTransformedData.ts +22 -0
- package/src/helpers/sizeHelpers.ts +1 -1
- package/src/helpers/tests/getNewRuntime.test.ts +82 -0
- package/src/helpers/tests/getPiePercent.test.ts +38 -0
- package/src/hooks/useMinMax.ts +21 -28
- package/src/hooks/useRightAxis.ts +5 -3
- package/src/hooks/useScales.ts +15 -6
- package/src/hooks/useTooltip.tsx +218 -203
- package/src/index.jsx +2 -2
- package/src/scss/main.scss +13 -6
- package/src/store/chart.actions.ts +2 -6
- package/src/store/chart.reducer.ts +23 -23
- package/src/types/ChartConfig.ts +11 -3
- package/src/types/ChartContext.ts +0 -2
- 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/test.json +0 -493
- package/src/components/ZoomBrush.tsx +0 -251
|
@@ -64,17 +64,23 @@ 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'
|
|
70
71
|
import { getComboChartConfig } from './helpers/getComboChartConfig'
|
|
71
72
|
import { getExcludedData } from './helpers/getExcludedData'
|
|
72
73
|
import { getColorScale } from './helpers/getColorScale'
|
|
74
|
+
import { getTransformedData } from './helpers/getTransformedData'
|
|
75
|
+
import { getPiePercent } from './helpers/getPiePercent'
|
|
76
|
+
|
|
73
77
|
// styles
|
|
74
78
|
import './scss/main.scss'
|
|
75
79
|
import { getInitialState, reducer } from './store/chart.reducer'
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
import { VizFilter } from '@cdc/core/types/VizFilter'
|
|
81
|
+
import { getNewRuntime } from './helpers/getNewRuntime'
|
|
82
|
+
import FootnotesStandAlone from '@cdc/core/components/Footnotes/FootnotesStandAlone'
|
|
83
|
+
import { Datasets } from '@cdc/core/types/DataSet'
|
|
78
84
|
|
|
79
85
|
interface CdcChartProps {
|
|
80
86
|
config?: ChartConfig
|
|
@@ -88,6 +94,7 @@ interface CdcChartProps {
|
|
|
88
94
|
setSharedFilter?: (filter: any) => void
|
|
89
95
|
setSharedFilterValue?: (value: any) => void
|
|
90
96
|
dashboardConfig?: DashboardConfig
|
|
97
|
+
datasets?: Datasets
|
|
91
98
|
}
|
|
92
99
|
const CdcChart: React.FC<CdcChartProps> = ({
|
|
93
100
|
config: configObj,
|
|
@@ -99,7 +106,8 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
99
106
|
link,
|
|
100
107
|
setSharedFilter,
|
|
101
108
|
setSharedFilterValue,
|
|
102
|
-
dashboardConfig
|
|
109
|
+
dashboardConfig,
|
|
110
|
+
datasets
|
|
103
111
|
}) => {
|
|
104
112
|
const transform = new DataTransform()
|
|
105
113
|
const initialState = getInitialState(configObj)
|
|
@@ -131,10 +139,6 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
131
139
|
}
|
|
132
140
|
}
|
|
133
141
|
|
|
134
|
-
const setFiltersData = (filteredData: object[]): void => {
|
|
135
|
-
dispatch({ type: 'SET_FILTERED_DATA', payload: filteredData })
|
|
136
|
-
}
|
|
137
|
-
|
|
138
142
|
const legendRef = useRef(null)
|
|
139
143
|
const parentRef = useRef(null)
|
|
140
144
|
|
|
@@ -142,8 +146,6 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
142
146
|
dispatch({ type: 'SET_DRAG_ANNOTATIONS', payload: isDragging })
|
|
143
147
|
}
|
|
144
148
|
|
|
145
|
-
if (isDebug) console.log('Chart config, isEditor', config, isEditor)
|
|
146
|
-
|
|
147
149
|
// Destructure items from config for more readable JSX
|
|
148
150
|
let { legend, title } = config
|
|
149
151
|
|
|
@@ -163,7 +165,7 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
163
165
|
|
|
164
166
|
const convertLineToBarGraph = isConvertLineToBarGraph(config, filteredData)
|
|
165
167
|
|
|
166
|
-
const prepareConfig =
|
|
168
|
+
const prepareConfig = (loadedConfig: ChartConfig) => {
|
|
167
169
|
let newConfig = _.defaultsDeep(loadedConfig, defaults)
|
|
168
170
|
_.defaultsDeep(newConfig, {
|
|
169
171
|
table: { showVertical: false }
|
|
@@ -280,14 +282,15 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
280
282
|
newConfig.series.forEach(series => {
|
|
281
283
|
newConfig.runtime.areaSeriesKeys.push({ ...series, type: 'Area Chart' })
|
|
282
284
|
})
|
|
285
|
+
newConfig.visualizationSubType = 'stacked'
|
|
283
286
|
}
|
|
284
287
|
|
|
285
288
|
if (
|
|
286
289
|
(newConfig.visualizationType === 'Bar' && newConfig.orientation === 'horizontal') ||
|
|
287
290
|
['Deviation Bar', 'Paired Bar', 'Forest Plot'].includes(newConfig.visualizationType)
|
|
288
291
|
) {
|
|
289
|
-
newConfig.runtime.xAxis = newConfig.yAxis
|
|
290
|
-
newConfig.runtime.yAxis = newConfig.xAxis
|
|
292
|
+
newConfig.runtime.xAxis = _.cloneDeep(newConfig.yAxis.yAxis || newConfig.yAxis)
|
|
293
|
+
newConfig.runtime.yAxis = _.cloneDeep(newConfig.xAxis.xAxis || newConfig.xAxis)
|
|
291
294
|
newConfig.runtime.yAxis.labelOffset *= -1
|
|
292
295
|
|
|
293
296
|
newConfig.runtime.horizontal = false
|
|
@@ -342,6 +345,30 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
342
345
|
}
|
|
343
346
|
}
|
|
344
347
|
|
|
348
|
+
const setFilters = (newFilters: VizFilter[]) => {
|
|
349
|
+
if (!config.dynamicSeries) {
|
|
350
|
+
const _newFilters = addValuesToFilters(newFilters, excludedData)
|
|
351
|
+
setConfig({
|
|
352
|
+
...config,
|
|
353
|
+
filters: _newFilters
|
|
354
|
+
})
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if (config.filterBehavior === 'Filter Change' || config.filterBehavior === 'Apply Button') {
|
|
358
|
+
const newFilteredData = filterVizData(newFilters, excludedData)
|
|
359
|
+
|
|
360
|
+
dispatch({ type: 'SET_FILTERED_DATA', payload: newFilteredData })
|
|
361
|
+
if (config.dynamicSeries) {
|
|
362
|
+
const runtime = getNewRuntime(config, newFilteredData)
|
|
363
|
+
setConfig({
|
|
364
|
+
...config,
|
|
365
|
+
filters: newFilters,
|
|
366
|
+
runtime
|
|
367
|
+
})
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
345
372
|
// Observes changes to outermost container and changes viewport size in state
|
|
346
373
|
const resizeObserver = new ResizeObserver(entries => {
|
|
347
374
|
for (let entry of entries) {
|
|
@@ -380,7 +407,7 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
380
407
|
if (newConfig.dataUrl && !urlFilters) {
|
|
381
408
|
// handle urls with spaces in the name.
|
|
382
409
|
if (newConfig.dataUrl) newConfig.dataUrl = `${newConfig.dataUrl}`
|
|
383
|
-
let newData = await fetchRemoteData(newConfig.dataUrl
|
|
410
|
+
let newData = await fetchRemoteData(newConfig.dataUrl)
|
|
384
411
|
|
|
385
412
|
if (newData && newConfig.dataDescription) {
|
|
386
413
|
newData = transform.autoStandardize(newData)
|
|
@@ -397,7 +424,7 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
397
424
|
newConfig.data = transform.developerStandardize(newConfig.data, newConfig.dataDescription)
|
|
398
425
|
}
|
|
399
426
|
} catch (err) {
|
|
400
|
-
console.
|
|
427
|
+
console.error('Error on prepareData function ', err)
|
|
401
428
|
}
|
|
402
429
|
return newConfig
|
|
403
430
|
}
|
|
@@ -407,7 +434,12 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
407
434
|
try {
|
|
408
435
|
if (configObj) {
|
|
409
436
|
const preparedConfig = await prepareConfig(configObj)
|
|
410
|
-
|
|
437
|
+
const preppedData = await prepareData(preparedConfig)
|
|
438
|
+
|
|
439
|
+
if (preparedConfig?.formattedData?.length) {
|
|
440
|
+
preppedData.data = preparedConfig.formattedData
|
|
441
|
+
}
|
|
442
|
+
|
|
411
443
|
dispatch({ type: 'SET_STATE_DATA', payload: preppedData.data })
|
|
412
444
|
dispatch({ type: 'SET_EXCLUDED_DATA', payload: preppedData.data })
|
|
413
445
|
updateConfig(preparedConfig, preppedData.data)
|
|
@@ -494,7 +526,11 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
494
526
|
|
|
495
527
|
// Called on legend click, highlights/unhighlights the data series with the given label
|
|
496
528
|
const highlight = (label: Label): void => {
|
|
497
|
-
if (
|
|
529
|
+
if (
|
|
530
|
+
seriesHighlight.length + 1 === config.runtime.seriesKeys.length &&
|
|
531
|
+
config.visualizationType !== 'Forecasting' &&
|
|
532
|
+
!seriesHighlight.includes(label.datum)
|
|
533
|
+
) {
|
|
498
534
|
return handleShowAll()
|
|
499
535
|
}
|
|
500
536
|
|
|
@@ -592,8 +628,7 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
592
628
|
rightSuffix,
|
|
593
629
|
bottomPrefix,
|
|
594
630
|
bottomSuffix,
|
|
595
|
-
bottomAbbreviated
|
|
596
|
-
onlyShowTopPrefixSuffix
|
|
631
|
+
bottomAbbreviated
|
|
597
632
|
}
|
|
598
633
|
} = config
|
|
599
634
|
|
|
@@ -686,9 +721,7 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
686
721
|
if (addColPrefix && axis === 'left') {
|
|
687
722
|
result = addColPrefix + result
|
|
688
723
|
} else {
|
|
689
|
-
|
|
690
|
-
const suppressAllButLast = onlyShowTopPrefixSuffix && length - 1 !== index
|
|
691
|
-
if (prefix && axis === 'left' && !suppressAllButLast) {
|
|
724
|
+
if (prefix && axis === 'left') {
|
|
692
725
|
result += prefix
|
|
693
726
|
}
|
|
694
727
|
}
|
|
@@ -707,7 +740,7 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
707
740
|
if (addColSuffix && axis === 'left') {
|
|
708
741
|
result += addColSuffix
|
|
709
742
|
} else {
|
|
710
|
-
if (suffix && axis === 'left'
|
|
743
|
+
if (suffix && axis === 'left') {
|
|
711
744
|
result += suffix
|
|
712
745
|
}
|
|
713
746
|
}
|
|
@@ -762,6 +795,10 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
762
795
|
const getTableRuntimeData = () => {
|
|
763
796
|
if (visualizationType === 'Sankey') return config?.data?.[0]?.tableData
|
|
764
797
|
const data = filteredData || excludedData
|
|
798
|
+
if (config.visualizationType === 'Pie' && !config.dataFormat?.showPiePercent) {
|
|
799
|
+
return getPiePercent(data, config?.yAxis?.dataKey)
|
|
800
|
+
}
|
|
801
|
+
|
|
765
802
|
const dynamicSeries = config.series.find(series => !!series.dynamicCategory)
|
|
766
803
|
if (!dynamicSeries) return data
|
|
767
804
|
const usedColumns = Object.values(config.columns)
|
|
@@ -828,7 +865,7 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
828
865
|
|
|
829
866
|
body = (
|
|
830
867
|
<>
|
|
831
|
-
{isEditor && <EditorPanel />}
|
|
868
|
+
{isEditor && <EditorPanel datasets={datasets} />}
|
|
832
869
|
<Layout.Responsive isEditor={isEditor}>
|
|
833
870
|
{config.newViz && <Confirm updateConfig={updateConfig} config={config} />}
|
|
834
871
|
{undefined === config.newViz && isEditor && config.runtime && config.runtime?.editorErrorMessage && (
|
|
@@ -862,11 +899,8 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
862
899
|
{config.filters && !externalFilters && config.visualizationType !== 'Spark Line' && (
|
|
863
900
|
<Filters
|
|
864
901
|
config={config}
|
|
865
|
-
|
|
866
|
-
setFilteredData={setFiltersData}
|
|
867
|
-
filteredData={filteredData}
|
|
902
|
+
setFilters={setFilters}
|
|
868
903
|
excludedData={excludedData}
|
|
869
|
-
filterData={filterVizData}
|
|
870
904
|
dimensions={dimensions}
|
|
871
905
|
/>
|
|
872
906
|
)}
|
|
@@ -883,7 +917,10 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
883
917
|
className={
|
|
884
918
|
legend.hide || isLegendWrapViewport(currentViewport)
|
|
885
919
|
? 'w-100'
|
|
886
|
-
: legend.position === 'bottom' ||
|
|
920
|
+
: legend.position === 'bottom' ||
|
|
921
|
+
legend.position === 'top' ||
|
|
922
|
+
visualizationType === 'Sankey' ||
|
|
923
|
+
visualizationType === 'Spark Line'
|
|
887
924
|
? 'w-100'
|
|
888
925
|
: 'w-75'
|
|
889
926
|
}
|
|
@@ -940,11 +977,8 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
940
977
|
<>
|
|
941
978
|
<Filters
|
|
942
979
|
config={config}
|
|
943
|
-
|
|
944
|
-
setFilteredData={setFiltersData}
|
|
945
|
-
filteredData={filteredData}
|
|
980
|
+
setFilters={setFilters}
|
|
946
981
|
excludedData={excludedData}
|
|
947
|
-
filterData={filterVizData}
|
|
948
982
|
dimensions={dimensions}
|
|
949
983
|
/>
|
|
950
984
|
{config?.introText && (
|
|
@@ -1015,7 +1049,7 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
1015
1049
|
(config.visualizationType === 'Sankey' && config.table.show)) && (
|
|
1016
1050
|
<DataTable
|
|
1017
1051
|
/* changing the "key" will force the table to re-render
|
|
1018
|
-
|
|
1052
|
+
when the default sort changes while editing */
|
|
1019
1053
|
key={dataTableDefaultSortBy}
|
|
1020
1054
|
config={pivotDynamicSeries(config)}
|
|
1021
1055
|
rawData={
|
|
@@ -1041,8 +1075,14 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
1041
1075
|
)}
|
|
1042
1076
|
{config?.annotations?.length > 0 && <Annotation.Dropdown />}
|
|
1043
1077
|
{/* show pdf or image button */}
|
|
1044
|
-
{config?.
|
|
1078
|
+
{config?.legacyFootnotes && (
|
|
1079
|
+
<section className='footnotes pt-2 mt-4'>{parse(config.legacyFootnotes)}</section>
|
|
1080
|
+
)}
|
|
1045
1081
|
</div>
|
|
1082
|
+
<FootnotesStandAlone
|
|
1083
|
+
config={configObj.footnotes}
|
|
1084
|
+
filters={config.filters?.filter(f => f.filterFootnotes)}
|
|
1085
|
+
/>
|
|
1046
1086
|
</div>
|
|
1047
1087
|
)}
|
|
1048
1088
|
</Layout.Responsive>
|
|
@@ -1100,7 +1140,7 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
1100
1140
|
setSharedFilterValue,
|
|
1101
1141
|
svgRef,
|
|
1102
1142
|
tableData: filteredData || excludedData,
|
|
1103
|
-
transformedData:
|
|
1143
|
+
transformedData: getTransformedData({ brushData: state.brushData, filteredData, excludedData, clean }),
|
|
1104
1144
|
twoColorPalette,
|
|
1105
1145
|
unfilteredData: _.cloneDeep(stateData),
|
|
1106
1146
|
updateConfig
|
|
@@ -16,6 +16,16 @@ export const bar_chart_with_labels: Story = {
|
|
|
16
16
|
isEditor: false
|
|
17
17
|
}
|
|
18
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
|
+
}
|
|
19
29
|
|
|
20
30
|
export const line_Chart_Dynamic_Confidence_Intervals: Story = {
|
|
21
31
|
args: {
|
|
@@ -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,86 +1,99 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
|
-
|
|
3
|
-
import Chart from '../CdcChart'
|
|
4
|
-
import lineChartTwoPointsRegressionTest from './_mock/line_chart_two_points_regression_test.json'
|
|
5
|
-
import lineChartTwoPointsNewChart from './_mock/line_chart_two_points_new_chart.json'
|
|
6
|
-
import lollipop from './_mock/lollipop.json'
|
|
7
|
-
import forestPlot from '../../examples/feature/forest-plot/forest-plot.json'
|
|
8
|
-
import pairedBar from './_mock/paired-bar.json'
|
|
9
|
-
import horizontalBarConfig from './_mock/horizontal_bar.json'
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
|
+
|
|
3
|
+
import Chart from '../CdcChart'
|
|
4
|
+
import lineChartTwoPointsRegressionTest from './_mock/line_chart_two_points_regression_test.json'
|
|
5
|
+
import lineChartTwoPointsNewChart from './_mock/line_chart_two_points_new_chart.json'
|
|
6
|
+
import lollipop from './_mock/lollipop.json'
|
|
7
|
+
import forestPlot from '../../examples/feature/forest-plot/forest-plot.json'
|
|
8
|
+
import pairedBar from './_mock/paired-bar.json'
|
|
9
|
+
import horizontalBarConfig from './_mock/horizontal_bar.json'
|
|
10
|
+
import barChartLabels from './_mock/barchart_labels.mock.json'
|
|
11
|
+
import pieConfig from './_mock/pie_with_data.json'
|
|
12
|
+
import pieCalculatedArea from './_mock/pie_calculated_area.json'
|
|
13
|
+
import boxPlotConfig from './_mock/boxplot_multiseries.json'
|
|
14
|
+
import areaChartStacked from './_mock/area_chart_stacked.json'
|
|
15
|
+
import multipleLines from './_mock/short_dates.json'
|
|
16
|
+
import { editConfigKeys } from '../helpers/configHelpers'
|
|
17
|
+
|
|
18
|
+
const meta: Meta<typeof Chart> = {
|
|
19
|
+
title: 'Components/Templates/Chart',
|
|
20
|
+
component: Chart
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type Story = StoryObj<typeof Chart>
|
|
24
|
+
|
|
25
|
+
export const line_Chart_Two_Points_Regression_Test: Story = {
|
|
26
|
+
args: {
|
|
27
|
+
config: lineChartTwoPointsRegressionTest,
|
|
28
|
+
isEditor: false
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export const line_Chart_Two_Points_New_Chart: Story = {
|
|
32
|
+
args: {
|
|
33
|
+
config: lineChartTwoPointsNewChart,
|
|
34
|
+
isEditor: false
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const multiple_lines: Story = {
|
|
39
|
+
args: {
|
|
40
|
+
config: editConfigKeys(multipleLines, [{ path: ['tooltips', 'dateDisplayFormat'], value: '%b. %d %Y' }])
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const Lollipop: Story = {
|
|
45
|
+
args: {
|
|
46
|
+
config: lollipop,
|
|
47
|
+
isEditor: false
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const Forest_Plot: Story = {
|
|
52
|
+
args: {
|
|
53
|
+
config: forestPlot
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const Horizontal_Bar: Story = {
|
|
58
|
+
args: {
|
|
59
|
+
config: horizontalBarConfig
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const BarChart_Labels: Story = {
|
|
64
|
+
args: {
|
|
65
|
+
config: barChartLabels
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const Pie: Story = {
|
|
70
|
+
args: {
|
|
71
|
+
config: pieConfig
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export const Pie_Calculated_Area: Story = {
|
|
75
|
+
args: {
|
|
76
|
+
config: pieCalculatedArea
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const Paired_Bar: Story = {
|
|
81
|
+
args: {
|
|
82
|
+
config: pairedBar
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export const BoxPlot_Multiseries: Story = {
|
|
86
|
+
args: {
|
|
87
|
+
config: boxPlotConfig,
|
|
88
|
+
isEditor: false
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export const Area_Chart_stacked: Story = {
|
|
93
|
+
args: {
|
|
94
|
+
config: areaChartStacked,
|
|
95
|
+
isEditor: false
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export default meta
|