@cdc/chart 4.26.1 → 4.26.3

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 (173) hide show
  1. package/CLAUDE.local.md +79 -0
  2. package/LICENSE +201 -0
  3. package/dist/{cdcchart-dgT_1dIT.es.js → cdcchart-DQ00cQCm.es.js} +1 -20
  4. package/dist/cdcchart.js +54742 -49796
  5. package/examples/data/data-with-metadata.json +10 -0
  6. package/examples/default.json +378 -0
  7. package/examples/feature/__data__/horizon-chart-data.json +373 -0
  8. package/examples/feature/annotations/index.json +3 -6
  9. package/examples/feature/horizon/horizon-chart.json +395 -0
  10. package/examples/feature/pie/planet-pie-example-config.json +2 -1
  11. package/examples/line-chart-states.json +1085 -0
  12. package/examples/metadata-variables.json +58 -0
  13. package/examples/private/123.json +694 -0
  14. package/examples/private/anchor-issue.json +4094 -0
  15. package/examples/private/backwards-slider.json +10430 -0
  16. package/examples/private/georgia.csv +160 -0
  17. package/examples/private/timeline-data.json +1 -0
  18. package/examples/private/timeline.json +389 -0
  19. package/examples/radar-chart-simple.json +133 -0
  20. package/examples/radar-chart.json +148 -0
  21. package/index.html +1 -31
  22. package/package.json +57 -59
  23. package/src/CdcChart.tsx +8 -4
  24. package/src/CdcChartComponent.tsx +398 -284
  25. package/src/_stories/Chart.Anchors.stories.tsx +10 -0
  26. package/src/_stories/Chart.BoxPlot.stories.tsx +7 -0
  27. package/src/_stories/Chart.CI.stories.tsx +13 -0
  28. package/src/_stories/Chart.Combo.stories.tsx +17 -0
  29. package/src/_stories/Chart.CustomColors.stories.tsx +78 -0
  30. package/src/_stories/Chart.Defaults.stories.tsx +95 -0
  31. package/src/_stories/Chart.DynamicSeries.stories.tsx +19 -0
  32. package/src/_stories/Chart.Filters.stories.tsx +4 -0
  33. package/src/_stories/Chart.Forecast.stories.tsx +4 -0
  34. package/src/_stories/Chart.HTMLInDataTable.stories.tsx +22 -0
  35. package/src/_stories/Chart.Legend.Gradient.stories.tsx +28 -0
  36. package/src/_stories/Chart.Patterns.stories.tsx +4 -0
  37. package/src/_stories/Chart.PreserveDecimals.stories.tsx +25 -0
  38. package/src/_stories/Chart.Regions.Categorical.stories.tsx +13 -0
  39. package/src/_stories/Chart.Regions.DateScale.stories.tsx +19 -0
  40. package/src/_stories/Chart.Regions.DateTimeScale.stories.tsx +25 -10
  41. package/src/_stories/Chart.ScatterPlot.stories.tsx +4 -0
  42. package/src/_stories/Chart.SmallMultiples.stories.tsx +16 -0
  43. package/src/_stories/Chart.SmallestLeftAxisMax.stories.tsx +64 -0
  44. package/src/_stories/Chart.stories.tsx +72 -1
  45. package/src/_stories/Chart.tooltip.stories.tsx +7 -0
  46. package/src/_stories/ChartAnnotation.stories.tsx +10 -0
  47. package/src/_stories/ChartAxisLabels.stories.tsx +4 -0
  48. package/src/_stories/ChartAxisTitles.stories.tsx +10 -0
  49. package/src/_stories/ChartBar.Editor.stories.tsx +97 -38
  50. package/src/_stories/ChartBrush.Editor.stories.tsx +11 -25
  51. package/src/_stories/ChartBrush.Matrix.Continuous.stories.tsx +41 -0
  52. package/src/_stories/ChartBrush.Matrix.Date.stories.tsx +114 -0
  53. package/src/_stories/ChartBrush.Matrix.DateTime.stories.tsx +78 -0
  54. package/src/_stories/ChartBrush.stories.tsx +7 -0
  55. package/src/_stories/ChartEditor.Editor.stories.tsx +1 -1
  56. package/src/_stories/ChartEditor.stories.tsx +7 -0
  57. package/src/_stories/ChartLine.QuadrantAngles.stories.tsx +89 -0
  58. package/src/_stories/ChartLine.Suppression.stories.tsx +7 -0
  59. package/src/_stories/ChartLine.Symbols.stories.tsx +4 -0
  60. package/src/_stories/ChartPrefixSuffix.stories.tsx +46 -1
  61. package/src/_stories/TechAdoptionWithLinks.stories.tsx +7 -0
  62. package/src/_stories/_mock/brush_continuous.json +86 -0
  63. package/src/_stories/_mock/brush_date_large.json +176 -0
  64. package/src/_stories/_mock/line_chart_angle_near_zero_fall.json +195 -0
  65. package/src/_stories/_mock/line_chart_angle_near_zero_rise.json +195 -0
  66. package/src/_stories/_mock/line_chart_angle_q1_steep_upward.json +195 -0
  67. package/src/_stories/_mock/line_chart_angle_q2_gentle_downward.json +195 -0
  68. package/src/_stories/_mock/line_chart_angle_q3_steep_downward.json +195 -0
  69. package/src/_stories/_mock/line_chart_angle_q4_gentle_upward.json +195 -0
  70. package/src/_stories/_mock/line_chart_quadrant_angles.json +264 -0
  71. package/src/_stories/_mock/paired-bar-abbr.json +421 -0
  72. package/src/_stories/_mock/pie_custom_colors.json +268 -0
  73. package/src/_stories/_mock/smallest_left_axis_max.json +104 -0
  74. package/src/components/Annotations/components/AnnotationDraggable.styles.css +14 -20
  75. package/src/components/Annotations/components/AnnotationDraggable.tsx +240 -116
  76. package/src/components/Annotations/components/AnnotationDropdown.styles.css +1 -2
  77. package/src/components/Annotations/components/AnnotationDropdown.tsx +8 -12
  78. package/src/components/Annotations/components/AnnotationList.styles.css +12 -18
  79. package/src/components/Annotations/components/AnnotationList.tsx +5 -4
  80. package/src/components/Annotations/components/findNearestDatum.ts +75 -85
  81. package/src/components/Annotations/helpers/getVisibleAnnotations.ts +38 -0
  82. package/src/components/Axis/BottomAxis.tsx +277 -0
  83. package/src/components/Axis/LeftAxis.tsx +404 -0
  84. package/src/components/Axis/LeftAxisGridlines.tsx +77 -0
  85. package/src/components/Axis/PairedBarAxis.tsx +192 -0
  86. package/src/components/Axis/README.md +94 -0
  87. package/src/components/Axis/RightAxis.tsx +108 -0
  88. package/src/components/Axis/axis.constants.ts +21 -0
  89. package/src/components/Axis/index.ts +7 -0
  90. package/src/components/BarChart/components/BarChart.Horizontal.tsx +12 -28
  91. package/src/components/BarChart/components/BarChart.StackedHorizontal.tsx +12 -30
  92. package/src/components/BarChart/components/BarChart.StackedVertical.tsx +12 -31
  93. package/src/components/BarChart/components/BarChart.Vertical.tsx +12 -28
  94. package/src/components/BarChart/components/BarChart.tsx +7 -1
  95. package/src/components/BarChart/helpers/getPatternUrl.ts +94 -0
  96. package/src/components/BarChart/helpers/tests/getPatternUrl.test.ts +134 -0
  97. package/src/components/BarChart/helpers/useBarChart.ts +3 -0
  98. package/src/components/Brush/BrushSelector.tsx +155 -22
  99. package/src/components/Brush/MiniChartPreview.tsx +133 -21
  100. package/src/components/EditorPanel/EditorPanel.tsx +81 -54
  101. package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +67 -29
  102. package/src/components/EditorPanel/components/Panels/Panel.ForestPlotSettings.tsx +0 -78
  103. package/src/components/EditorPanel/components/Panels/Panel.General.tsx +120 -2
  104. package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +25 -43
  105. package/src/components/EditorPanel/components/Panels/Panel.Radar.tsx +353 -0
  106. package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +83 -3
  107. package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +66 -43
  108. package/src/components/EditorPanel/components/Panels/index.tsx +2 -0
  109. package/src/components/EditorPanel/editor-panel.scss +1 -1
  110. package/src/components/EditorPanel/useEditorPermissions.ts +55 -26
  111. package/src/components/ForestPlot/ForestPlot.tsx +26 -22
  112. package/src/components/HorizonChart/HorizonChart.tsx +131 -0
  113. package/src/components/HorizonChart/components/HorizonBand.tsx +160 -0
  114. package/src/components/HorizonChart/helpers/calculateHorizonBands.ts +27 -0
  115. package/src/components/HorizonChart/helpers/getHorizonLayerColors.ts +40 -0
  116. package/src/components/HorizonChart/index.tsx +3 -0
  117. package/src/components/Legend/Legend.Component.tsx +52 -4
  118. package/src/components/Legend/Legend.tsx +1 -1
  119. package/src/components/Legend/LegendGroup/LegendGroup.styles.css +4 -4
  120. package/src/components/Legend/LegendValueRange.tsx +77 -0
  121. package/src/components/Legend/helpers/createFormatLabels.tsx +16 -2
  122. package/src/components/Legend/helpers/generateValueRanges.ts +92 -0
  123. package/src/components/LineChart/helpers/README.md +292 -0
  124. package/src/components/LineChart/helpers/labelPositioning.test.ts +245 -0
  125. package/src/components/LineChart/helpers/labelPositioning.ts +304 -0
  126. package/src/components/LineChart/index.tsx +44 -8
  127. package/src/components/LinearChart/README.md +109 -0
  128. package/src/components/LinearChart/VisualizationRenderer.tsx +267 -0
  129. package/src/components/LinearChart/linearChart.constants.ts +84 -0
  130. package/src/components/LinearChart/tests/LinearChart.test.tsx +278 -0
  131. package/src/components/LinearChart/tests/mockConfigContext.ts +131 -0
  132. package/src/components/LinearChart/utils/tickFormatting.ts +146 -0
  133. package/src/components/LinearChart.tsx +268 -1057
  134. package/src/components/PieChart/PieChart.tsx +20 -5
  135. package/src/components/RadarChart/RadarAxis.tsx +78 -0
  136. package/src/components/RadarChart/RadarChart.tsx +298 -0
  137. package/src/components/RadarChart/RadarGrid.tsx +64 -0
  138. package/src/components/RadarChart/RadarPolygon.tsx +91 -0
  139. package/src/components/RadarChart/helpers.ts +83 -0
  140. package/src/components/RadarChart/index.tsx +3 -0
  141. package/src/components/Regions/components/Regions.tsx +6 -6
  142. package/src/components/Sankey/components/Sankey.tsx +3 -3
  143. package/src/components/Sankey/sankey.scss +1 -1
  144. package/src/components/SmallMultiples/SmallMultiples.css +5 -5
  145. package/src/components/Sparkline/index.scss +4 -2
  146. package/src/components/WarmingStripes/WarmingStripes.tsx +95 -25
  147. package/src/components/WarmingStripes/WarmingStripesGradientLegend.css +8 -8
  148. package/src/data/initial-state.js +37 -15
  149. package/src/data/legacy-defaults.ts +18 -0
  150. package/src/helpers/abbreviateNumber.ts +24 -17
  151. package/src/helpers/getChartPatternId.ts +17 -0
  152. package/src/helpers/getExcludedData.ts +4 -0
  153. package/src/helpers/getMinMax.ts +16 -2
  154. package/src/helpers/handleChartAriaLabels.ts +19 -19
  155. package/src/helpers/handleLineType.ts +22 -18
  156. package/src/helpers/seriesColumnSettings.ts +114 -0
  157. package/src/helpers/tests/countNumOfTicks.test.ts +77 -0
  158. package/src/helpers/tests/seriesColumnSettings.test.ts +84 -0
  159. package/src/hooks/useProgrammaticTooltip.ts +23 -2
  160. package/src/hooks/useRightAxis.ts +14 -0
  161. package/src/hooks/useScales.ts +99 -56
  162. package/src/hooks/useTooltip.tsx +23 -3
  163. package/src/scss/main.scss +157 -79
  164. package/src/selectors/README.md +68 -0
  165. package/src/store/chart.reducer.ts +2 -0
  166. package/src/test/CdcChart.test.jsx +2 -2
  167. package/src/types/ChartConfig.ts +22 -0
  168. package/src/types/ChartContext.ts +1 -0
  169. package/src/types/Horizon.ts +64 -0
  170. package/tests/fixtures/chart-config-with-metadata.json +29 -0
  171. package/tests/fixtures/data-with-metadata.json +10 -0
  172. package/preview.html +0 -1616
  173. package/src/components/Annotations/components/helpers/index.tsx +0 -46
