@cdc/chart 4.26.1 → 4.26.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/CLAUDE.local.md +79 -0
  2. package/dist/{cdcchart-dgT_1dIT.es.js → cdcchart-DQ00cQCm.es.js} +1 -20
  3. package/dist/cdcchart.js +45357 -43655
  4. package/examples/default.json +378 -0
  5. package/examples/feature/__data__/horizon-chart-data.json +373 -0
  6. package/examples/feature/annotations/index.json +3 -6
  7. package/examples/feature/horizon/horizon-chart.json +395 -0
  8. package/examples/line-chart-states.json +1085 -0
  9. package/examples/private/123.json +694 -0
  10. package/examples/private/anchor-issue.json +4094 -0
  11. package/examples/private/backwards-slider.json +10430 -0
  12. package/examples/private/georgia.csv +160 -0
  13. package/examples/private/timeline-data.json +1 -0
  14. package/examples/private/timeline.json +389 -0
  15. package/examples/radar-chart-simple.json +133 -0
  16. package/examples/radar-chart.json +148 -0
  17. package/index.html +1 -31
  18. package/package.json +57 -59
  19. package/src/CdcChartComponent.tsx +99 -18
  20. package/src/_stories/Chart.Anchors.stories.tsx +10 -0
  21. package/src/_stories/Chart.BoxPlot.stories.tsx +7 -0
  22. package/src/_stories/Chart.CI.stories.tsx +13 -0
  23. package/src/_stories/Chart.Combo.stories.tsx +17 -0
  24. package/src/_stories/Chart.CustomColors.stories.tsx +4 -0
  25. package/src/_stories/Chart.DynamicSeries.stories.tsx +19 -0
  26. package/src/_stories/Chart.Filters.stories.tsx +4 -0
  27. package/src/_stories/Chart.Forecast.stories.tsx +4 -0
  28. package/src/_stories/Chart.HTMLInDataTable.stories.tsx +22 -0
  29. package/src/_stories/Chart.Legend.Gradient.stories.tsx +28 -0
  30. package/src/_stories/Chart.Patterns.stories.tsx +4 -0
  31. package/src/_stories/Chart.PreserveDecimals.stories.tsx +25 -0
  32. package/src/_stories/Chart.Regions.Categorical.stories.tsx +13 -0
  33. package/src/_stories/Chart.Regions.DateScale.stories.tsx +19 -0
  34. package/src/_stories/Chart.Regions.DateTimeScale.stories.tsx +25 -10
  35. package/src/_stories/Chart.ScatterPlot.stories.tsx +4 -0
  36. package/src/_stories/Chart.SmallMultiples.stories.tsx +16 -0
  37. package/src/_stories/Chart.stories.tsx +37 -0
  38. package/src/_stories/Chart.tooltip.stories.tsx +7 -0
  39. package/src/_stories/ChartAnnotation.stories.tsx +10 -0
  40. package/src/_stories/ChartAxisLabels.stories.tsx +4 -0
  41. package/src/_stories/ChartAxisTitles.stories.tsx +10 -0
  42. package/src/_stories/ChartBrush.Matrix.Continuous.stories.tsx +41 -0
  43. package/src/_stories/ChartBrush.Matrix.Date.stories.tsx +114 -0
  44. package/src/_stories/ChartBrush.Matrix.DateTime.stories.tsx +78 -0
  45. package/src/_stories/ChartBrush.stories.tsx +7 -0
  46. package/src/_stories/ChartEditor.stories.tsx +7 -0
  47. package/src/_stories/ChartLine.QuadrantAngles.stories.tsx +89 -0
  48. package/src/_stories/ChartLine.Suppression.stories.tsx +7 -0
  49. package/src/_stories/ChartLine.Symbols.stories.tsx +4 -0
  50. package/src/_stories/ChartPrefixSuffix.stories.tsx +46 -1
  51. package/src/_stories/TechAdoptionWithLinks.stories.tsx +7 -0
  52. package/src/_stories/_mock/brush_continuous.json +86 -0
  53. package/src/_stories/_mock/brush_date_large.json +176 -0
  54. package/src/_stories/_mock/line_chart_angle_near_zero_fall.json +195 -0
  55. package/src/_stories/_mock/line_chart_angle_near_zero_rise.json +195 -0
  56. package/src/_stories/_mock/line_chart_angle_q1_steep_upward.json +195 -0
  57. package/src/_stories/_mock/line_chart_angle_q2_gentle_downward.json +195 -0
  58. package/src/_stories/_mock/line_chart_angle_q3_steep_downward.json +195 -0
  59. package/src/_stories/_mock/line_chart_angle_q4_gentle_upward.json +195 -0
  60. package/src/_stories/_mock/line_chart_quadrant_angles.json +264 -0
  61. package/src/components/Annotations/components/AnnotationDraggable.styles.css +11 -17
  62. package/src/components/Annotations/components/AnnotationDraggable.tsx +240 -116
  63. package/src/components/Annotations/components/AnnotationDropdown.styles.css +1 -2
  64. package/src/components/Annotations/components/AnnotationDropdown.tsx +8 -12
  65. package/src/components/Annotations/components/AnnotationList.styles.css +4 -10
  66. package/src/components/Annotations/components/AnnotationList.tsx +5 -4
  67. package/src/components/Annotations/components/findNearestDatum.ts +75 -85
  68. package/src/components/Annotations/helpers/getVisibleAnnotations.ts +38 -0
  69. package/src/components/Axis/BottomAxis.tsx +270 -0
  70. package/src/components/Axis/LeftAxis.tsx +404 -0
  71. package/src/components/Axis/LeftAxisGridlines.tsx +77 -0
  72. package/src/components/Axis/PairedBarAxis.tsx +186 -0
  73. package/src/components/Axis/README.md +94 -0
  74. package/src/components/Axis/RightAxis.tsx +108 -0
  75. package/src/components/Axis/axis.constants.ts +21 -0
  76. package/src/components/Axis/index.ts +7 -0
  77. package/src/components/BarChart/components/BarChart.tsx +7 -1
  78. package/src/components/Brush/BrushSelector.tsx +154 -22
  79. package/src/components/Brush/MiniChartPreview.tsx +138 -21
  80. package/src/components/EditorPanel/EditorPanel.tsx +25 -11
  81. package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +60 -22
  82. package/src/components/EditorPanel/components/Panels/Panel.General.tsx +81 -1
  83. package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +1 -1
  84. package/src/components/EditorPanel/components/Panels/Panel.Radar.tsx +353 -0
  85. package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +0 -1
  86. package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +21 -1
  87. package/src/components/EditorPanel/components/Panels/index.tsx +2 -0
  88. package/src/components/EditorPanel/useEditorPermissions.ts +55 -26
  89. package/src/components/HorizonChart/HorizonChart.tsx +131 -0
  90. package/src/components/HorizonChart/components/HorizonBand.tsx +160 -0
  91. package/src/components/HorizonChart/helpers/calculateHorizonBands.ts +27 -0
  92. package/src/components/HorizonChart/helpers/getHorizonLayerColors.ts +40 -0
  93. package/src/components/HorizonChart/index.tsx +3 -0
  94. package/src/components/Legend/Legend.Component.tsx +52 -4
  95. package/src/components/Legend/Legend.tsx +1 -1
  96. package/src/components/Legend/LegendValueRange.tsx +77 -0
  97. package/src/components/Legend/helpers/createFormatLabels.tsx +13 -0
  98. package/src/components/Legend/helpers/generateValueRanges.ts +92 -0
  99. package/src/components/LineChart/helpers/README.md +292 -0
  100. package/src/components/LineChart/helpers/labelPositioning.test.ts +245 -0
  101. package/src/components/LineChart/helpers/labelPositioning.ts +304 -0
  102. package/src/components/LineChart/index.tsx +44 -8
  103. package/src/components/LinearChart/README.md +109 -0
  104. package/src/components/LinearChart/VisualizationRenderer.tsx +267 -0
  105. package/src/components/LinearChart/linearChart.constants.ts +84 -0
  106. package/src/components/LinearChart/tests/LinearChart.test.tsx +201 -0
  107. package/src/components/LinearChart/tests/mockConfigContext.ts +129 -0
  108. package/src/components/LinearChart/utils/tickFormatting.ts +146 -0
  109. package/src/components/LinearChart.tsx +250 -1059
  110. package/src/components/PieChart/PieChart.tsx +1 -1
  111. package/src/components/RadarChart/RadarAxis.tsx +78 -0
  112. package/src/components/RadarChart/RadarChart.tsx +298 -0
  113. package/src/components/RadarChart/RadarGrid.tsx +64 -0
  114. package/src/components/RadarChart/RadarPolygon.tsx +91 -0
  115. package/src/components/RadarChart/helpers.ts +83 -0
  116. package/src/components/RadarChart/index.tsx +3 -0
  117. package/src/components/WarmingStripes/WarmingStripes.tsx +95 -25
  118. package/src/data/initial-state.js +14 -1
  119. package/src/helpers/getExcludedData.ts +4 -0
  120. package/src/helpers/handleChartAriaLabels.ts +19 -19
  121. package/src/helpers/handleLineType.ts +22 -18
  122. package/src/hooks/useProgrammaticTooltip.ts +23 -2
  123. package/src/hooks/useScales.ts +7 -0
  124. package/src/hooks/useTooltip.tsx +3 -0
  125. package/src/scss/main.scss +5 -0
  126. package/src/selectors/README.md +68 -0
  127. package/src/store/chart.reducer.ts +2 -0
  128. package/src/types/ChartConfig.ts +18 -0
  129. package/src/types/ChartContext.ts +1 -0
  130. package/src/types/Horizon.ts +64 -0
  131. package/preview.html +0 -1616
  132. package/src/components/Annotations/components/helpers/index.tsx +0 -46
