@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.
Files changed (86) hide show
  1. package/dist/cdcchart.js +46641 -42561
  2. package/index.html +130 -129
  3. package/package.json +22 -27
  4. package/src/CdcChartComponent.tsx +75 -35
  5. package/src/_stories/Chart.CI.stories.tsx +10 -0
  6. package/src/_stories/Chart.DynamicSeries.stories.tsx +68 -49
  7. package/src/_stories/Chart.stories.tsx +99 -86
  8. package/src/_stories/ChartPrefixSuffix.stories.tsx +29 -32
  9. package/{examples/private/line-issue.json → src/_stories/_mock/barchart_labels.mock.json} +150 -35
  10. package/src/_stories/_mock/dynamic_series_bar_config.json +1 -1
  11. package/src/_stories/_mock/dynamic_series_suppression_mock.json +610 -0
  12. package/{examples/private/not-loading.json → src/_stories/_mock/pie_calculated_area.json} +152 -95
  13. package/src/components/Annotations/components/AnnotationDropdown.tsx +2 -2
  14. package/src/components/AreaChart/components/AreaChart.jsx +33 -5
  15. package/src/components/Axis/Categorical.Axis.tsx +2 -2
  16. package/src/components/BarChart/components/BarChart.Horizontal.tsx +38 -37
  17. package/src/components/BarChart/components/BarChart.StackedHorizontal.tsx +18 -8
  18. package/src/components/BarChart/components/BarChart.StackedVertical.tsx +8 -8
  19. package/src/components/BarChart/components/BarChart.Vertical.tsx +47 -36
  20. package/src/components/BarChart/components/{BarChart.jsx → BarChart.tsx} +23 -5
  21. package/src/components/BarChart/components/context.tsx +20 -2
  22. package/src/components/BarChart/helpers/getBarHeights.ts +47 -0
  23. package/src/components/BarChart/helpers/index.ts +5 -2
  24. package/src/components/BarChart/helpers/tests/getBarHeights.test.ts +83 -0
  25. package/src/{hooks → components/BarChart/helpers}/useBarChart.ts +9 -46
  26. package/src/components/BoxPlot/BoxPlot.tsx +2 -1
  27. package/src/components/Brush/BrushChart.tsx +73 -0
  28. package/src/components/Brush/BrushController..tsx +39 -0
  29. package/src/components/DeviationBar.jsx +2 -2
  30. package/src/components/EditorPanel/EditorPanel.tsx +232 -147
  31. package/src/components/EditorPanel/components/Panels/Panel.General.tsx +36 -36
  32. package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +52 -25
  33. package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +12 -4
  34. package/src/components/EditorPanel/components/Panels/panelVisual.styles.css +8 -0
  35. package/src/components/EditorPanel/useEditorPermissions.ts +5 -5
  36. package/src/components/ForestPlot/ForestPlot.tsx +2 -2
  37. package/src/components/HoverLine/HoverLine.tsx +74 -0
  38. package/src/components/Legend/Legend.Component.tsx +1 -1
  39. package/src/components/Legend/Legend.Suppression.tsx +59 -25
  40. package/src/components/Legend/helpers/createFormatLabels.tsx +28 -0
  41. package/src/components/Legend/helpers/index.ts +1 -1
  42. package/src/components/LineChart/LineChartProps.ts +3 -1
  43. package/src/components/LineChart/components/LineChart.Circle.tsx +72 -119
  44. package/src/components/LineChart/helpers.ts +133 -56
  45. package/src/components/LineChart/index.tsx +106 -55
  46. package/src/components/LinearChart.tsx +178 -198
  47. package/src/components/PairedBarChart.jsx +3 -2
  48. package/src/components/PieChart/PieChart.tsx +127 -102
  49. package/src/components/ScatterPlot/ScatterPlot.jsx +5 -0
  50. package/src/components/Sparkline/components/SparkLine.tsx +80 -18
  51. package/src/data/initial-state.js +11 -6
  52. package/src/helpers/countNumOfTicks.ts +1 -1
  53. package/src/helpers/dataHelpers.ts +23 -2
  54. package/src/helpers/getNewRuntime.ts +35 -0
  55. package/src/helpers/getPiePercent.ts +22 -0
  56. package/src/helpers/getTransformedData.ts +22 -0
  57. package/src/helpers/sizeHelpers.ts +1 -1
  58. package/src/helpers/tests/getNewRuntime.test.ts +82 -0
  59. package/src/helpers/tests/getPiePercent.test.ts +38 -0
  60. package/src/hooks/useMinMax.ts +21 -28
  61. package/src/hooks/useRightAxis.ts +5 -3
  62. package/src/hooks/useScales.ts +15 -6
  63. package/src/hooks/useTooltip.tsx +218 -203
  64. package/src/index.jsx +2 -2
  65. package/src/scss/main.scss +13 -6
  66. package/src/store/chart.actions.ts +2 -6
  67. package/src/store/chart.reducer.ts +23 -23
  68. package/src/types/ChartConfig.ts +11 -3
  69. package/src/types/ChartContext.ts +0 -2
  70. package/examples/private/DEV-8850-2.json +0 -493
  71. package/examples/private/DEV-9822.json +0 -574
  72. package/examples/private/DEV-9840.json +0 -553
  73. package/examples/private/DEV-9850-3.json +0 -461
  74. package/examples/private/chart.json +0 -1084
  75. package/examples/private/ci_formatted.json +0 -202
  76. package/examples/private/ci_issue.json +0 -3016
  77. package/examples/private/completed.json +0 -634
  78. package/examples/private/dem-data-long.csv +0 -20
  79. package/examples/private/dem-data-long.json +0 -36
  80. package/examples/private/demographic_data.csv +0 -157
  81. package/examples/private/demographic_data.json +0 -2654
  82. package/examples/private/demographic_dynamic.json +0 -443
  83. package/examples/private/demographic_standard.json +0 -560
  84. package/examples/private/ehdi.json +0 -29939
  85. package/examples/private/test.json +0 -493
  86. 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
