@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
@@ -1,5 +1,6 @@
1
1
  import { Meta, StoryObj } from '@storybook/react-vite'
2
2
  import CdcChart from '../CdcChartComponent'
3
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
3
4
 
4
5
  const meta: Meta<typeof CdcChart> = {
5
6
  title: 'Components/Templates/Chart/HTML in Data Table',
@@ -148,6 +149,9 @@ export const BasicHTMLInFootnoteColumn: Story = {
148
149
  }
149
150
  },
150
151
  isEditor: true
152
+ },
153
+ play: async ({ canvasElement }) => {
154
+ await assertVisualizationRendered(canvasElement)
151
155
  }
152
156
  }
153
157
 
@@ -208,6 +212,9 @@ export const HTMLWithLinksAndFormatting: Story = {
208
212
  }
209
213
  },
210
214
  isEditor: true
215
+ },
216
+ play: async ({ canvasElement }) => {
217
+ await assertVisualizationRendered(canvasElement)
211
218
  }
212
219
  }
213
220
 
@@ -265,6 +272,9 @@ export const HTMLWithLineBreaks: Story = {
265
272
  }
266
273
  },
267
274
  isEditor: true
275
+ },
276
+ play: async ({ canvasElement }) => {
277
+ await assertVisualizationRendered(canvasElement)
268
278
  }
269
279
  }
270
280
 
@@ -315,6 +325,9 @@ export const ComplexHTMLWithLists: Story = {
315
325
  }
316
326
  },
317
327
  isEditor: true
328
+ },
329
+ play: async ({ canvasElement }) => {
330
+ await assertVisualizationRendered(canvasElement)
318
331
  }
319
332
  }
320
333
 
@@ -368,6 +381,9 @@ export const HTMLWithInlineStyles: Story = {
368
381
  }
369
382
  },
370
383
  isEditor: true
384
+ },
385
+ play: async ({ canvasElement }) => {
386
+ await assertVisualizationRendered(canvasElement)
371
387
  }
372
388
  }
373
389
 
@@ -444,6 +460,9 @@ export const LineChartWithHTMLFootnotes: Story = {
444
460
  }
445
461
  },
446
462
  isEditor: true
463
+ },
464
+ play: async ({ canvasElement }) => {
465
+ await assertVisualizationRendered(canvasElement)
447
466
  }
448
467
  }
449
468
 
@@ -516,5 +535,8 @@ export const PieChartWithHTMLFootnotes: Story = {
516
535
  }
517
536
  },
518
537
  isEditor: true
538
+ },
539
+ play: async ({ canvasElement }) => {
540
+ await assertVisualizationRendered(canvasElement)
519
541
  }
520
542
  }
@@ -5,6 +5,7 @@ import SimplifiedLineConfig from './_mock/simplified_line.json'
5
5
 
6
6
  import Chart from '../CdcChartComponent'
7
7
  import { editConfigKeys } from '@cdc/core/helpers/configHelpers'
8
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
8
9
 