@@ -3,6 +3,7 @@ import type { Meta, StoryObj } from '@storybook/react-vite'
3
3
  import Chart from '../CdcChartComponent'
4
4
  import barChartStacked from './_mock/barchart_labels.mock.json'
5
5
  import barChartSuppressed from './_mock/bar-chart-suppressed.json'
6
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
6
7
  const meta: Meta<typeof Chart> = {
7
8
  title: 'Components/Templates/Chart/Tooltip',
8
9
  component: Chart
@@ -20,6 +21,9 @@ export const Increased_Tooltip_Range: Story = {
20
21
  singleSeries: true
21
22
  }
22
23
  }
24
+ },
25
+ play: async ({ canvasElement }) => {
26
+ await assertVisualizationRendered(canvasElement)
23
27
  }
24
28
  }
25
29
 
@@ -58,6 +62,9 @@ export const Additional_Tooltip: Story = {
58
62
  }
59
63
  }
60
64
  }
65
+ },
66
+ play: async ({ canvasElement }) => {
67
+ await assertVisualizationRendered(canvasElement)
61
68
  }
62
69
  }
63
70
 
@@ -3,6 +3,7 @@ import annotationConfig from './_mock/annotation_category_mock.json'
3
3
  import annotationConfigDateLinear from './_mock/annotation_date-linear_mock.json'
