@cdc/chart 4.25.8 → 4.25.11

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 (145) hide show
  1. package/.claude/settings.local.json +9 -0
  2. package/dist/{cdcchart-1a1724a1.es.js → cdcchart-dgT_1dIT.es.js} +136 -151
  3. package/dist/cdcchart.js +44236 -40355
  4. package/examples/feature/__data__/planet-example-data.json +0 -30
  5. package/examples/feature/boxplot/valid-boxplot.csv +38 -17
  6. package/examples/grouped-bar-test.json +400 -0
  7. package/examples/private/DEV-11825.json +573 -0
  8. package/examples/private/d.json +382 -0
  9. package/examples/private/example-2.json +49784 -0
  10. package/examples/private/f2.json +1 -0
  11. package/examples/private/f4.json +1577 -0
  12. package/examples/private/forecast.json +1180 -0
  13. package/examples/private/lollipop.json +468 -0
  14. package/examples/private/na.json +913 -0
  15. package/examples/private/new.json +48756 -0
  16. package/examples/private/pie-chart-legend.json +904 -0
  17. package/examples/private/test-data.csv +28 -0
  18. package/examples/suppressed_tooltip.json +480 -0
  19. package/index.html +2 -133
  20. package/package.json +25 -7
  21. package/src/CdcChart.tsx +9 -13
  22. package/src/CdcChartComponent.tsx +403 -92
  23. package/src/_stories/Chart.Anchors.stories.tsx +2 -2
  24. package/src/_stories/Chart.BoxPlot.stories.tsx +1 -1
  25. package/src/_stories/Chart.CI.stories.tsx +1 -1
  26. package/src/_stories/Chart.Combo.stories.tsx +18 -0
  27. package/src/_stories/Chart.CustomColors.stories.tsx +1 -1
  28. package/src/_stories/Chart.DynamicSeries.stories.tsx +2 -2
  29. package/src/_stories/Chart.Filters.stories.tsx +2 -2
  30. package/src/_stories/Chart.Forecast.stories.tsx +36 -0
  31. package/src/_stories/Chart.HTMLInDataTable.stories.tsx +520 -0
  32. package/src/_stories/Chart.Legend.Gradient.stories.tsx +2 -2
  33. package/src/_stories/Chart.Patterns.stories.tsx +20 -0
  34. package/src/_stories/Chart.PreserveDecimals.stories.tsx +220 -0
  35. package/src/_stories/Chart.ScatterPlot.stories.tsx +1 -1
  36. package/src/_stories/Chart.SmallMultiples.stories.tsx +47 -0
  37. package/src/_stories/Chart.stories.tsx +8 -5
  38. package/src/_stories/Chart.tooltip.stories.tsx +1 -1
  39. package/src/_stories/ChartAnnotation.stories.tsx +7 -4
  40. package/src/_stories/ChartAxisLabels.stories.tsx +2 -2
  41. package/src/_stories/ChartAxisTitles.stories.tsx +2 -2
  42. package/src/_stories/ChartBar.Editor.stories.tsx +3580 -0
  43. package/src/_stories/ChartEditor.Editor.stories.tsx +658 -0
  44. package/src/_stories/ChartEditor.stories.tsx +59 -60
  45. package/src/_stories/ChartLine.Suppression.stories.tsx +1 -1
  46. package/src/_stories/ChartLine.Symbols.stories.tsx +1 -1
  47. package/src/_stories/ChartPrefixSuffix.stories.tsx +2 -2
  48. package/src/_stories/_mock/combo.json +451 -0
  49. package/src/_stories/_mock/editor-test-configs.json +376 -0
  50. package/src/_stories/_mock/editor-test-datasets.json +477 -0
  51. package/src/_stories/_mock/editor-tests/bar-chart-editor-test.json +255 -0
  52. package/src/_stories/_mock/editor-tests/bar-chart-general-test.json +267 -0
  53. package/src/_stories/_mock/editor-tests/bar-chart-test.json +237 -0
  54. package/src/_stories/_mock/forecast_combo_with_gaps.json +913 -0
  55. package/src/_stories/_mock/pie_config.json +257 -62
  56. package/src/_stories/_mock/small_multiples/small_multiples_bars.json +1944 -0
  57. package/src/_stories/_mock/small_multiples/small_multiples_big_data_bars.json +1114 -0
  58. package/src/_stories/_mock/small_multiples/small_multiples_lines.json +2646 -0
  59. package/src/_stories/_mock/small_multiples/small_multiples_lines_colors.json +1305 -0
  60. package/src/_stories/_mock/small_multiples/small_multiples_stacked_bars.json +1936 -0
  61. package/src/_stories/_mock/stacked-pattern-test.json +520 -0
  62. package/src/components/Annotations/components/AnnotationDraggable.tsx +1 -0
  63. package/src/components/Annotations/components/AnnotationDropdown.tsx +1 -1
  64. package/src/components/Annotations/components/findNearestDatum.ts +6 -41
  65. package/src/components/AreaChart/components/AreaChart.Stacked.jsx +10 -6
  66. package/src/components/AreaChart/index.tsx +1 -2
  67. package/src/components/BarChart/components/BarChart.Horizontal.tsx +161 -22
  68. package/src/components/BarChart/components/BarChart.StackedHorizontal.tsx +138 -5
  69. package/src/components/BarChart/components/BarChart.StackedVertical.tsx +215 -73
  70. package/src/components/BarChart/components/BarChart.Vertical.tsx +155 -22
  71. package/src/components/BarChart/helpers/index.ts +43 -4
  72. package/src/components/BarChart/helpers/lollipopColors.ts +27 -0
  73. package/src/components/BarChart/helpers/useBarChart.ts +25 -3
  74. package/src/components/BoxPlot/BoxPlot.Vertical.tsx +2 -1
  75. package/src/components/BoxPlot/helpers/index.ts +3 -3
  76. package/src/components/Brush/BrushChart.tsx +1 -1
  77. package/src/components/DeviationBar.jsx +9 -6
  78. package/src/components/EditorPanel/EditorPanel.tsx +563 -229
  79. package/src/components/EditorPanel/EditorPanelContext.ts +3 -0
  80. package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +96 -111
  81. package/src/components/EditorPanel/components/Panels/Panel.General.tsx +19 -1
  82. package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +461 -0
  83. package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +80 -67
  84. package/src/components/EditorPanel/components/Panels/Panel.SmallMultiples.tsx +422 -0
  85. package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +188 -139
  86. package/src/components/EditorPanel/components/Panels/index.tsx +5 -1
  87. package/src/components/EditorPanel/components/Panels/panelVisual.styles.css +0 -8
  88. package/src/components/EditorPanel/editor-panel.scss +0 -20
  89. package/src/components/EditorPanel/helpers/updateFieldRankByValue.ts +49 -48
  90. package/src/components/EditorPanel/useEditorPermissions.ts +7 -15
  91. package/src/components/Forecasting/Forecasting.tsx +175 -27
  92. package/src/components/ForestPlot/ForestPlot.tsx +11 -7
  93. package/src/components/ForestPlot/ForestPlotProps.ts +1 -1
  94. package/src/components/Legend/Legend.Component.tsx +114 -14
  95. package/src/components/Legend/helpers/createFormatLabels.tsx +230 -171
  96. package/src/components/Legend/helpers/getLegendClasses.ts +0 -1
  97. package/src/components/LegendWrapper.tsx +1 -1
  98. package/src/components/LineChart/LineChartProps.ts +0 -3
  99. package/src/components/LineChart/components/LineChart.Circle.tsx +2 -2
  100. package/src/components/LineChart/helpers.ts +1 -1
  101. package/src/components/LineChart/index.tsx +38 -15
  102. package/src/components/LinearChart.tsx +96 -84
  103. package/src/components/PairedBarChart.jsx +6 -4
  104. package/src/components/PieChart/PieChart.tsx +170 -54
  105. package/src/components/Regions/components/Regions.tsx +3 -24
  106. package/src/components/Sankey/components/Sankey.tsx +7 -1
  107. package/src/components/Sankey/types/index.ts +1 -1
  108. package/src/components/ScatterPlot/ScatterPlot.jsx +32 -4
  109. package/src/components/SmallMultiples/SmallMultipleTile.tsx +198 -0
  110. package/src/components/SmallMultiples/SmallMultiples.css +32 -0
  111. package/src/components/SmallMultiples/SmallMultiples.tsx +271 -0
  112. package/src/components/SmallMultiples/index.ts +2 -0
  113. package/src/data/initial-state.js +327 -293
  114. package/src/helpers/buildForecastPaletteMappings.ts +112 -0
  115. package/src/helpers/buildForecastPaletteOptions.ts +71 -0
  116. package/src/helpers/getColorScale.ts +82 -8
  117. package/src/{hooks/useMinMax.ts → helpers/getMinMax.ts} +14 -7
  118. package/src/helpers/getNewRuntime.ts +1 -1
  119. package/src/helpers/getTransformedData.ts +1 -1
  120. package/src/helpers/getYAxisAutoPadding.ts +53 -0
  121. package/src/helpers/smallMultiplesHelpers.ts +529 -0
  122. package/src/hooks/useChartHoverAnalytics.tsx +44 -0
  123. package/src/hooks/useProgrammaticTooltip.ts +96 -0
  124. package/src/hooks/useReduceData.ts +105 -70
  125. package/src/hooks/useScales.ts +88 -34
  126. package/src/hooks/useSmallMultipleSynchronization.ts +59 -0
  127. package/src/hooks/useTooltip.tsx +116 -29
  128. package/src/index.jsx +0 -2
  129. package/src/scss/main.scss +13 -80
  130. package/src/store/chart.actions.ts +2 -0
  131. package/src/store/chart.reducer.ts +5 -1
  132. package/src/test/CdcChart.test.jsx +8 -3
  133. package/src/types/ChartConfig.ts +53 -11
  134. package/src/types/ChartContext.ts +4 -0
  135. package/vite.config.js +1 -1
  136. package/vitest.config.ts +16 -0
  137. package/src/_stories/_mock/pie_data.json +0 -218
  138. package/src/components/AreaChart/components/AreaChart.jsx +0 -109
  139. package/src/coreStyles_chart.scss +0 -3
  140. package/src/helpers/configHelpers.ts +0 -28
  141. package/src/helpers/generateColorsArray.ts +0 -8
  142. package/src/helpers/sort.ts +0 -7
  143. package/src/hooks/useActiveElement.js +0 -19
  144. package/src/hooks/useChartClasses.js +0 -41
  145. package/src/hooks/useColorPalette.js +0 -76