9
10
  const meta: Meta<typeof Chart> = {
10
11
  title: 'Components/Templates/Chart/Legend',
@@ -16,41 +17,62 @@ type Story = StoryObj<typeof Chart>
16
17
  export const Legend_Gradient_Smooth: Story = {
17
18
  args: {
18
19
  config: chartGradientConfig
20
+ },
21
+ play: async ({ canvasElement }) => {
22
+ await assertVisualizationRendered(canvasElement)
19
23
  }
20
24
  }
21
25
  export const Legend_Group_By: Story = {
22
26
  args: {
23
27
  config: chartGroupedLagend
28
+ },
29
+ play: async ({ canvasElement }) => {
30
+ await assertVisualizationRendered(canvasElement)
24
31
  }
25
32
  }
26
33
 
27
34
  export const Legend_Gradient_Linear_Blocks: Story = {
28
35
  args: {
29
36
  config: editConfigKeys(chartGradientConfig, [{ path: ['legend', 'subStyle'], value: 'linear blocks' }])
37
+ },
38
+ play: async ({ canvasElement }) => {
39
+ await assertVisualizationRendered(canvasElement)
30
40
  }
31
41
  }
32
42
 
33
43
  export const Labels_On_Line_Legend_On_Top: Story = {
34
44
  args: {
35
45
  config: editConfigKeys(chartGradientConfig, [{ path: ['yAxis', 'labelsAboveGridlines'], value: true }])
46
+ },
47
+ play: async ({ canvasElement }) => {
48
+ await assertVisualizationRendered(canvasElement)
36
49
  }
37
50
  }
38
51
 
39
52
  export const Legend_On_Right: Story = {
40
53
  args: {
41
54
  config: SimplifiedLineConfig
55
+ },
56
+ play: async ({ canvasElement }) => {
57
+ await assertVisualizationRendered(canvasElement)
42
58
  }
43
59
  }
44
60
 
45
61
  export const Legend_On_Right_With_Box: Story = {
46
62
  args: {
47
63
  config: editConfigKeys(SimplifiedLineConfig, [{ path: ['legend', 'hideBorder'], value: false }])
64
+ },
65
+ play: async ({ canvasElement }) => {
66
+ await assertVisualizationRendered(canvasElement)
48
67
  }
49
68
  }
50
69
 
51
70
  export const Legend_Gradient_With_box: Story = {
52
71
  args: {
53
72
  config: editConfigKeys(chartGradientConfig, [{ path: ['legend', 'hideBorder'], value: false }])
73
+ },
74
+ play: async ({ canvasElement }) => {
75
+ await assertVisualizationRendered(canvasElement)
54
76
  }
55
77
  }
56
78
 
@@ -61,6 +83,9 @@ export const Legend_Gradient_With_Text: Story = {
61
83
  { path: ['legend', 'description'], value: 'Description' },
62
84
  { path: ['legend', 'hideBorder'], value: false }
63
85
  ])
86
+ },
87
+ play: async ({ canvasElement }) => {
88
+ await assertVisualizationRendered(canvasElement)
64
89
  }
65
90
  }
66
91
  export const Legend_Gradient_Wrapping_Label: Story = {
@@ -74,6 +99,9 @@ export const Legend_Gradient_Wrapping_Label: Story = {
74
99
  ])
75
100
  ).replace(/Data 1/g, 'This is a long string that should wrap')
76
101
  )
102
+ },
103
+ play: async ({ canvasElement }) => {
104
+ await assertVisualizationRendered(canvasElement)
77
105
  }
78
106
  }
79
107
 
@@ -2,6 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react'
2
2
  import StackedPattern from './_mock/stacked-pattern-test.json'
3
3
 
4
4
  import Chart from '../CdcChartComponent'
5
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
5
6
 
6
7
  const meta: Meta<typeof Chart> = {
7
8
  title: 'Components/Templates/Chart/Patterns',
@@ -14,6 +15,9 @@ export const Stacked_Bar_Pattern: Story = {
14
15
  args: {
15
16
  config: StackedPattern,
16
17
  isEditor: true
18
+ },
19
+ play: async ({ canvasElement }) => {
20
+ await assertVisualizationRendered(canvasElement)
17
21
  }
18
22
  }
19
23
 
@@ -1,5 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite'
2
2
  import Chart from '../CdcChartComponent'
3
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
3
4
 
4
5
  const meta: Meta<typeof Chart> = {
5
6
  title: 'Components/Templates/Chart/Preserve Original Decimals',
@@ -56,6 +57,9 @@ export const Default_With_Forced_Rounding: Story = {
56
57
  'Default behavior forces all numbers to 1 decimal place. Notice how whole numbers like 1000 become "1,000.0" and 89.23 gets rounded to "89.2".'
57
58
  }
58
59
  }
60
+ },
61
+ play: async ({ canvasElement }) => {
62
+ await assertVisualizationRendered(canvasElement)
59
63
  }
60
64
  }
61
65
 
@@ -77,6 +81,9 @@ export const Preserve_Original_Decimals_Enabled: Story = {
77
81
  'With "Preserve Original Decimals" enabled, numbers display exactly as they appear in the data: 1000 shows as "1,000", 45.7 shows as "45.7", and 89.23 shows as "89.23". The roundTo setting is ignored.'
78
82
  }
79
83
  }
84
+ },
85
+ play: async ({ canvasElement }) => {
86
+ await assertVisualizationRendered(canvasElement)
80
87
  }
81
88
  }
82
89
 
@@ -97,6 +104,9 @@ export const Comparison_No_Decimals: Story = {
97
104
  'Forcing 0 decimal places rounds everything to whole numbers: 45.7 becomes "46", 89.23 becomes "89". This loses precision from the original data.'
98
105
  }
99
106
  }