4
4
  import annotationConfigDateTime from './_mock/annotation_date-time_mock.json'
5
5
  import Chart from '../CdcChartComponent'
6
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
6
7
 
7
8
  const meta: Meta<typeof Chart> = {
8
9
  title: 'Components/Templates/Chart/Annotation',
@@ -15,6 +16,9 @@ export const Chart_Annotation_Categorical: Story = {
15
16
  args: {
16
17
  config: annotationConfig,
17
18
  isEditor: true
19
+ },
20
+ play: async ({ canvasElement }) => {
21
+ await assertVisualizationRendered(canvasElement)
18
22
  }
19
23
  }
20
24
 
@@ -22,6 +26,9 @@ export const Chart_Annotation_Date_Linear: Story = {
22
26
  args: {
23
27
  config: annotationConfigDateLinear,
24
28
  isEditor: true
29
+ },
30
+ play: async ({ canvasElement }) => {
31
+ await assertVisualizationRendered(canvasElement)
25
32
  }
26
33
  }
27
34
 
@@ -29,6 +36,9 @@ export const Chart_Annotation_Date_Time: Story = {
29
36
  args: {
30
37
  config: annotationConfigDateTime,
31
38
  isEditor: true
39
+ },
40
+ play: async ({ canvasElement }) => {
41
+ await assertVisualizationRendered(canvasElement)
32
42
  }
33
43
  }
34
44
 
@@ -3,6 +3,7 @@ import SimplifiedLineConfig from './_mock/simplified_line.json'
3
3
 
4
4
  import Chart from '../CdcChartComponent'
5
5
  import { editConfigKeys } from '@cdc/core/helpers/configHelpers'
6
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
6
7
 
7
8
  const meta: Meta<typeof Chart> = {
8
9
  title: 'Components/Templates/Chart/Axis Labels',
@@ -17,6 +18,9 @@ export const Abbreviated_Dates: Story = {
17
18
  { path: ['xAxis', 'showYearsOnce'], value: true },
18
19
  { path: ['tooltips', 'dateDisplayFormat'], value: '%b. %d %Y' }
19
20
  ])
21
+ },
22
+ play: async ({ canvasElement }) => {
23
+ await assertVisualizationRendered(canvasElement)
20
24
  }
21
25
  }
22
26
 
@@ -4,6 +4,7 @@ import longXLabelsConfig from './_mock/large_x_axis_labels.json'
4
4
  import pairedBarConfig from './_mock/paired-bar.json'
5
5
  import { editConfigKeys } from '@cdc/core/helpers/configHelpers'
6
6
  import { ChartConfig } from '../types/ChartConfig'
7
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
7
8
 