@@ -1,8 +1,8 @@
1
1
  import React from 'react'
2
- import { Meta, Story } from '@storybook/react'
2
+ import { Meta, Story } from '@storybook/react-vite'
3
3
  import Chart from '../CdcChartComponent'
4
4
  import exampleComboBarNonNumeric from './../../examples/feature/tests-date-exclusions/date-exclusions-config.json'
5
- import { editConfigKeys } from '../helpers/configHelpers'
5
+ import { editConfigKeys } from '@cdc/core/helpers/configHelpers'
6
6
 
7
7
  export default {
8
8
  title: 'Components/Templates/Chart/Anchors',
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from '@storybook/react'
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
2
  import boxPlotConfig from './_mock/boxplot_multiseries.json'
3
3
  import Chart from '../CdcChartComponent'
4
4
 
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from '@storybook/react'
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
2
  import barChartCiLabels from './_mock/bar_chart_ci_labels.json'
3
3
  import lineChartDynamicCI from './_mock/line_chart_dynamic_ci.json'
4
4
  import lineChartNonDynamicCI from './_mock/line_chart_non_dynamic_ci.json'
@@ -0,0 +1,18 @@
1
+ // generate a combo chart story
2
+ import React from 'react'
3
+ import { Meta, Story } from '@storybook/react'
4
+ import CdcChart from '@cdc/chart/src/CdcChart'
5
+ import comboChartConfig from './_mock/combo.json'
6
+
7
+ export default {
8
+ title: 'Components/Templates/Chart/Combo Chart',
9
+ component: CdcChart
10
+ } as Meta
11
+
12
+ const Template: Story = args => <CdcChart {...args} />
13
+
14
+ export const ComboChart = Template.bind({})
15
+ ComboChart.args = {
16
+ config: comboChartConfig,
17
+ isEditor: true
18
+ }
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from '@storybook/react'
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
2
  import Chart from '../CdcChartComponent'
3
3
  import scatterPlotCustomColorConfig from './_mock/scatterplot_mock.json'
4
4
 
@@ -1,7 +1,7 @@
1
1
  import DynamicSeriesConfig from './_mock/dynamic_series_config.json'
2
2
  import DynamicSeriesBarConfig from './_mock/dynamic_series_bar_config.json'
3
3
  import DynamicSeriesSuppression from './_mock/dynamic_series_suppression_mock.json'
4
- import { Meta, StoryObj } from '@storybook/react'
4
+ import { Meta, StoryObj } from '@storybook/react-vite'
5
5
  import Chart from '../CdcChartComponent'
6
6
 
7
7
  const meta: Meta<typeof Chart> = {
@@ -43,7 +43,7 @@ export const LineHoverPoints: Story = {
43
43
  export const Bar_Vertical: Story = {
44
44
  args: {
45
45
  config: DynamicSeriesBarConfig,
46
- isEditor: false
46
+ isEditor: true
47
47
  }
48
48
  }
49
49
 
@@ -1,6 +1,6 @@
1
- import type { Meta, StoryObj } from '@storybook/react'
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
2
  import Chart from '../CdcChartComponent'
3
- import { editConfigKeys } from '../helpers/configHelpers'
3
+ import { editConfigKeys } from '@cdc/core/helpers/configHelpers'
4
4
  import scatterPlotDownloadImage from './_mock/scatterplot-image-download.json'
5
5
 
6
6
  const meta: Meta<typeof Chart> = {
@@ -0,0 +1,36 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
+
3
+ import Chart from '../CdcChart'
4
+ import forecastComboWithGaps from './_mock/forecast_combo_with_gaps.json'
5
+
6
+ const meta: Meta<typeof Chart> = {
7
+ title: 'Components/Templates/Chart/Forecast Chart',
8
+ component: Chart,
9
+ parameters: {
10
+ docs: {
11
+ description: {
12
+ component:
13
+ 'Forecast charts with gap handling. This story demonstrates how forecast charts properly handle gaps in data by filtering invalid values (NA) and splitting segments at gaps.'
14
+ }
15
+ }
16
+ }
17
+ }
18
+
19
+ type Story = StoryObj<typeof Chart>
20
+
21
+ export const Forecast_Combo_With_Gaps: Story = {
22
+ args: {
23
+ config: forecastComboWithGaps,
24
+ isEditor: true
25
+ },
26
+ parameters: {
27
+ docs: {
28
+ description: {
29
+ story:
30
+ 'A combo chart with forecast confidence intervals that demonstrates proper gap handling. The forecast areas and lines are split into separate segments when gaps are detected, preventing misleading connections across missing data periods. Invalid data points (NA values) are automatically filtered out.'
31
+ }
32
+ }
33
+ }
34
+ }
35
+
36
+ export default meta
@@ -0,0 +1,520 @@
1
+ import { Meta, StoryObj } from '@storybook/react-vite'
2
+ import CdcChart from '../CdcChartComponent'
3
+
4
+ const meta: Meta<typeof CdcChart> = {
5
+ title: 'Components/Templates/Chart/HTML in Data Table',
6
+ component: CdcChart,
7
+ parameters: {
8
+ docs: {
9
+ description: {
10
+ component:
11
+ 'Demonstrates charts with HTML content rendered in data table columns, including footnotes, links, and formatted text.'
12
+ }
13
+ }
14
+ }
15
+ }
16
+
17
+ export default meta
18
+
19
+ type Story = StoryObj<typeof CdcChart>
20
+
21
+ // Sample data with HTML footnotes as a column
22
+ const sampleDataWithHTMLFootnotes = [
23
+ {
24
+ State: 'California',
25
+ VaccinationRate: 82.4,
26
+ Year: 2023,
27
+ Category: 'High',
28
+ Footnote: 'Data from <strong>CDC National Immunization Survey</strong>'
29
+ },
30
+ {
31
+ State: 'Connecticut',
32
+ VaccinationRate: 85.6,
33
+ Year: 2023,
34
+ Category: 'High',
35
+ Footnote: 'Coverage rate includes <em>all age groups</em>'
36
+ },
37
+ {
38
+ State: 'Massachusetts',
39
+ VaccinationRate: 87.3,
40
+ Year: 2023,
41
+ Category: 'High',
42
+ Footnote: 'Highest rate in <strong>2023</strong> survey'
43
+ },
44
+ {
45
+ State: 'New York',
46
+ VaccinationRate: 81.2,
47
+ Year: 2023,
48
+ Category: 'High',
49
+ Footnote: 'See <a href="https://www.cdc.gov" target="_blank">CDC.gov</a> for details'
50
+ },
51
+ {
52
+ State: 'Washington',
53
+ VaccinationRate: 80.5,
54
+ Year: 2023,
55
+ Category: 'High',
56
+ Footnote: 'Rate increased <strong>5%</strong> from previous year'
57
+ },
58
+ {
59
+ State: 'Alabama',
60
+ VaccinationRate: 72.5,
61
+ Year: 2023,
62
+ Category: 'Medium',
63
+ Footnote: 'Medium coverage: <em>60-79%</em> range'
64
+ },
65
+ {
66
+ State: 'Arizona',
67
+ VaccinationRate: 75.8,
68
+ Year: 2023,
69
+ Category: 'Medium',
70
+ Footnote: 'Improving from <strong>previous surveys</strong>'
71
+ },
72
+ {
73
+ State: 'Colorado',
74
+ VaccinationRate: 79.1,
75
+ Year: 2023,
76
+ Category: 'Medium',
77
+ Footnote: 'Near <em>high coverage</em> threshold'
78
+ }
79
+ ]
80
+
81
+ // Base chart configuration
82
+ const baseChartConfig: any = {
83
+ type: 'chart',
84
+ visualizationType: 'Bar',
85
+ title: 'State Vaccination Coverage Rates',
86
+ showTitle: true,
87
+ theme: 'theme-blue',
88
+ fontSize: 'medium',
89
+ orientation: 'vertical',
90
+ filterBehavior: 'Filter Change',
91
+ filters: [],
92
+ xAxis: {
93
+ label: 'State',
94
+ dataKey: 'State',
95
+ type: 'categorical'
96
+ },
97
+ yAxis: {
98
+ label: 'Vaccination Rate (%)',
99
+ dataKey: 'VaccinationRate',
100
+ type: 'linear'
101
+ },
102
+ series: [
103
+ {
104
+ dataKey: 'VaccinationRate',
105
+ type: 'Bar',
106
+ name: 'Coverage Rate'
107
+ }
108
+ ],
109
+ table: {
110
+ label: 'Data Table',
111
+ expanded: true,
112
+ show: true,
113
+ download: true
114
+ },
115
+ dataFormat: {
116
+ commas: false,
117
+ abbreviated: false,
118
+ roundTo: 1
119
+ },
120
+ data: sampleDataWithHTMLFootnotes
121
+ }
122
+
123
+ // Story 1: Basic HTML in footnote column
124
+ export const BasicHTMLInFootnoteColumn: Story = {
125
+ name: 'Basic HTML in Footnote Column',
126
+ args: {
127
+ config: {
128
+ ...baseChartConfig,
129
+ columns: {
130
+ State: {
131
+ name: 'State',
132
+ label: 'State',
133
+ dataTable: true
134
+ },
135
+ VaccinationRate: {
136
+ name: 'VaccinationRate',
137
+ label: 'Vaccination Rate (%)',
138
+ dataTable: true,
139
+ suffix: '%',
140
+ roundToPlace: 1
141
+ },
142
+ Footnote: {
143
+ name: 'Footnote',
144
+ label: 'Notes',
145
+ dataTable: true,
146
+ tooltips: false
147
+ }
148
+ }
149
+ },
150
+ isEditor: true
151
+ }
152
+ }
153
+
154
+ // Story 2: HTML with links and formatting
155
+ export const HTMLWithLinksAndFormatting: Story = {
156
+ name: 'HTML with Links and Formatting',
157
+ args: {
158
+ config: {
159
+ ...baseChartConfig,
160
+ data: [
161
+ {
162
+ State: 'California',
163
+ VaccinationRate: 82.4,
164
+ Footnote:
165
+ 'Source: <strong>CDC</strong> - <a href="https://www.cdc.gov/vaccines" target="_blank">Vaccine Data</a>\nReporting Period: January - December 2023'
166
+ },
167
+ {
168
+ State: 'Connecticut',
169
+ VaccinationRate: 85.6,
170
+ Footnote: 'Includes <em>all demographics</em>\nContact: <a href="mailto:health@ct.gov">health@ct.gov</a>'
171
+ },
172
+ {
173
+ State: 'Massachusetts',
174
+ VaccinationRate: 87.3,
175
+ Footnote:
176
+ '<strong style="color: #005ea2;">Leading state</strong> in vaccination coverage\nHighest rate in region'
177
+ },
178
+ {
179
+ State: 'New York',
180
+ VaccinationRate: 81.2,
181
+ Footnote: 'Data validated by <em>NYS Department of Health</em>\nSee full report for methodology'
182
+ },
183
+ {
184
+ State: 'Texas',
185
+ VaccinationRate: 69.8,
186
+ Footnote:
187
+ 'More info: <a href="https://dshs.texas.gov" target="_blank">TX DSHS</a>\nOutreach programs available'
188
+ }
189
+ ],
190
+ columns: {
191
+ State: {
192
+ name: 'State',
193
+ label: 'State',
194
+ dataTable: true
195
+ },
196
+ VaccinationRate: {
197
+ name: 'VaccinationRate',
198
+ label: 'Coverage Rate (%)',
199
+ dataTable: true,
200
+ suffix: '%',
201
+ roundToPlace: 1
202
+ },
203
+ Footnote: {
204
+ name: 'Footnote',
205
+ label: 'Additional Information',
206
+ dataTable: true
207
+ }
208
+ }
209
+ },
210
+ isEditor: true
211
+ }
212
+ }
213
+
214
+ // Story 3: HTML with line breaks
215
+ export const HTMLWithLineBreaks: Story = {
216
+ name: 'HTML with Line Breaks',
217
+ args: {
218
+ config: {
219
+ ...baseChartConfig,
220
+ data: [
221
+ {
222
+ State: 'California',
223
+ VaccinationRate: 82.4,
224
+ Footnote: '<strong>Data Source:</strong> CDC Survey<br><em>Collection Period:</em> Jan-Dec 2023'
225
+ },
226
+ {
227
+ State: 'Connecticut',
228
+ VaccinationRate: 85.6,
229
+ Footnote: 'Coverage includes:<br>• Ages 6 months+<br>• All vaccine types'
230
+ },
231
+ {
232
+ State: 'Massachusetts',
233
+ VaccinationRate: 87.3,
234
+ Footnote: 'Leading state for:<br>1. Overall coverage<br>2. Equity metrics'
235
+ },
236
+ {
237
+ State: 'New York',
238
+ VaccinationRate: 81.2,
239
+ Footnote: '<strong>Note:</strong> Excludes NYC<br>See separate report'
240
+ },
241
+ {
242
+ State: 'Washington',
243
+ VaccinationRate: 80.5,
244
+ Footnote: 'Trend: ↑ 5% YoY<br>Target: <strong>85%</strong> by 2024'
245
+ }
246
+ ],
247
+ columns: {
248
+ State: {
249
+ name: 'State',
250
+ label: 'State',
251
+ dataTable: true
252
+ },
253
+ VaccinationRate: {
254
+ name: 'VaccinationRate',
255
+ label: 'Rate (%)',
256
+ dataTable: true,
257
+ suffix: '%',
258
+ roundToPlace: 1
259
+ },
260
+ Footnote: {
261
+ name: 'Footnote',
262
+ label: 'Detailed Notes',
263
+ dataTable: true
264
+ }
265
+ }
266
+ },
267
+ isEditor: true
268
+ }
269
+ }
270
+
271
+ // Story 4: Complex HTML with lists
272
+ export const ComplexHTMLWithLists: Story = {
273
+ name: 'Complex HTML with Lists',
274
+ args: {
275
+ config: {
276
+ ...baseChartConfig,
277
+ data: [
278
+ {
279
+ State: 'California',
280
+ VaccinationRate: 82.4,
281
+ Footnote:
282
+ '<strong>Program Details:</strong><ul style="margin:0;padding-left:20px;"><li>State-funded clinics</li><li>Mobile vaccination units</li></ul>'
283
+ },
284
+ {
285
+ State: 'Connecticut',
286
+ VaccinationRate: 85.6,
287
+ Footnote:
288
+ '<em>Success Factors:</em><br><ol style="margin:0;padding-left:20px;"><li>Community outreach</li><li>School programs</li></ol>'
289
+ },
290
+ {
291
+ State: 'Massachusetts',
292
+ VaccinationRate: 87.3,
293
+ Footnote:
294
+ 'Achievements:<ul style="margin:0;padding-left:20px;"><li><strong>Highest rate</strong> in region</li><li>Improved <em>accessibility</em></li></ul>'
295
+ }
296
+ ],
297
+ columns: {
298
+ State: {
299
+ name: 'State',
300
+ label: 'State',
301
+ dataTable: true
302
+ },
303
+ VaccinationRate: {
304
+ name: 'VaccinationRate',
305
+ label: 'Coverage (%)',
306
+ dataTable: true,
307
+ suffix: '%',
308
+ roundToPlace: 1
309
+ },
310
+ Footnote: {
311
+ name: 'Footnote',
312
+ label: 'Program Information',
313
+ dataTable: true
314
+ }
315
+ }
316
+ },
317
+ isEditor: true
318
+ }
319
+ }
320
+
321
+ // Story 5: HTML with inline styles
322
+ export const HTMLWithInlineStyles: Story = {
323
+ name: 'HTML with Inline Styles',
324
+ args: {
325
+ config: {
326
+ ...baseChartConfig,
327
+ data: [
328
+ {
329
+ State: 'California',
330
+ VaccinationRate: 82.4,
331
+ Footnote:
332
+ '<span style="color: #005ea2; font-weight: bold;">High Priority State</span> - Continued improvement needed'
333
+ },
334
+ {
335
+ State: 'Connecticut',
336
+ VaccinationRate: 85.6,
337
+ Footnote: '<span style="background-color: #f0f0f0; padding: 2px 5px;">Exemplary Performance</span>'
338
+ },
339
+ {
340
+ State: 'Massachusetts',
341
+ VaccinationRate: 87.3,
342
+ Footnote: '<strong style="color: #2e8540;">✓ Target Achieved</strong> - Maintaining high coverage'
343
+ },
344
+ {
345
+ State: 'Texas',
346
+ VaccinationRate: 69.8,
347
+ Footnote: '<span style="color: #d54309;">⚠ Below Target</span> - Outreach initiatives underway'
348
+ }
349
+ ],
350
+ columns: {
351
+ State: {
352
+ name: 'State',
353
+ label: 'State',
354
+ dataTable: true
355
+ },
356
+ VaccinationRate: {
357
+ name: 'VaccinationRate',
358
+ label: 'Rate (%)',
359
+ dataTable: true,
360
+ suffix: '%',
361
+ roundToPlace: 1
362
+ },
363
+ Footnote: {
364
+ name: 'Footnote',
365
+ label: 'Status',
366
+ dataTable: true
367
+ }
368
+ }
369
+ },
370
+ isEditor: true
371
+ }
372
+ }
373
+
374
+ // Story 6: Line chart with HTML footnotes
375
+ export const LineChartWithHTMLFootnotes: Story = {
376
+ name: 'Line Chart with HTML Footnotes',
377
+ args: {
378
+ config: {
379
+ ...baseChartConfig,
380
+ visualizationType: 'Line',
381
+ title: 'Vaccination Rate Trends',
382
+ data: [
383
+ {
384
+ Year: '2019',
385
+ Rate: 72.5,
386
+ Footnote: 'Baseline year - <strong>Pre-pandemic</strong> data'
387
+ },
388
+ {
389
+ Year: '2020',
390
+ Rate: 68.3,
391
+ Footnote: '<em style="color: #d54309;">Pandemic impact</em> - Reduced access to healthcare'
392
+ },
393
+ {
394
+ Year: '2021',
395
+ Rate: 75.8,
396
+ Footnote: 'Recovery begins - <strong>Vaccination campaigns</strong> launched'
397
+ },
398
+ {
399
+ Year: '2022',
400
+ Rate: 80.1,
401
+ Footnote: 'Significant improvement - See <a href="https://www.cdc.gov" target="_blank">CDC report</a>'
402
+ },
403
+ {
404
+ Year: '2023',
405
+ Rate: 82.4,
406
+ Footnote: '<strong style="color: #2e8540;">Target exceeded</strong> - Continued success'
407
+ }
408
+ ],
409
+ xAxis: {
410
+ label: 'Year',
411
+ dataKey: 'Year',
412
+ type: 'categorical'
413
+ },
414
+ yAxis: {
415
+ label: 'Vaccination Rate (%)',
416
+ dataKey: 'Rate',
417
+ type: 'linear'
418
+ },
419
+ series: [
420
+ {
421
+ dataKey: 'Rate',
422
+ type: 'Line',
423
+ name: 'Coverage Rate'
424
+ }
425
+ ],
426
+ columns: {
427
+ Year: {
428
+ name: 'Year',
429
+ label: 'Year',
430
+ dataTable: true
431
+ },
432
+ Rate: {
433
+ name: 'Rate',
434
+ label: 'Rate (%)',
435
+ dataTable: true,
436
+ suffix: '%',
437
+ roundToPlace: 1
438
+ },
439
+ Footnote: {
440
+ name: 'Footnote',
441
+ label: 'Context & Notes',
442
+ dataTable: true
443
+ }
444
+ }
445
+ },
446
+ isEditor: true
447
+ }
448
+ }
449
+
450
+ // Story 7: Pie chart with HTML footnotes
451
+ export const PieChartWithHTMLFootnotes: Story = {
452
+ name: 'Pie Chart with HTML Footnotes',
453
+ args: {
454
+ config: {
455
+ type: 'chart',
456
+ visualizationType: 'Pie',
457
+ title: 'Coverage by Category',
458
+ showTitle: true,
459
+ theme: 'theme-blue',
460
+ fontSize: 'medium',
461
+ filterBehavior: 'Filter Change',
462
+ filters: [],
463
+ data: [
464
+ {
465
+ Category: 'High Coverage',
466
+ Count: 5,
467
+ Percentage: 42,
468
+ Footnote: '<strong>5 states</strong> with ≥80% coverage<br>Leading examples: <em>MA, CT, NY</em>'
469
+ },
470
+ {
471
+ Category: 'Medium Coverage',
472
+ Count: 7,
473
+ Percentage: 58,
474
+ Footnote: '<strong>7 states</strong> with 60-79% coverage<br>Target: Move to <em>high category</em>'
475
+ }
476
+ ],
477
+ series: [
478
+ {
479
+ dataKey: 'Percentage',
480
+ type: 'Pie',
481
+ name: 'Coverage Distribution'
482
+ }
483
+ ],
484
+ table: {
485
+ label: 'Coverage Distribution Data',
486
+ expanded: true,
487
+ show: true,
488
+ download: true
489
+ },
490
+ columns: {
491
+ Category: {
492
+ name: 'Category',
493
+ label: 'Coverage Category',
494
+ dataTable: true
495
+ },
496
+ Count: {
497
+ name: 'Count',
498
+ label: 'Number of States',
499
+ dataTable: true
500
+ },
501
+ Percentage: {
502
+ name: 'Percentage',
503
+ label: 'Percentage',
504
+ dataTable: true,
505
+ suffix: '%'
506
+ },
507
+ Footnote: {
508
+ name: 'Footnote',
509
+ label: 'Details',
510
+ dataTable: true
511
+ }
512
+ },
513
+ dataFormat: {
514
+ commas: false,
515
+ abbreviated: false
516
+ }
517
+ },
518
+ isEditor: true
519
+ }
520
+ }
@@ -1,10 +1,10 @@
1
- import type { Meta, StoryObj } from '@storybook/react'
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
2
  import chartGradientConfig from './_mock/legend.gradient_mock.json'
3
3
  import chartGroupedLagend from './_mock/legend_groupBy_mock.json'
4
4
  import SimplifiedLineConfig from './_mock/simplified_line.json'
5
5
 
6
6
  import Chart from '../CdcChartComponent'
7
- import { editConfigKeys } from '../helpers/configHelpers'
7
+ import { editConfigKeys } from '@cdc/core/helpers/configHelpers'
8
8
 
9
9
  const meta: Meta<typeof Chart> = {
10
10
  title: 'Components/Templates/Chart/Legend',
@@ -0,0 +1,20 @@
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+ import StackedPattern from './_mock/stacked-pattern-test.json'
3
+
4
+ import Chart from '../CdcChartComponent'
5
+
6
+ const meta: Meta<typeof Chart> = {
7
+ title: 'Components/Templates/Chart/Patterns',
8
+ component: Chart
9
+ }
10
+
11
+ type Story = StoryObj<typeof Chart>
12
+
13
+ export const Stacked_Bar_Pattern: Story = {
14
+ args: {
15
+ config: StackedPattern,
16
+ isEditor: true
17
+ }
18
+ }
19
+
20
+ export default meta