@@ -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
 
@@ -472,7 +472,7 @@ export const SmallMultiplesSectionTests: Story = {
472
472
  // ============================================================================
473
473
 
474
474
  const getChartCounts = () => {
475
- const chartContainer = canvasElement.querySelector('.cove-component__content, .chart-container, .visualization')
475
+ const chartContainer = canvasElement.querySelector('.cove-visualization__body, .chart-container, .visualization')
476
476
  const tiles = canvasElement.querySelectorAll('.small-multiple-tile, [class*="tile"]')
477
477
  const svgElements = chartContainer?.querySelectorAll('svg[role="img"], svg.chart') || []
478
478
 
@@ -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
@@ -2,6 +2,7 @@ import config from './../../examples/tech-adoption-with-links.json'
2
2
  import type { Meta, StoryObj } from '@storybook/react-vite'
3
3
  import Chart from '../CdcChart'
4
4
  import { editConfigKeys } from '@cdc/core/helpers/configHelpers'
5
+ import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
5
6
 
6
7
  const meta: Meta<typeof Chart> = {
7
8
  title: 'Components/Templates/Chart/Bar Chart/Horizontal Bar Chart Link Titles',
@@ -14,6 +15,9 @@ export const horizontal_barchart_links: Story = {
14
15
  args: {
15
16
  config: config,
16
17
  isEditor: true
18
+ },
19
+ play: async ({ canvasElement }) => {
20
+ await assertVisualizationRendered(canvasElement)
17
21
  }
18
22
  }
19
23
 
@@ -21,6 +25,9 @@ export const horizontal_barchart_links_single_series: Story = {
21
25
  args: {
22
26
  config: editConfigKeys(config, [{ path: ['tooltips', 'singleSeries'], value: true }]),
23
27
  isEditor: true
28
+ },
29
+ play: async ({ canvasElement }) => {
30
+ await assertVisualizationRendered(canvasElement)
24
31
  }
25
32
  }
26
33
 
@@ -0,0 +1,86 @@
1
+ {
2
+ "type": "chart",
3
+ "title": "Sensor Readings by Temperature - Continuous Axis Demo",
4
+ "showTitle": true,
5
+ "theme": "theme-blue",
6
+ "visualizationType": "Line",
7
+ "orientation": "vertical",
8
+ "xAxis": {
9
+ "type": "continuous",
10
+ "dataKey": "Temperature",
11
+ "hideAxis": false,
12
+ "hideLabel": false,
13
+ "hideTicks": false,
14
+ "size": 75,
15
+ "labelColor": "#333",
16
+ "tickLabelColor": "#333",
17
+ "tickColor": "#333",
18
+ "brushActive": true
19
+ },
20
+ "yAxis": {
21
+ "hideAxis": false,
22
+ "hideLabel": false,
23
+ "hideTicks": false,
24
+ "size": 50,
25
+ "gridLines": false,
26
+ "labelColor": "#333",
27
+ "tickLabelColor": "#333",
28
+ "tickColor": "#333"
29
+ },
30
+ "legend": {
31
+ "hide": false,
32
+ "behavior": "isolate",
33
+ "position": "right"
34
+ },
35
+ "table": {
36
+ "label": "Data Table",
37
+ "show": true
38
+ },
39
+ "series": [
40
+ {
41
+ "dataKey": "Pressure",
42
+ "type": "Line",
43
+ "lineType": "curveMonotoneX",
44
+ "weight": 3,
45
+ "axis": "Left",
46
+ "name": "Pressure (kPa)",
47
+ "tooltip": true
48
+ },
49
+ {
50
+ "dataKey": "Humidity",
51
+ "type": "dashed-md",
52
+ "lineType": "curveLinear",
53
+ "weight": 2,
54
+ "axis": "Left",
55
+ "name": "Humidity (%)",
56
+ "tooltip": true
57
+ }
58
+ ],
59
+ "data": [
60
+ { "Temperature": "10", "Pressure": "101.2", "Humidity": "85" },
61
+ { "Temperature": "15", "Pressure": "101.0", "Humidity": "82" },
62
+ { "Temperature": "20", "Pressure": "100.8", "Humidity": "78" },
63
+ { "Temperature": "25", "Pressure": "100.5", "Humidity": "74" },
64
+ { "Temperature": "30", "Pressure": "100.2", "Humidity": "70" },
65
+ { "Temperature": "35", "Pressure": "99.8", "Humidity": "65" },
66
+ { "Temperature": "40", "Pressure": "99.4", "Humidity": "60" },
67
+ { "Temperature": "45", "Pressure": "99.0", "Humidity": "56" },
68
+ { "Temperature": "50", "Pressure": "98.5", "Humidity": "52" },
69
+ { "Temperature": "55", "Pressure": "98.0", "Humidity": "48" },
70
+ { "Temperature": "60", "Pressure": "97.4", "Humidity": "45" },
71
+ { "Temperature": "65", "Pressure": "96.8", "Humidity": "42" },
72
+ { "Temperature": "70", "Pressure": "96.1", "Humidity": "40" },
73
+ { "Temperature": "75", "Pressure": "95.4", "Humidity": "38" },
74
+ { "Temperature": "80", "Pressure": "94.6", "Humidity": "36" },
75
+ { "Temperature": "85", "Pressure": "93.8", "Humidity": "35" },
76
+ { "Temperature": "90", "Pressure": "92.9", "Humidity": "34" },
77
+ { "Temperature": "95", "Pressure": "92.0", "Humidity": "33" },
78
+ { "Temperature": "100", "Pressure": "91.0", "Humidity": "32" },
79
+ { "Temperature": "105", "Pressure": "90.0", "Humidity": "31" },
80
+ { "Temperature": "110", "Pressure": "88.9", "Humidity": "30" },
81
+ { "Temperature": "115", "Pressure": "87.7", "Humidity": "29" },
82
+ { "Temperature": "120", "Pressure": "86.5", "Humidity": "28" },
83
+ { "Temperature": "125", "Pressure": "85.2", "Humidity": "27" },
84
+ { "Temperature": "130", "Pressure": "83.8", "Humidity": "26" }
85
+ ]
86
+ }
@@ -0,0 +1,176 @@
1
+ {
2
+ "type": "chart",
3
+ "title": "Weekly Regional Metrics - Date Type Brush Demo",
4
+ "showTitle": true,
5
+ "theme": "theme-blue",
6
+ "visualizationType": "Line",
7
+ "orientation": "vertical",
8
+ "xAxis": {
9
+ "type": "date",
10
+ "dataKey": "Week_End",
11
+ "dateParseFormat": "%Y-%m-%d",
12
+ "dateDisplayFormat": "%m/%d/%y",
13
+ "hideAxis": false,
14
+ "hideLabel": false,
15
+ "hideTicks": false,
16
+ "size": 75,
17
+ "labelColor": "#333",
18
+ "tickLabelColor": "#333",
19
+ "tickColor": "#333",
20
+ "brushActive": true
21
+ },
22
+ "yAxis": {
23
+ "hideAxis": false,
24
+ "hideLabel": false,
25
+ "hideTicks": false,
26
+ "size": 50,
27
+ "gridLines": false,
28
+ "labelColor": "#333",
29
+ "tickLabelColor": "#333",
30
+ "tickColor": "#333"
31
+ },
32
+ "legend": {
33
+ "hide": false,
34
+ "behavior": "isolate",
35
+ "position": "right"
36
+ },
37
+ "table": {
38
+ "label": "Data Table",
39
+ "show": true
40
+ },
41
+ "series": [
42
+ {
43
+ "dataKey": "National",
44
+ "type": "Line",
45
+ "lineType": "curveMonotoneX",
46
+ "weight": 3,
47
+ "axis": "Left",
48
+ "name": "National",
49
+ "tooltip": true
50
+ },
51
+ {
52
+ "dataKey": "Midwest",
53
+ "type": "Line",
54
+ "lineType": "curveMonotoneX",
55
+ "weight": 2,
56
+ "axis": "Left",
57
+ "name": "Midwest",
58
+ "tooltip": true
59
+ },
60
+ {
61
+ "dataKey": "South",
62
+ "type": "Line",
63
+ "lineType": "curveMonotoneX",
64
+ "weight": 2,
65
+ "axis": "Left",
66
+ "name": "South",
67
+ "tooltip": true
68
+ }
69
+ ],
70
+ "data": [
71
+ { "Week_End": "2022-01-01", "National": "10", "Midwest": "15", "South": "5" },
72
+ { "Week_End": "2022-01-08", "National": "11", "Midwest": "16", "South": "6" },
73
+ { "Week_End": "2022-01-15", "National": "12", "Midwest": "17", "South": "7" },
74
+ { "Week_End": "2022-01-22", "National": "13", "Midwest": "18", "South": "8" },
75
+ { "Week_End": "2022-01-29", "National": "14", "Midwest": "19", "South": "9" },
76
+ { "Week_End": "2022-02-05", "National": "15", "Midwest": "20", "South": "10" },
77
+ { "Week_End": "2022-02-12", "National": "16", "Midwest": "21", "South": "11" },
78
+ { "Week_End": "2022-02-19", "National": "17", "Midwest": "22", "South": "12" },
79
+ { "Week_End": "2022-02-26", "National": "18", "Midwest": "23", "South": "13" },
80
+ { "Week_End": "2022-03-05", "National": "19", "Midwest": "24", "South": "14" },
81
+ { "Week_End": "2022-03-12", "National": "20", "Midwest": "25", "South": "15" },
82
+ { "Week_End": "2022-03-19", "National": "21", "Midwest": "26", "South": "16" },
83
+ { "Week_End": "2022-03-26", "National": "22", "Midwest": "27", "South": "17" },
84
+ { "Week_End": "2022-04-02", "National": "23", "Midwest": "28", "South": "18" },
85
+ { "Week_End": "2022-04-09", "National": "24", "Midwest": "29", "South": "19" },
86
+ { "Week_End": "2022-04-16", "National": "25", "Midwest": "30", "South": "20" },
87
+ { "Week_End": "2022-04-23", "National": "26", "Midwest": "31", "South": "21" },
88
+ { "Week_End": "2022-04-30", "National": "27", "Midwest": "32", "South": "22" },
89
+ { "Week_End": "2022-05-07", "National": "28", "Midwest": "33", "South": "23" },
90
+ { "Week_End": "2022-05-14", "National": "29", "Midwest": "34", "South": "24" },
91
+ { "Week_End": "2022-05-21", "National": "30", "Midwest": "35", "South": "25" },
92
+ { "Week_End": "2022-05-28", "National": "31", "Midwest": "36", "South": "26" },
93
+ { "Week_End": "2022-06-04", "National": "32", "Midwest": "37", "South": "27" },
94
+ { "Week_End": "2022-06-11", "National": "33", "Midwest": "38", "South": "28" },
95
+ { "Week_End": "2022-06-18", "National": "34", "Midwest": "39", "South": "29" },
96
+ { "Week_End": "2022-06-25", "National": "35", "Midwest": "40", "South": "30" },
97
+ { "Week_End": "2022-07-02", "National": "36", "Midwest": "41", "South": "31" },
98
+ { "Week_End": "2022-07-09", "National": "37", "Midwest": "42", "South": "32" },
99
+ { "Week_End": "2022-07-16", "National": "38", "Midwest": "43", "South": "33" },
100
+ { "Week_End": "2022-07-23", "National": "39", "Midwest": "44", "South": "34" },
101
+ { "Week_End": "2022-07-30", "National": "40", "Midwest": "45", "South": "35" },
102
+ { "Week_End": "2022-08-06", "National": "41", "Midwest": "46", "South": "36" },
103
+ { "Week_End": "2022-08-13", "National": "42", "Midwest": "47", "South": "37" },
104
+ { "Week_End": "2022-08-20", "National": "43", "Midwest": "48", "South": "38" },
105
+ { "Week_End": "2022-08-27", "National": "44", "Midwest": "49", "South": "39" },
106
+ { "Week_End": "2022-09-03", "National": "45", "Midwest": "50", "South": "40" },
107
+ { "Week_End": "2022-09-10", "National": "46", "Midwest": "51", "South": "41" },
108
+ { "Week_End": "2022-09-17", "National": "47", "Midwest": "52", "South": "42" },
109
+ { "Week_End": "2022-09-24", "National": "48", "Midwest": "53", "South": "43" },
110
+ { "Week_End": "2022-10-01", "National": "49", "Midwest": "54", "South": "44" },
111
+ { "Week_End": "2022-10-08", "National": "50", "Midwest": "55", "South": "45" },
112
+ { "Week_End": "2022-10-15", "National": "51", "Midwest": "56", "South": "46" },
113
+ { "Week_End": "2022-10-22", "National": "52", "Midwest": "57", "South": "47" },
114
+ { "Week_End": "2022-10-29", "National": "53", "Midwest": "58", "South": "48" },
115
+ { "Week_End": "2022-11-05", "National": "54", "Midwest": "59", "South": "49" },
116
+ { "Week_End": "2022-11-12", "National": "55", "Midwest": "60", "South": "50" },
117
+ { "Week_End": "2022-11-19", "National": "56", "Midwest": "61", "South": "51" },
118
+ { "Week_End": "2022-11-26", "National": "57", "Midwest": "62", "South": "52" },
119
+ { "Week_End": "2022-12-03", "National": "58", "Midwest": "63", "South": "53" },
120
+ { "Week_End": "2022-12-10", "National": "59", "Midwest": "64", "South": "54" },
121
+ { "Week_End": "2022-12-17", "National": "60", "Midwest": "65", "South": "55" },
122
+ { "Week_End": "2022-12-24", "National": "61", "Midwest": "66", "South": "56" },
123
+ { "Week_End": "2022-12-31", "National": "62", "Midwest": "67", "South": "57" },
124
+ { "Week_End": "2023-01-07", "National": "63", "Midwest": "68", "South": "58" },
125
+ { "Week_End": "2023-01-14", "National": "64", "Midwest": "69", "South": "59" },
126
+ { "Week_End": "2023-01-21", "National": "65", "Midwest": "70", "South": "60" },
127
+ { "Week_End": "2023-01-28", "National": "66", "Midwest": "71", "South": "61" },
128
+ { "Week_End": "2023-02-04", "National": "67", "Midwest": "72", "South": "62" },
129
+ { "Week_End": "2023-02-11", "National": "68", "Midwest": "73", "South": "63" },
130
+ { "Week_End": "2023-02-18", "National": "69", "Midwest": "74", "South": "64" },
131
+ { "Week_End": "2023-02-25", "National": "70", "Midwest": "75", "South": "65" },
132
+ { "Week_End": "2023-03-04", "National": "71", "Midwest": "76", "South": "66" },
133
+ { "Week_End": "2023-03-11", "National": "72", "Midwest": "77", "South": "67" },
134
+ { "Week_End": "2023-03-18", "National": "73", "Midwest": "78", "South": "68" },
135
+ { "Week_End": "2023-03-25", "National": "74", "Midwest": "79", "South": "69" },
136
+ { "Week_End": "2023-04-01", "National": "75", "Midwest": "80", "South": "70" },
137
+ { "Week_End": "2023-04-08", "National": "76", "Midwest": "81", "South": "71" },
138
+ { "Week_End": "2023-04-15", "National": "77", "Midwest": "82", "South": "72" },
139
+ { "Week_End": "2023-04-22", "National": "78", "Midwest": "83", "South": "73" },
140
+ { "Week_End": "2023-04-29", "National": "79", "Midwest": "84", "South": "74" },
141
+ { "Week_End": "2023-05-06", "National": "80", "Midwest": "85", "South": "75" },
142
+ { "Week_End": "2023-05-13", "National": "81", "Midwest": "86", "South": "76" },
143
+ { "Week_End": "2023-05-20", "National": "82", "Midwest": "87", "South": "77" },
144
+ { "Week_End": "2023-05-27", "National": "83", "Midwest": "88", "South": "78" },
145
+ { "Week_End": "2023-06-03", "National": "84", "Midwest": "89", "South": "79" },
146
+ { "Week_End": "2023-06-10", "National": "85", "Midwest": "90", "South": "80" },
147
+ { "Week_End": "2023-06-17", "National": "86", "Midwest": "91", "South": "81" },
148
+ { "Week_End": "2023-06-24", "National": "87", "Midwest": "92", "South": "82" },
149
+ { "Week_End": "2023-07-01", "National": "88", "Midwest": "93", "South": "83" },
150
+ { "Week_End": "2023-07-08", "National": "89", "Midwest": "94", "South": "84" },
151
+ { "Week_End": "2023-07-15", "National": "90", "Midwest": "95", "South": "85" },
152
+ { "Week_End": "2023-07-22", "National": "91", "Midwest": "96", "South": "86" },
153
+ { "Week_End": "2023-07-29", "National": "92", "Midwest": "97", "South": "87" },
154
+ { "Week_End": "2023-08-05", "National": "93", "Midwest": "98", "South": "88" },
155
+ { "Week_End": "2023-08-12", "National": "94", "Midwest": "99", "South": "89" },
156
+ { "Week_End": "2023-08-19", "National": "95", "Midwest": "100", "South": "90" },
157
+ { "Week_End": "2023-08-26", "National": "96", "Midwest": "101", "South": "91" },
158
+ { "Week_End": "2023-09-02", "National": "97", "Midwest": "102", "South": "92" },
159
+ { "Week_End": "2023-09-09", "National": "98", "Midwest": "103", "South": "93" },
160
+ { "Week_End": "2023-09-16", "National": "99", "Midwest": "104", "South": "94" },
161
+ { "Week_End": "2023-09-23", "National": "100", "Midwest": "105", "South": "95" },
162
+ { "Week_End": "2023-09-30", "National": "101", "Midwest": "106", "South": "96" },
163
+ { "Week_End": "2023-10-07", "National": "102", "Midwest": "107", "South": "97" },
164
+ { "Week_End": "2023-10-14", "National": "103", "Midwest": "108", "South": "98" },
165
+ { "Week_End": "2023-10-21", "National": "104", "Midwest": "109", "South": "99" },
166
+ { "Week_End": "2023-10-28", "National": "105", "Midwest": "110", "South": "100" },
167
+ { "Week_End": "2023-11-04", "National": "106", "Midwest": "111", "South": "101" },
168
+ { "Week_End": "2023-11-11", "National": "107", "Midwest": "112", "South": "102" },
169
+ { "Week_End": "2023-11-18", "National": "108", "Midwest": "113", "South": "103" },
170
+ { "Week_End": "2023-11-25", "National": "109", "Midwest": "114", "South": "104" },
171
+ { "Week_End": "2023-12-02", "National": "110", "Midwest": "115", "South": "105" },
172
+ { "Week_End": "2023-12-09", "National": "111", "Midwest": "116", "South": "106" },
173
+ { "Week_End": "2023-12-16", "National": "112", "Midwest": "117", "South": "107" },
174
+ { "Week_End": "2023-12-23", "National": "113", "Midwest": "118", "South": "108" }
175
+ ]
176
+ }