8
9
  const meta: Meta<typeof Chart> = {
9
10
  title: 'Components/Templates/Chart/Axis Titles',
@@ -17,6 +18,9 @@ type Story = StoryObj<typeof Chart>
17
18
  export const Dynamic_Labels: Story = {
18
19
  args: {
19
20
  config: editConfigKeys(longXLabelsConfig, [{ path: ['xAxis', 'label'], value: 'This is the title' }])
21
+ },
22
+ play: async ({ canvasElement }) => {
23
+ await assertVisualizationRendered(canvasElement)
20
24
  }
21
25
  }
22
26
 
@@ -43,11 +47,17 @@ export const Rotated_Labels: StoryObj<{ config: ChartConfig; tickRotation: numbe
43
47
  ])
44
48
 
45
49
  return <Chart config={config} />
50
+ },
51
+ play: async ({ canvasElement }) => {
52
+ await assertVisualizationRendered(canvasElement)
46
53
  }
47
54
  }
48
55
 
49
56
  export const Paired_Bar: Story = {
50
57
  args: {
51
58
  config: pairedBarConfig
59
+ },
60
+ play: async ({ canvasElement }) => {
61
+ await assertVisualizationRendered(canvasElement)
52
62
  }
53
63
  }
@@ -0,0 +1,41 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
+ import Chart from '../CdcChartComponent'
3
+ import { editConfigKeys } from '@cdc/core/helpers/configHelpers'
4
+ import brushContinuousConfig from './_mock/brush_continuous.json'
5
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
6
+
7
+ const meta: Meta<typeof Chart> = {
8
+ title: 'Components/Templates/Chart/BrushSlider/Matrix/Continuous',
9
+ component: Chart
10
+ }
11
+
12
+ export default meta
13
+
14
+ type Story = StoryObj<typeof Chart>
15
+
16
+ export const Default: Story = {
17
+ args: { config: brushContinuousConfig, isEditor: false },
18
+ parameters: {
19
+ docs: {
20
+ description: { story: 'xAxis.type = "continuous", default ascending numeric order.' }
21
+ }
22
+ },
23
+ play: async ({ canvasElement }) => {
24
+ await assertVisualizationRendered(canvasElement)
25
+ }
26
+ }
27
+
28
+ export const Reversed: Story = {
29
+ args: {
30
+ config: editConfigKeys(brushContinuousConfig, [{ path: ['xAxis', 'sortByRecentDate'], value: true }]),
31
+ isEditor: false
32
+ },
33
+ parameters: {
34
+ docs: {
35
+ description: { story: 'xAxis.type = "continuous", sortByRecentDate = true.' }
36
+ }
37
+ },
38
+ play: async ({ canvasElement }) => {
39
+ await assertVisualizationRendered(canvasElement)
40
+ }
41
+ }
@@ -0,0 +1,114 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
+ import Chart from '../CdcChartComponent'
3
+ import { editConfigKeys } from '@cdc/core/helpers/configHelpers'
4
+ import brushDateLargeConfig from './_mock/brush_date_large.json'
5
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
6
+
7
+ // Helper: add a "Category" column to every row (duplicating for two categories) and add a dropdown filter
8
+ function addFilter(config: any) {
9
+ const dataWithCategory = [
10
+ ...config.data.map((row: any) => ({ ...row, Category: 'Group A' })),
11
+ ...config.data.map((row: any) => ({ ...row, Category: 'Group B' }))
12
+ ]
13
+ return editConfigKeys(config, [
14
+ { path: ['data'], value: dataWithCategory },
15
+ {
16
+ path: ['filters'],
17
+ value: [
18
+ {
19
+ values: ['Group A', 'Group B'],
20
+ filterStyle: 'dropdown',
21
+ showDropdown: false,
22
+ active: 'Group A',
23
+ columnName: 'Category',
24
+ orderedValues: ['Group A', 'Group B'],
25
+ defaultValue: 'Group A'
26
+ }
27
+ ]
28
+ }
29
+ ])
30
+ }
31
+
32
+ const reversedDataConfig = editConfigKeys(brushDateLargeConfig, [
33
+ { path: ['data'], value: [...brushDateLargeConfig.data].reverse() }
34
+ ])
35
+
36
+ const meta: Meta<typeof Chart> = {
37
+ title: 'Components/Templates/Chart/BrushSlider/Matrix/Date',
38
+ component: Chart
39
+ }
40
+
41
+ export default meta
42
+
43
+ type Story = StoryObj<typeof Chart>
44
+
45
+ export const Default: Story = {
46
+ args: { config: brushDateLargeConfig, isEditor: false },
47
+ parameters: {
48
+ docs: {
49
+ description: {
50
+ story: 'xAxis.type = "date", default chronological order. ~104 weekly data points.'
51
+ }
52
+ }
53
+ },
54
+ play: async ({ canvasElement }) => {
55
+ await assertVisualizationRendered(canvasElement)
56
+ }
57
+ }
58
+
59
+ export const Reversed: Story = {
60
+ args: {
61
+ config: editConfigKeys(brushDateLargeConfig, [{ path: ['xAxis', 'sortByRecentDate'], value: true }]),
62
+ isEditor: false
63
+ },
64
+ parameters: {
65
+ docs: {
66
+ description: { story: 'xAxis.type = "date", sortByRecentDate = true. Most recent dates appear first.' }
67
+ }
68
+ },
69
+ play: async ({ canvasElement }) => {
70
+ await assertVisualizationRendered(canvasElement)
71
+ }
72
+ }
73
+
74
+ export const ReversedDataOrder: Story = {
75
+ args: { config: reversedDataConfig, isEditor: false },
76
+ parameters: {
77
+ docs: {
78
+ description: {
79
+ story:
80
+ 'Data array in reverse chronological order (newest-first in JSON). Verifies the brush sorts its domain correctly regardless of input order.'
81
+ }
82
+ }
83
+ },
84
+ play: async ({ canvasElement }) => {
85
+ await assertVisualizationRendered(canvasElement)
86
+ }
87
+ }
88
+
89
+ export const WithFilter: Story = {
90
+ args: { config: addFilter(brushDateLargeConfig), isEditor: false },
91
+ parameters: {
92
+ docs: {
93
+ description: { story: 'xAxis.type = "date" with a dropdown filter applied.' }
94
+ }
95
+ },
96
+ play: async ({ canvasElement }) => {
97
+ await assertVisualizationRendered(canvasElement)
98
+ }
99
+ }
100
+
101
+ export const Reversed_WithFilter: Story = {
102
+ args: {
103
+ config: addFilter(editConfigKeys(brushDateLargeConfig, [{ path: ['xAxis', 'sortByRecentDate'], value: true }])),
104
+ isEditor: false
105
+ },
106
+ parameters: {
107
+ docs: {
108
+ description: { story: 'sortByRecentDate = true with a dropdown filter.' }
109
+ }
110
+ },
111
+ play: async ({ canvasElement }) => {
112
+ await assertVisualizationRendered(canvasElement)
113
+ }
114
+ }
@@ -0,0 +1,78 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
+ import Chart from '../CdcChartComponent'
3
+ import { editConfigKeys } from '@cdc/core/helpers/configHelpers'
4
+ import brushEnabledConfig from './_mock/brush_enabled.json'
5
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
6
+
7
+ // Helper: add a "Category" column to every row (duplicating for two categories) and add a dropdown filter
8
+ function addFilter(config: any) {
9
+ const dataWithCategory = [
10
+ ...config.data.map((row: any) => ({ ...row, Category: 'Group A' })),
11
+ ...config.data.map((row: any) => ({ ...row, Category: 'Group B' }))
12
+ ]
13
+ return editConfigKeys(config, [
14
+ { path: ['data'], value: dataWithCategory },
15
+ {
16
+ path: ['filters'],
17
+ value: [
18
+ {
19
+ values: ['Group A', 'Group B'],
20
+ filterStyle: 'dropdown',
21
+ showDropdown: false,
22
+ active: 'Group A',
23
+ columnName: 'Category',
24
+ orderedValues: ['Group A', 'Group B'],
25
+ defaultValue: 'Group A'
26
+ }
27
+ ]
28
+ }
29
+ ])
30
+ }
31
+
32
+ const meta: Meta<typeof Chart> = {
33
+ title: 'Components/Templates/Chart/BrushSlider/Matrix/DateTime',
34
+ component: Chart
35
+ }
36
+
37
+ export default meta
38
+
39
+ type Story = StoryObj<typeof Chart>
40
+
41
+ export const Default: Story = {
42
+ args: { config: brushEnabledConfig, isEditor: false },
43
+ parameters: {
44
+ docs: {
45
+ description: { story: 'xAxis.type = "date-time", default chronological order.' }
46
+ }
47
+ },
48
+ play: async ({ canvasElement }) => {
49
+ await assertVisualizationRendered(canvasElement)
50
+ }
51
+ }
52
+
53
+ export const Reversed: Story = {
54
+ args: {
55
+ config: editConfigKeys(brushEnabledConfig, [{ path: ['xAxis', 'sortByRecentDate'], value: true }]),
56
+ isEditor: false
57
+ },
58
+ parameters: {
59
+ docs: {
60
+ description: { story: 'xAxis.type = "date-time", sortByRecentDate = true.' }
61
+ }
62
+ },
63
+ play: async ({ canvasElement }) => {
64
+ await assertVisualizationRendered(canvasElement)
65
+ }
66
+ }
67
+
68
+ export const WithFilter: Story = {
69
+ args: { config: addFilter(brushEnabledConfig), isEditor: false },
70
+ parameters: {
71
+ docs: {
72
+ description: { story: 'xAxis.type = "date-time" with a dropdown filter applied.' }
73
+ }
74
+ },
75
+ play: async ({ canvasElement }) => {
76
+ await assertVisualizationRendered(canvasElement)
77
+ }
78
+ }
@@ -1,6 +1,7 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite'
2
2
  import Chart from '../CdcChartComponent'