- export const EDITOR_WIDTH = 350
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 = async (loadedConfig: ChartConfig) => {
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['yAxis'] ? newConfig.yAxis['yAxis'] : newConfig.yAxis
290
- newConfig.runtime.yAxis = newConfig.xAxis['xAxis'] ? newConfig.xAxis['xAxis'] : 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, 'Chart')
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.log('Error on prepareData function ', err)
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
- let preppedData = await prepareData(preparedConfig)
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 (seriesHighlight.length + 1 === config.runtime.seriesKeys.length && config.visualizationType !== 'Forecasting') {
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
- // if onlyShowTopPrefixSuffix only show top prefix
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' && !onlyShowTopPrefixSuffix) {
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
- setConfig={setConfig}
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' || legend.position === 'top' || visualizationType === 'Sankey'
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
- setConfig={setConfig}
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
- when the default sort changes while editing */
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?.footnotes && <section className='footnotes pt-2 mt-4'>{parse(config.footnotes)}</section>}
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: clean(filteredData || excludedData),
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 { Meta, StoryObj } from '@storybook/react'
4
- import Chart from '../CdcChartComponent'
5
-
6
- const meta: Meta<typeof Chart> = {
7
- title: 'Components/Templates/Chart/Dynamic Series',
8
- component: Chart
9
- }
10
-
11
- type Story = StoryObj<typeof Chart>
12
-
13
- // data with a line break
14
- const data = DynamicSeriesConfig.data.map((d, i) => (i === 4 ? { ...d, Data_Value: null } : d))
15
- export const LineShowPoints: Story = {
16
- args: {
17
- config: {
18
- ...DynamicSeriesConfig,
19
- data,
20
- originalFormattedData: data,
21
- formattedData: data,
22
- lineDatapointStyle: 'always show'
23
- },
24
- isEditor: false
25
- }
26
- }
27
-
28
- export const LineHoverPoints: Story = {
29
- args: {
30
- config: DynamicSeriesConfig,
31
- isEditor: false
32
- }
33
- }
34
-
35
- export const Bar_Vertical: Story = {
36
- args: {
37
- config: DynamicSeriesBarConfig,
38
- isEditor: false
39
- }
40
- }
41
-
42
- export const Bar_Horizontal: Story = {
43
- args: {
44
- config: { ...DynamicSeriesBarConfig, orientation: 'horizontal' },
45
- isEditor: false
46
- }
47
- }
48
-
49
- export default meta
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 pieConfig from './_mock/pie_with_data.json'
11
- import boxPlotConfig from './_mock/boxplot_multiseries.json'
12
- import areaChartStacked from './_mock/area_chart_stacked.json'
13
- import multipleLines from './_mock/short_dates.json'
14
- import { editConfigKeys } from '../helpers/configHelpers'
15
-
16
- const meta: Meta<typeof Chart> = {
17
- title: 'Components/Templates/Chart',
18
- component: Chart
19
- }
20
-
21
- type Story = StoryObj<typeof Chart>
22
-
23
- export const line_Chart_Two_Points_Regression_Test: Story = {
24
- args: {
25
- config: lineChartTwoPointsRegressionTest,
26
- isEditor: false
27
- }
28
- }
29
- export const line_Chart_Two_Points_New_Chart: Story = {
30
- args: {
31
- config: lineChartTwoPointsNewChart,
32
- isEditor: false
33
- }
34
- }
35
-
36
- export const multiple_lines: Story = {
37
- args: {
38
- config: editConfigKeys(multipleLines, [{ path: ['tooltips', 'dateDisplayFormat'], value: '%b. %d %Y' }])
39
- }
40
- }
41
-
42
- export const Lollipop: Story = {
43
- args: {
44
- config: lollipop,
45
- isEditor: false
46
- }
47
- }
48
-
49
- export const Forest_Plot: Story = {
50
- args: {
51
- config: forestPlot
52
- }
53
- }
54
-
55
- export const Horizontal_Bar: Story = {
56
- args: {
57
- config: horizontalBarConfig
58
- }
59
- }
60
-
61
- export const Pie: Story = {
62
- args: {
63
- config: pieConfig
64
- }
65
- }
66
-
67
- export const Paired_Bar: Story = {
68
- args: {
69
- config: pairedBar
70
- }
71
- }
72
- export const BoxPlot_Multiseries: Story = {
73
- args: {
74
- config: boxPlotConfig,
75
- isEditor: false
76
- }
77
- }
78
-
79
- export const Area_Chart_stacked: Story = {
80
- args: {
81
- config: areaChartStacked,
82
- isEditor: false
83
- }
84
- }
85
-
86
- export default meta
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