107
+ },
108
+ play: async ({ canvasElement }) => {
109
+ await assertVisualizationRendered(canvasElement)
100
110
  }
101
111
  }
102
112
 
@@ -117,6 +127,9 @@ export const Comparison_Two_Decimals: Story = {
117
127
  'Forcing 2 decimal places adds unnecessary zeros: 1000 becomes "1,000.00", 45.7 becomes "45.70". This can look cluttered for whole numbers.'
118
128
  }
119
129
  }
130
+ },
131
+ play: async ({ canvasElement }) => {
132
+ await assertVisualizationRendered(canvasElement)
120
133
  }
121
134
  }
122
135
 
@@ -139,6 +152,9 @@ export const With_Prefix_And_Suffix: Story = {
139
152
  'Preserve Original Decimals works seamlessly with prefix and suffix formatting. Numbers show as "$1,000 USD", "$45.7 USD", etc.'
140
153
  }
141
154
  }
155
+ },
156
+ play: async ({ canvasElement }) => {
157
+ await assertVisualizationRendered(canvasElement)
142
158
  }
143
159
  }
144
160
 
@@ -167,6 +183,9 @@ export const Percentage_Data_Mixed_Precision: Story = {
167
183
  'Perfect for percentage data where some values are whole (25%, 50%) and others need decimals (33.3%, 12.75%). Each value displays naturally without forced rounding.'
168
184
  }
169
185
  }
186
+ },
187
+ play: async ({ canvasElement }) => {
188
+ await assertVisualizationRendered(canvasElement)
170
189
  }
171
190
  }
172
191
 
@@ -193,6 +212,9 @@ export const Line_Chart_With_Table: Story = {
193
212
  'When enabled, the preserve decimals setting applies to both the chart axis/tooltips AND the data table, ensuring consistency across all displays.'
194
213
  }
195
214
  }
215
+ },
216
+ play: async ({ canvasElement }) => {
217
+ await assertVisualizationRendered(canvasElement)
196
218
  }
197
219
  }
198
220
 
@@ -214,6 +236,9 @@ export const Editor_Mode: Story = {
214
236
  'In editor mode, look for the "Preserve Original Decimal Places" checkbox in the Number Formatting section, right below the "Round to decimal point" field. Toggle it to see the effect in real-time.'
215
237
  }
216
238
  }
239
+ },
240
+ play: async ({ canvasElement }) => {
241
+ await assertVisualizationRendered(canvasElement)
217
242
  }
218
243
  }
219
244
 
@@ -1,5 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite'
2
2
  import Chart from '../CdcChart'
3
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
3
4
 
4
5
  const meta: Meta<typeof Chart> = {
5
6
  title: 'Components/Templates/Chart/Regions/Categorical',
@@ -70,6 +71,9 @@ export const Line_Fixed_From_Fixed_To: Story = {
70
71
  ]
71
72
  },
72
73
  isEditor: true
74
+ },
75
+ play: async ({ canvasElement }) => {
76
+ await assertVisualizationRendered(canvasElement)
73
77
  }
74
78
  }
75
79
 
@@ -92,6 +96,9 @@ export const Line_Fixed_From_Last_Date: Story = {
92
96
  ]
93
97
  },
94
98
  isEditor: true
99
+ },
100
+ play: async ({ canvasElement }) => {
101
+ await assertVisualizationRendered(canvasElement)
95
102
  }
96
103
  }
97
104
 
@@ -118,6 +125,9 @@ export const Bar_Fixed_From_Fixed_To: Story = {
118
125
  ]
119
126
  },
120
127
  isEditor: true
128
+ },
129
+ play: async ({ canvasElement }) => {
130
+ await assertVisualizationRendered(canvasElement)
121
131
  }
122
132
  }
123
133
 
@@ -142,6 +152,9 @@ export const Bar_Fixed_From_Last_Date: Story = {
142
152
  ]
143
153
  },
144
154
  isEditor: true
155
+ },
156
+ play: async ({ canvasElement }) => {
157
+ await assertVisualizationRendered(canvasElement)
145
158
  }
146
159
  }
147
160
 
@@ -1,5 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite'
2
2
  import Chart from '../CdcChart'
3
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
3
4
 
4
5
  const meta: Meta<typeof Chart> = {
5
6
  title: 'Components/Templates/Chart/Regions/Date Scale (Band)',
@@ -73,6 +74,9 @@ export const Line_Fixed_From_Fixed_To: Story = {
73
74
  ]
74
75
  },