3
3
  import brushEnabledConfig from './_mock/brush_enabled.json'
4
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
4
5
 
5
6
  const meta: Meta<typeof Chart> = {
6
7
  title: 'Components/Templates/Chart/BrushSlider',
@@ -29,6 +30,9 @@ export const BrushSliderEnabled: Story = {
29
30
  'Line chart with brush slider enabled. Drag the handles on the slider below the chart to filter the data range.'
30
31
  }
31
32
  }
33
+ },
34
+ play: async ({ canvasElement }) => {
35
+ await assertVisualizationRendered(canvasElement)
32
36
  }
33
37
  }
34
38
 
@@ -44,6 +48,9 @@ export const BrushSliderInEditor: Story = {
44
48
  'Brush slider in editor mode. You can toggle the "Brush Slider" checkbox in the X-Axis section to enable/disable it.'
45
49
  }
46
50
  }
51
+ },
52
+ play: async ({ canvasElement }) => {
53
+ await assertVisualizationRendered(canvasElement)
47
54
  }
48
55
  }
49
56
 
@@ -4,6 +4,7 @@ import Chart from '../CdcChartComponent'
4
4
  import pieChartExample from './_mock/pie_config.json'
5
5
  import urlFilterExample from './_mock/url_filter.json'
6
6
  import mockScatterPlot from './_mock/scatterplot_mock.json'
7
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
7
8
 
8
9
  const meta: Meta<typeof Chart> = {
9
10
  title: 'Components/Templates/Chart/Editor',
@@ -16,6 +17,9 @@ export const Primary: Story = {
16
17
  args: {
17
18
  config: { ...pieChartExample },
18
19
  isEditor: true
20
+ },
21
+ play: async ({ canvasElement }) => {
22
+ await assertVisualizationRendered(canvasElement)
19
23
  }
20
24
  }
21
25
 
@@ -27,6 +31,9 @@ export const Url_Filter: Story = {
27
31
  args: {
28
32
  config: urlFilterExample,
29
33
  isEditor: true
34
+ },
35
+ play: async ({ canvasElement }) => {
36
+ await assertVisualizationRendered(canvasElement)
30
37
  }
31
38
  }
32
39
 
@@ -0,0 +1,89 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
+ import Chart from '../CdcChartComponent'
3
+ import configAll from './_mock/line_chart_quadrant_angles.json'
4
+ import configQ1 from './_mock/line_chart_angle_q1_steep_upward.json'
5
+ import configQ2 from './_mock/line_chart_angle_q2_gentle_downward.json'
6
+ import configQ3 from './_mock/line_chart_angle_q3_steep_downward.json'
7
+ import configQ4 from './_mock/line_chart_angle_q4_gentle_upward.json'
8
+ import configNearZeroRise from './_mock/line_chart_angle_near_zero_rise.json'
9
+ import configNearZeroFall from './_mock/line_chart_angle_near_zero_fall.json'
10
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
11
+
12
+ const meta: Meta<typeof Chart> = {
13
+ title: 'Components/Templates/Chart/QuadrantAngles',
14
+ component: Chart
15
+ }
16
+
17
+ type Story = StoryObj<typeof Chart>
18
+
19
+ export const AllQuadrants: Story = {
20
+ args: {
21
+ config: configAll,
22
+ isEditor: false
23
+ },
24
+ play: async ({ canvasElement }) => {
25
+ await assertVisualizationRendered(canvasElement)
26
+ }
27
+ }
28
+
29
+ export const Q1SteepUpward: Story = {
30
+ args: {
31
+ config: configQ1,
32
+ isEditor: false
33
+ },
34
+ play: async ({ canvasElement }) => {
35
+ await assertVisualizationRendered(canvasElement)
36
+ }
37
+ }
38
+
39
+ export const Q2GentleDownward: Story = {
40
+ args: {
41
+ config: configQ2,
42
+ isEditor: false
43
+ },
44
+ play: async ({ canvasElement }) => {
45
+ await assertVisualizationRendered(canvasElement)
46
+ }
47
+ }
48
+
49
+ export const Q3SteepDownward: Story = {
50
+ args: {
51
+ config: configQ3,
52
+ isEditor: false
53
+ },
54
+ play: async ({ canvasElement }) => {
55
+ await assertVisualizationRendered(canvasElement)
56
+ }
57
+ }
58
+
59
+ export const Q4GentleUpward: Story = {
60
+ args: {
61
+ config: configQ4,
62
+ isEditor: false
63
+ },
64
+ play: async ({ canvasElement }) => {
65
+ await assertVisualizationRendered(canvasElement)
66
+ }
67
+ }
68
+
69
+ export const NearZeroRise: Story = {
70
+ args: {
71
+ config: configNearZeroRise,
72
+ isEditor: false
73
+ },
74
+ play: async ({ canvasElement }) => {
75
+ await assertVisualizationRendered(canvasElement)
76
+ }
77
+ }
78
+
79
+ export const NearZeroFall: Story = {
80
+ args: {
81
+ config: configNearZeroFall,
82
+ isEditor: false
83
+ },
84
+ play: async ({ canvasElement }) => {
85
+ await assertVisualizationRendered(canvasElement)
86
+ }
87
+ }
88
+
89
+ export default meta
@@ -2,6 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react-vite'
2
2
  import Chart from '../CdcChartComponent'
3
3
  import suppressionConfig from './_mock/suppression_mock.json'
4
4
  import SuppressedConfig from './_mock/bar-chart-suppressed.json'
5
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
5
6
  const meta: Meta<typeof Chart> = {
6
7
  title: 'Components/Templates/Chart/Suppression',
7
8
  component: Chart
@@ -13,12 +14,18 @@ export const SuppressedLines: Story = {
13
14
  args: {
14
15
  config: suppressionConfig,
15
16
  isEditor: false
17
+ },
18
+ play: async ({ canvasElement }) => {
19
+ await assertVisualizationRendered(canvasElement)
16
20
  }
17
21
  }
18
22
  export const SuppressedBars: Story = {
19
23
  args: {
20
24
  config: SuppressedConfig,
21
25
  isEditor: false
26
+ },
27
+ play: async ({ canvasElement }) => {
28
+ await assertVisualizationRendered(canvasElement)
22
29
  }
23
30
  }
24
31
 
@@ -1,6 +1,7 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite'
2
2
  import Chart from '../CdcChartComponent'
3
3
  import config from './_mock/line_chart_symbols.json'
4
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
4
5
  const meta: Meta<typeof Chart> = {
5
6
  title: 'Components/Templates/Chart/Symbols',
6
7
  component: Chart
@@ -12,6 +13,9 @@ export const LineChartSymbols: Story = {
12
13
  args: {
13
14
  config: config,
14
15
  isEditor: false
16
+ },
17
+ play: async ({ canvasElement }) => {
18
+ await assertVisualizationRendered(canvasElement)
15
19
  }
16
20
  }
17
21
 
@@ -7,6 +7,7 @@ import scatterPlotConfig from './_mock/scatterplot_mock.json'
7
7
 
8
8
  import Chart from '../CdcChartComponent'
9
9
  import { editConfigKeys } from '@cdc/core/helpers/configHelpers'
10
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
10
11
 
11
12
  const meta: Meta<typeof Chart> = {
12
13
  title: 'Components/Templates/Chart/Prefix Suffix',
@@ -21,6 +22,9 @@ export const Inline_Label: Story = {
21
22
  { path: ['yAxis', 'inlineLabel'], value: ' Somethings per Something' },
22
23
  { path: ['yAxis', 'gridLines'], value: true }
23
24
  ])
25
+ },
26
+ play: async ({ canvasElement }) => {
27
+ await assertVisualizationRendered(canvasElement)
24
28
  }
25
29
  }
26
30
  export const Inline_Label_With_Suffix: Story = {
@@ -30,12 +34,18 @@ export const Inline_Label_With_Suffix: Story = {
30
34
  { path: ['dataFormat', 'suffix'], value: '%' },
31
35
  { path: ['yAxis', 'gridLines'], value: true }
32
36
  ])
37
+ },
38
+ play: async ({ canvasElement }) => {
39
+ await assertVisualizationRendered(canvasElement)
33
40
  }