75
76
  isEditor: true
77
+ },
78
+ play: async ({ canvasElement }) => {
79
+ await assertVisualizationRendered(canvasElement)
76
80
  }
77
81
  }
78
82
 
@@ -95,6 +99,9 @@ export const Line_Fixed_From_Last_Date: Story = {
95
99
  ]
96
100
  },
97
101
  isEditor: true
102
+ },
103
+ play: async ({ canvasElement }) => {
104
+ await assertVisualizationRendered(canvasElement)
98
105
  }
99
106
  }
100
107
 
@@ -117,6 +124,9 @@ export const Line_Previous_Days_Last_Date: Story = {
117
124
  ]
118
125
  },
119
126
  isEditor: true
127
+ },
128
+ play: async ({ canvasElement }) => {
129
+ await assertVisualizationRendered(canvasElement)
120
130
  }
121
131
  }
122
132
 
@@ -143,6 +153,9 @@ export const Bar_Fixed_From_Fixed_To: Story = {
143
153
  ]
144
154
  },
145
155
  isEditor: true
156
+ },
157
+ play: async ({ canvasElement }) => {
158
+ await assertVisualizationRendered(canvasElement)
146
159
  }
147
160
  }
148
161
 
@@ -167,6 +180,9 @@ export const Bar_Fixed_From_Last_Date: Story = {
167
180
  ]
168
181
  },
169
182
  isEditor: true
183
+ },
184
+ play: async ({ canvasElement }) => {
185
+ await assertVisualizationRendered(canvasElement)
170
186
  }
171
187
  }
172
188
 
@@ -191,6 +207,9 @@ export const Bar_Previous_Days_Last_Date: Story = {
191
207
  ]
192
208
  },
193
209
  isEditor: true
210
+ },
211
+ play: async ({ canvasElement }) => {
212
+ await assertVisualizationRendered(canvasElement)
194
213
  }
195
214
  }
196
215
 
@@ -1,5 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite'
2
2
  import Chart from '../CdcChart'
3
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
3
4
 
4
5
  const meta: Meta<typeof Chart> = {
5
6
  title: 'Components/Templates/Chart/Regions/Date-Time Scale (Continuous)',
@@ -52,6 +53,10 @@ const baseDateTimeConfig = {
52
53
  regions: []
53
54
  }
54
55
 
56
+ const play = async ({ canvasElement }) => {
57
+ await assertVisualizationRendered(canvasElement)
58
+ }
59
+
55
60
  // LINE CHARTS
56
61
 
57
62
  export const Line_Fixed_From_Fixed_To: Story = {
@@ -73,7 +78,8 @@ export const Line_Fixed_From_Fixed_To: Story = {
73
78
  ]
74
79
  },
75
80
  isEditor: true
76
- }
81
+ },
82
+ play
77
83
  }
78
84
 
79
85
  export const Line_Fixed_From_Last_Date: Story = {
@@ -95,7 +101,8 @@ export const Line_Fixed_From_Last_Date: Story = {
95
101
  ]
96
102
  },
97
103
  isEditor: true
98
- }
104
+ },
105
+ play
99
106
  }
100
107
 
101
108
  export const Line_Previous_Days_Last_Date: Story = {
@@ -117,7 +124,8 @@ export const Line_Previous_Days_Last_Date: Story = {
117
124
  ]
118
125
  },
119
126
  isEditor: true
120
- }
127
+ },
128
+ play
121
129
  }
122
130
 
123
131
  // BAR CHARTS
@@ -143,7 +151,8 @@ export const Bar_Fixed_From_Fixed_To: Story = {
143
151
  ]
144
152
  },
145
153
  isEditor: true
146
- }
154
+ },
155
+ play
147
156
  }
148
157
 
149
158
  export const Bar_Fixed_From_Last_Date: Story = {
@@ -167,7 +176,8 @@ export const Bar_Fixed_From_Last_Date: Story = {
167
176
  ]
168
177
  },
169
178
  isEditor: true
170
- }
179
+ },
180
+ play
171
181
  }
172
182
 
173
183
  export const Bar_Previous_Days_Last_Date: Story = {
@@ -191,7 +201,8 @@ export const Bar_Previous_Days_Last_Date: Story = {
191
201
  ]
192
202
  },
193
203
  isEditor: true
194
- }
204
+ },
205
+ play
195
206
  }