34
41
  }
35
42
 
36
43
  export const Inline_Label_Worst_Case: Story = {
37
44
  args: {
38
45
  config: editConfigKeys(annotationConfig, [{ path: ['yAxis', 'inlineLabel'], value: ' Somethings per Something' }])
46
+ },
47
+ play: async ({ canvasElement }) => {
48
+ await assertVisualizationRendered(canvasElement)
39
49
  }
40
50
  }
41
51
 
@@ -47,6 +57,9 @@ export const Inline_Label_With_Options: Story = {
47
57
  { path: ['yAxis', 'tickRotation'], value: 45 },
48
58
  { path: ['yAxis', 'tickLabelColor'], value: 'red' }
49
59
  ])
60
+ },
61
+ play: async ({ canvasElement }) => {
62
+ await assertVisualizationRendered(canvasElement)
50
63
  }
51
64
  }
52
65
 
@@ -56,6 +69,9 @@ export const Inline_Label_No_Space: Story = {
56
69
  { path: ['yAxis', 'inlineLabel'], value: 'lbs' },
57
70
  { path: ['dataFormat', 'suffix'], value: '' }
58
71
  ])
72
+ },
73
+ play: async ({ canvasElement }) => {
74
+ await assertVisualizationRendered(canvasElement)
59
75
  }
60
76
  }
61
77
 
@@ -65,12 +81,18 @@ export const Inline_Label_With_Space: Story = {
65
81
  { path: ['yAxis', 'inlineLabel'], value: 'lbs of something' },
66
82
  { path: ['dataFormat', 'suffix'], value: '' }
67
83
  ])
84
+ },
85
+ play: async ({ canvasElement }) => {
86
+ await assertVisualizationRendered(canvasElement)
68
87
  }
69
88
  }
70
89
 
71
90
  export const Suffix: Story = {
72
91
  args: {
73
92
  config: annotationConfig
93
+ },
94
+ play: async ({ canvasElement }) => {
95
+ await assertVisualizationRendered(canvasElement)
74
96
  }
75
97
  }
76
98
 
@@ -80,6 +102,9 @@ export const Prefix: Story = {
80
102
  { path: ['dataFormat', 'prefix'], value: '$' },
81
103
  { path: ['dataFormat', 'suffix'], value: '' }
82
104
  ])
105
+ },
106
+ play: async ({ canvasElement }) => {
107
+ await assertVisualizationRendered(canvasElement)
83
108
  }
84
109
  }
85
110
 
@@ -89,6 +114,9 @@ export const Prefix_Suffix_And_Inline_Title: Story = {
89
114
  { path: ['yAxis', 'inlineLabel'], value: 'lbs of something' },
90
115
  { path: ['dataFormat', 'prefix'], value: '$' }
91
116
  ])
117
+ },
118
+ play: async ({ canvasElement }) => {
119
+ await assertVisualizationRendered(canvasElement)
92
120
  }
93
121
  }
94
122
  export const Horizontal_Bar: Story = {
@@ -97,6 +125,9 @@ export const Horizontal_Bar: Story = {
97
125
  { path: ['dataFormat', 'suffix'], value: ' suf' },
98
126
  { path: ['dataFormat', 'prefix'], value: 'pre' }
99
127
  ])
128
+ },
129
+ play: async ({ canvasElement }) => {
130
+ await assertVisualizationRendered(canvasElement)
100
131
  }
101
132
  }
102
133
 
@@ -109,6 +140,9 @@ export const Inline_Title_On_Line: Story = {
109
140
  { path: ['yAxis', 'labelsAboveGridlines'], value: true },
110
141
  { path: ['yAxis', 'hideAxis'], value: true }
111
142
  ])
143
+ },
144
+ play: async ({ canvasElement }) => {
145
+ await assertVisualizationRendered(canvasElement)
112
146
  }
113
147
  }
114
148
 
@@ -120,6 +154,9 @@ export const Values_On_Line_All_Suffix: Story = {
120
154
  { path: ['yAxis', 'gridLines'], value: true },
121
155
  { path: ['yAxis', 'hideAxis'], value: true }
122
156
  ])
157
+ },
158
+ play: async ({ canvasElement }) => {
159
+ await assertVisualizationRendered(canvasElement)
123
160
  }
124
161
  }
125
162
 
@@ -131,6 +168,9 @@ export const Values_on_Line_Top_Suffix_Only_Area_Worst_Case: Story = {
131
168
  { path: ['yAxis', 'labelsAboveGridlines'], value: true },
132
169
  { path: ['yAxis', 'gridLines'], value: true }
133
170
  ])
171
+ },
172
+ play: async ({ canvasElement }) => {
173
+ await assertVisualizationRendered(canvasElement)
134
174
  }
135
175
  }
136
176
 
@@ -143,6 +183,9 @@ export const Top_Suffix_Above_Gridlines_With_Options: Story = {
143
183
  { path: ['yAxis', 'gridLines'], value: true },
144
184
  { path: ['yAxis', 'hideAxis'], value: true }
145
185
  ])
186
+ },
187
+ play: async ({ canvasElement }) => {
188
+ await assertVisualizationRendered(canvasElement)
146
189
  }
147
190
  }
148
191
 
@@ -150,7 +193,9 @@ export const ScatterPlot_Bottom_Commas: Story = {
150
193
  args: {
151
194
  config: editConfigKeys(scatterPlotConfig, [{ path: ['dataFormat', 'bottomCommas'], value: true }])
152
195
  },
153
- isEditor: true
196
+ play: async ({ canvasElement }) => {
197
+ await assertVisualizationRendered(canvasElement)
198
+ }
154
199
  }
155
200
 
156
201
  export default meta