196
207
 
197
208
  // EDGE CASES
@@ -215,7 +226,8 @@ export const Edge_Region_At_Start: Story = {
215
226
  ]
216
227
  },
217
228
  isEditor: true
218
- }
229
+ },
230
+ play
219
231
  }
220
232
 
221
233
  export const Edge_Region_At_End: Story = {
@@ -237,7 +249,8 @@ export const Edge_Region_At_End: Story = {
237
249
  ]
238
250
  },
239
251
  isEditor: true
240
- }
252
+ },
253
+ play
241
254
  }
242
255
 
243
256
  export const Edge_Full_Coverage: Story = {
@@ -259,7 +272,8 @@ export const Edge_Full_Coverage: Story = {
259
272
  ]
260
273
  },
261
274
  isEditor: true
262
- }
275
+ },
276
+ play
263
277
  }
264
278
 
265
279
  export const Multiple_Regions: Story = {
@@ -291,7 +305,8 @@ export const Multiple_Regions: Story = {
291
305
  ]
292
306
  },
293
307
  isEditor: true
294
- }
308
+ },
309
+ play
295
310
  }
296
311
 
297
312
  export default meta
@@ -1,6 +1,7 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite'
2
2
  import Chart from '../CdcChartComponent'
3
3
  import scatterPlotDownloadImage from './_mock/scatterplot-image-download.json'
4
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
4
5
 
5
6
  const meta: Meta<typeof Chart> = {
6
7
  title: 'Components/Templates/Chart/Scatter Plot Download Image',
@@ -13,6 +14,9 @@ export const ScatterPlot_Download_Image: Story = {
13
14
  args: {
14
15
  config: scatterPlotDownloadImage,
15
16
  isEditor: false
17
+ },
18
+ play: async ({ canvasElement }) => {
19
+ await assertVisualizationRendered(canvasElement)
16
20
  }
17
21
  }
18
22
 
@@ -5,6 +5,7 @@ import smallMultiplesBigDataBars from './_mock/small_multiples/small_multiples_b
5
5
  import smallMultiplesLinesColors from './_mock/small_multiples/small_multiples_lines_colors.json'
6
6
  import smallMultiplesLines from './_mock/small_multiples/small_multiples_lines.json'
7
7
  import smallMultiplesStackedBars from './_mock/small_multiples/small_multiples_stacked_bars.json'
8
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
8
9
 
9
10
  const meta: Meta<typeof Chart> = {
10
11
  title: 'Components/Templates/Chart/Small Multiples',
@@ -17,6 +18,9 @@ export const smallMultiples_Bars: Story = {
17
18
  args: {
18
19
  config: smallMultiplesBars,
19
20
  isEditor: false
21
+ },
22
+ play: async ({ canvasElement }) => {
23
+ await assertVisualizationRendered(canvasElement)
20
24
  }
21
25
  }
22
26
 
@@ -24,24 +28,36 @@ export const smallMultiples_BigDataBars: Story = {
24
28
  args: {
25
29
  config: smallMultiplesBigDataBars,
26
30
  isEditor: false
31
+ },
32
+ play: async ({ canvasElement }) => {
33
+ await assertVisualizationRendered(canvasElement)
27
34
  }
28
35
  }
29
36
  export const smallMultiples_LinesColors: Story = {
30
37
  args: {
31
38
  config: smallMultiplesLinesColors,
32
39
  isEditor: false
40
+ },
41
+ play: async ({ canvasElement }) => {
42
+ await assertVisualizationRendered(canvasElement)
33
43
  }
34
44
  }
35
45
  export const smallMultiples_Lines: Story = {
36
46
  args: {
37
47
  config: smallMultiplesLines,
38
48
  isEditor: false
49
+ },
50
+ play: async ({ canvasElement }) => {
51
+ await assertVisualizationRendered(canvasElement)
39
52
  }
40
53
  }
41
54
  export const smallMultiples_StackedBars: Story = {
42
55
  args: {
43
56
  config: smallMultiplesStackedBars,
44
57
  isEditor: false
58
+ },
59
+ play: async ({ canvasElement }) => {
60
+ await assertVisualizationRendered(canvasElement)
45
61
  }
46
62
  }
47
63
  export default meta
@@ -14,6 +14,7 @@ import pieCalculatedArea from './_mock/pie_calculated_area.json'
14
14
  import areaChartStacked from './_mock/area_chart_stacked.json'
15
15
  import multipleLines from './_mock/short_dates.json'
16
16
  import { editConfigKeys } from '@cdc/core/helpers/configHelpers'
17
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
17
18
 
18
19
  const meta: Meta<typeof Chart> = {
19
20
  title: 'Components/Templates/Chart',
@@ -26,18 +27,27 @@ export const line_Chart_Two_Points_Regression_Test: Story = {
26
27
  args: {
27
28
  config: lineChartTwoPointsRegressionTest,
28
29
  isEditor: false
30
+ },
31
+ play: async ({ canvasElement }) => {
32
+ await assertVisualizationRendered(canvasElement)
29
33
  }
30
34
  }
31
35
  export const line_Chart_Two_Points_New_Chart: Story = {
32
36
  args: {
33
37
  config: lineChartTwoPointsNewChart,
34
38
  isEditor: false
39
+ },
40
+ play: async ({ canvasElement }) => {
41
+ await assertVisualizationRendered(canvasElement)
35
42
  }
36
43
  }
37
44
 
38
45
  export const multiple_lines: Story = {
39
46
  args: {
40
47
  config: editConfigKeys(multipleLines, [{ path: ['tooltips', 'dateDisplayFormat'], value: '%b. %d %Y' }])
48
+ },
49
+ play: async ({ canvasElement }) => {
50
+ await assertVisualizationRendered(canvasElement)
41
51
  }
42
52
  }
43
53
 
@@ -45,18 +55,27 @@ export const Lollipop: Story = {
45
55
  args: {
46
56
  config: lollipop,
47
57
  isEditor: false
58
+ },
59
+ play: async ({ canvasElement }) => {
60
+ await assertVisualizationRendered(canvasElement)
48
61
  }
49
62
  }
50
63
 
51
64
  export const Forest_Plot: Story = {
52
65
  args: {
53
66
  config: forestPlot
67
+ },
68
+ play: async ({ canvasElement }) => {
69
+ await assertVisualizationRendered(canvasElement)
54
70
  }
55
71
  }
56
72
 
57
73
  export const Horizontal_Bar: Story = {
58
74
  args: {
59
75
  config: horizontalBarConfig
76
+ },
77
+ play: async ({ canvasElement }) => {
78
+ await assertVisualizationRendered(canvasElement)
60
79
  }
61
80
  }
62
81
 
@@ -64,12 +83,18 @@ export const Horizontal_Bars_Dynamic_Y_Axis: Story = {
64
83
  args: {
65
84
  config: horizontalBarsDynamicYAxis,
66
85
  isEditor: false
86
+ },
87
+ play: async ({ canvasElement }) => {
88
+ await assertVisualizationRendered(canvasElement)
67
89
  }
68
90
  }
69
91
 
70
92
  export const BarChart_Labels: Story = {
71
93
  args: {
72
94
  config: barChartLabels
95
+ },
96
+ play: async ({ canvasElement }) => {
97
+ await assertVisualizationRendered(canvasElement)
73
98
  }
74
99
  }
75
100
 
@@ -77,12 +102,18 @@ export const Pie: Story = {
77
102
  args: {
78
103
  config: pieConfig,
79
104
  isEditor: true
105
+ },
106
+ play: async ({ canvasElement }) => {
107
+ await assertVisualizationRendered(canvasElement)
80
108
  }
81
109
  }
82
110
  export const Pie_Calculated_Area: Story = {
83
111
  args: {
84
112
  config: pieCalculatedArea,
85
113
  isEditor: true
114
+ },
115
+ play: async ({ canvasElement }) => {
116
+ await assertVisualizationRendered(canvasElement)
86
117
  }
87
118
  }
88
119
 
@@ -90,6 +121,9 @@ export const Paired_Bar: Story = {
90
121
  args: {
91
122
  config: pairedBar,
92
123
  isEditor: true
124
+ },
125
+ play: async ({ canvasElement }) => {
126
+ await assertVisualizationRendered(canvasElement)
93
127
  }
94
128
  }
95
129
 
@@ -97,6 +131,9 @@ export const Area_Chart_stacked: Story = {
97
131
  args: {
98
132
  config: areaChartStacked,
99
133
  isEditor: false
134
+ },
135
+ play: async ({ canvasElement }) => {
136
+ await assertVisualizationRendered(canvasElement)
100
137
  }
101
138
  }
102
139