@cdc/chart 4.25.10 → 4.26.1

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 (135) hide show
  1. package/dist/{cdcchart-1a1724a1.es.js → cdcchart-dgT_1dIT.es.js} +136 -151
  2. package/dist/cdcchart.js +44003 -43518
  3. package/examples/feature/__data__/planet-example-data.json +1 -1
  4. package/examples/feature/boxplot/valid-boxplot.csv +38 -17
  5. package/examples/feature/pie/planet-pie-example-config.json +48 -2
  6. package/examples/private/DEV-11825.json +573 -0
  7. package/examples/private/DEV-12100.json +1303 -0
  8. package/examples/private/cat-y.json +1235 -0
  9. package/examples/private/data-points.json +228 -0
  10. package/examples/private/height.json +3915 -0
  11. package/examples/private/links.json +569 -0
  12. package/examples/private/na.json +913 -0
  13. package/examples/private/quadrant.txt +30 -0
  14. package/examples/private/test-data.csv +28 -0
  15. package/examples/private/test-forecast.json +5510 -0
  16. package/examples/private/warming-stripe-test.json +2578 -0
  17. package/examples/private/warming-stripes.json +4763 -0
  18. package/examples/tech-adoption-with-links.json +560 -0
  19. package/index.html +16 -140
  20. package/package.json +6 -5
  21. package/preview.html +1616 -0
  22. package/src/CdcChart.tsx +8 -11
  23. package/src/CdcChartComponent.tsx +329 -124
  24. package/src/_stories/Chart.Combo.stories.tsx +18 -0
  25. package/src/_stories/Chart.Forecast.stories.tsx +36 -0
  26. package/src/_stories/Chart.HTMLInDataTable.stories.tsx +520 -0
  27. package/src/_stories/Chart.Patterns.stories.tsx +2 -1
  28. package/src/_stories/Chart.PreserveDecimals.stories.tsx +220 -0
  29. package/src/_stories/Chart.Regions.Categorical.stories.tsx +148 -0
  30. package/src/_stories/Chart.Regions.DateScale.stories.tsx +197 -0
  31. package/src/_stories/Chart.Regions.DateTimeScale.stories.tsx +297 -0
  32. package/src/_stories/Chart.SmallMultiples.stories.tsx +47 -0
  33. package/src/_stories/Chart.stories.tsx +8 -0
  34. package/src/_stories/ChartAnnotation.stories.tsx +6 -3
  35. package/src/_stories/ChartBar.Editor.stories.tsx +3585 -0
  36. package/src/_stories/ChartBrush.Editor.stories.tsx +295 -0
  37. package/src/_stories/ChartBrush.stories.tsx +50 -0
  38. package/src/_stories/ChartEditor.Editor.stories.tsx +656 -0
  39. package/src/_stories/ChartEditor.stories.tsx +1 -2
  40. package/src/_stories/TechAdoptionWithLinks.stories.tsx +27 -0
  41. package/src/_stories/_mock/brush_enabled.json +326 -0
  42. package/src/_stories/_mock/brush_mock.json +2 -69
  43. package/src/_stories/_mock/combo.json +451 -0
  44. package/src/_stories/_mock/editor-test-configs.json +376 -0
  45. package/src/_stories/_mock/editor-test-datasets.json +477 -0
  46. package/src/_stories/_mock/editor-tests/bar-chart-editor-test.json +255 -0
  47. package/src/_stories/_mock/editor-tests/bar-chart-general-test.json +267 -0
  48. package/src/_stories/_mock/editor-tests/bar-chart-test.json +237 -0
  49. package/src/_stories/_mock/forecast_combo_with_gaps.json +913 -0
  50. package/src/_stories/_mock/horizontal-bars-dynamic-y-axis.json +413 -0
  51. package/src/_stories/_mock/pie_config.json +257 -62
  52. package/src/_stories/_mock/small_multiples/small_multiples_bars.json +1944 -0
  53. package/src/_stories/_mock/small_multiples/small_multiples_big_data_bars.json +1114 -0
  54. package/src/_stories/_mock/small_multiples/small_multiples_lines.json +2646 -0
  55. package/src/_stories/_mock/small_multiples/small_multiples_lines_colors.json +1305 -0
  56. package/src/_stories/_mock/small_multiples/small_multiples_stacked_bars.json +1936 -0
  57. package/src/components/Annotations/components/findNearestDatum.ts +6 -41
  58. package/src/components/AreaChart/components/AreaChart.Stacked.jsx +10 -7
  59. package/src/components/AreaChart/index.tsx +1 -2
  60. package/src/components/Axis/Categorical.Axis.tsx +6 -7
  61. package/src/components/BarChart/components/BarChart.Horizontal.tsx +181 -27
  62. package/src/components/BarChart/components/BarChart.StackedHorizontal.tsx +3 -1
  63. package/src/components/BarChart/components/BarChart.StackedVertical.tsx +1 -0
  64. package/src/components/BarChart/components/BarChart.Vertical.tsx +8 -9
  65. package/src/components/BarChart/components/context.tsx +1 -0
  66. package/src/components/BarChart/helpers/useBarChart.ts +14 -2
  67. package/src/components/BoxPlot/helpers/index.ts +3 -3
  68. package/src/components/Brush/BrushSelector.tsx +1258 -0
  69. package/src/components/Brush/MiniChartPreview.tsx +283 -0
  70. package/src/components/DeviationBar.jsx +9 -7
  71. package/src/components/EditorPanel/EditorPanel.tsx +2720 -2586
  72. package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +96 -111
  73. package/src/components/EditorPanel/components/Panels/Panel.ForestPlotSettings.tsx +56 -34
  74. package/src/components/EditorPanel/components/Panels/Panel.General.tsx +76 -31
  75. package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +104 -55
  76. package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +54 -49
  77. package/src/components/EditorPanel/components/Panels/Panel.SmallMultiples.tsx +427 -0
  78. package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +96 -48
  79. package/src/components/EditorPanel/components/Panels/index.tsx +3 -1
  80. package/src/components/EditorPanel/editor-panel.scss +0 -20
  81. package/src/components/EditorPanel/useEditorPermissions.ts +36 -31
  82. package/src/components/Forecasting/Forecasting.tsx +139 -21
  83. package/src/components/Legend/Legend.Component.tsx +16 -9
  84. package/src/components/Legend/Legend.tsx +3 -2
  85. package/src/components/Legend/helpers/createFormatLabels.tsx +325 -176
  86. package/src/components/Legend/helpers/getLegendClasses.ts +0 -1
  87. package/src/components/Legend/helpers/index.ts +10 -6
  88. package/src/components/LineChart/LineChartProps.ts +0 -3
  89. package/src/components/LineChart/helpers.ts +1 -1
  90. package/src/components/LineChart/index.tsx +36 -13
  91. package/src/components/LinearChart.tsx +559 -499
  92. package/src/components/PairedBarChart.jsx +20 -3
  93. package/src/components/Regions/components/Regions.tsx +366 -144
  94. package/src/components/Sankey/types/index.ts +1 -1
  95. package/src/components/ScatterPlot/ScatterPlot.jsx +2 -2
  96. package/src/components/SmallMultiples/SmallMultipleTile.tsx +202 -0
  97. package/src/components/SmallMultiples/SmallMultiples.css +32 -0
  98. package/src/components/SmallMultiples/SmallMultiples.tsx +271 -0
  99. package/src/components/SmallMultiples/index.ts +2 -0
  100. package/src/components/WarmingStripes/WarmingStripes.tsx +160 -0
  101. package/src/components/WarmingStripes/WarmingStripesGradientLegend.css +35 -0
  102. package/src/components/WarmingStripes/WarmingStripesGradientLegend.tsx +104 -0
  103. package/src/components/WarmingStripes/index.tsx +3 -0
  104. package/src/data/initial-state.js +16 -2
  105. package/src/helpers/buildForecastPaletteOptions.ts +0 -38
  106. package/src/helpers/calculateHorizontalBarCategoryLabelWidth.ts +57 -0
  107. package/src/helpers/getColorScale.ts +10 -0
  108. package/src/{hooks/useMinMax.ts → helpers/getMinMax.ts} +26 -14
  109. package/src/helpers/getYAxisAutoPadding.ts +53 -0
  110. package/src/helpers/sizeHelpers.ts +0 -20
  111. package/src/helpers/smallMultiplesHelpers.ts +529 -0
  112. package/src/hooks/useChartHoverAnalytics.tsx +10 -9
  113. package/src/hooks/useProgrammaticTooltip.ts +96 -0
  114. package/src/hooks/useScales.ts +98 -34
  115. package/src/hooks/useSmallMultipleSynchronization.ts +59 -0
  116. package/src/hooks/useTooltip.tsx +91 -25
  117. package/src/scss/DataTable.scss +0 -4
  118. package/src/scss/main.scss +18 -83
  119. package/src/store/chart.actions.ts +2 -0
  120. package/src/store/chart.reducer.ts +4 -0
  121. package/src/test/CdcChart.test.jsx +1 -1
  122. package/src/types/ChartConfig.ts +27 -6
  123. package/src/types/ChartContext.ts +3 -0
  124. package/src/types/Label.ts +1 -0
  125. package/src/utils/analyticsTracking.ts +19 -0
  126. package/LICENSE +0 -201
  127. package/src/_stories/_mock/pie_data.json +0 -218
  128. package/src/components/AreaChart/components/AreaChart.jsx +0 -109
  129. package/src/components/Brush/BrushChart.tsx +0 -128
  130. package/src/components/Brush/BrushController.tsx +0 -71
  131. package/src/components/Brush/types.tsx +0 -8
  132. package/src/components/BrushChart.tsx +0 -223
  133. package/src/helpers/sort.ts +0 -7
  134. package/src/hooks/useActiveElement.js +0 -19
  135. package/src/hooks/useChartClasses.js +0 -41
@@ -0,0 +1,297 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
+ import Chart from '../CdcChart'
3
+
4
+ const meta: Meta<typeof Chart> = {
5
+ title: 'Components/Templates/Chart/Regions/Date-Time Scale (Continuous)',
6
+ component: Chart
7
+ }
8
+
9
+ type Story = StoryObj<typeof Chart>
10
+
11
+ const dateData = [
12
+ { date: '2024-01-01', value: 10 },
13
+ { date: '2024-01-08', value: 25 },
14
+ { date: '2024-01-15', value: 35 },
15
+ { date: '2024-01-22', value: 45 },
16
+ { date: '2024-01-29', value: 55 },
17
+ { date: '2024-02-05', value: 40 },
18
+ { date: '2024-02-12', value: 60 },
19
+ { date: '2024-02-19', value: 75 },
20
+ { date: '2024-02-26', value: 65 },
21
+ { date: '2024-03-04', value: 80 }
22
+ ]
23
+
24
+ const baseDateTimeConfig = {
25
+ type: 'chart',
26
+ visualizationType: 'Line',
27
+ orientation: 'vertical',
28
+ showTitle: true,
29
+ theme: 'theme-blue',
30
+ animate: false,
31
+ xAxis: {
32
+ type: 'date-time',
33
+ dataKey: 'date',
34
+ dateParseFormat: '%Y-%m-%d',
35
+ dateDisplayFormat: '%b %-d',
36
+ size: '0',
37
+ hideAxis: false,
38
+ hideTicks: false,
39
+ numTicks: '6'
40
+ },
41
+ yAxis: {
42
+ size: '50',
43
+ hideAxis: false,
44
+ hideTicks: false,
45
+ gridLines: true,
46
+ min: '0',
47
+ max: '100'
48
+ },
49
+ series: [{ dataKey: 'value', type: 'Line', axis: 'Left', tooltip: true, name: 'Value' }],
50
+ legend: { hide: true },
51
+ data: dateData,
52
+ regions: []
53
+ }
54
+
55
+ // LINE CHARTS
56
+
57
+ export const Line_Fixed_From_Fixed_To: Story = {
58
+ args: {
59
+ config: {
60
+ ...baseDateTimeConfig,
61
+ title: 'Date-Time Scale - Line: Fixed From + Fixed To',
62
+ regions: [
63
+ {
64
+ from: '2024-01-15',
65
+ to: '2024-02-11',
66
+ fromType: 'Fixed',
67
+ toType: 'Fixed',
68
+ label: 'Fixed Region',
69
+ background: '#0077cc',
70
+ color: '#000000',
71
+ range: 'Custom'
72
+ }
73
+ ]
74
+ },
75
+ isEditor: true
76
+ }
77
+ }
78
+
79
+ export const Line_Fixed_From_Last_Date: Story = {
80
+ args: {
81
+ config: {
82
+ ...baseDateTimeConfig,
83
+ title: 'Date-Time Scale - Line: Fixed From + Last Date',
84
+ regions: [
85
+ {
86
+ from: '2024-02-05',
87
+ to: '',
88
+ fromType: 'Fixed',
89
+ toType: 'Last Date',
90
+ label: 'To Last Date',
91
+ background: '#00aa55',
92
+ color: '#000000',
93
+ range: 'Custom'
94
+ }
95
+ ]
96
+ },
97
+ isEditor: true
98
+ }
99
+ }
100
+
101
+ export const Line_Previous_Days_Last_Date: Story = {
102
+ args: {
103
+ config: {
104
+ ...baseDateTimeConfig,
105
+ title: 'Date-Time Scale - Line: Previous Days + Last Date',
106
+ regions: [
107
+ {
108
+ from: '8',
109
+ to: '',
110
+ fromType: 'Previous Days',
111
+ toType: 'Last Date',
112
+ label: 'Last 8 Days',
113
+ background: '#aa0077',
114
+ color: '#000000',
115
+ range: 'Custom'
116
+ }
117
+ ]
118
+ },
119
+ isEditor: true
120
+ }
121
+ }
122
+
123
+ // BAR CHARTS
124
+
125
+ export const Bar_Fixed_From_Fixed_To: Story = {
126
+ args: {
127
+ config: {
128
+ ...baseDateTimeConfig,
129
+ visualizationType: 'Bar',
130
+ barThickness: 0.7,
131
+ title: 'Date-Time Scale - Bar: Fixed From + Fixed To',
132
+ regions: [
133
+ {
134
+ from: '2024-01-15',
135
+ to: '2024-02-12',
136
+ fromType: 'Fixed',
137
+ toType: 'Fixed',
138
+ label: 'Fixed Region',
139
+ background: '#0077cc',
140
+ color: '#000000',
141
+ range: 'Custom'
142
+ }
143
+ ]
144
+ },
145
+ isEditor: true
146
+ }
147
+ }
148
+
149
+ export const Bar_Fixed_From_Last_Date: Story = {
150
+ args: {
151
+ config: {
152
+ ...baseDateTimeConfig,
153
+ visualizationType: 'Bar',
154
+ barThickness: 0.7,
155
+ title: 'Date-Time Scale - Bar: Fixed From + Last Date',
156
+ regions: [
157
+ {
158
+ from: '2024-02-05',
159
+ to: '',
160
+ fromType: 'Fixed',
161
+ toType: 'Last Date',
162
+ label: 'To Last Date',
163
+ background: '#00aa55',
164
+ color: '#000000',
165
+ range: 'Custom'
166
+ }
167
+ ]
168
+ },
169
+ isEditor: true
170
+ }
171
+ }
172
+
173
+ export const Bar_Previous_Days_Last_Date: Story = {
174
+ args: {
175
+ config: {
176
+ ...baseDateTimeConfig,
177
+ visualizationType: 'Bar',
178
+ barThickness: 0.7,
179
+ title: 'Date-Time Scale - Bar: Previous Days + Last Date',
180
+ regions: [
181
+ {
182
+ from: '28',
183
+ to: '',
184
+ fromType: 'Previous Days',
185
+ toType: 'Last Date',
186
+ label: 'Last 28 Days',
187
+ background: '#aa0077',
188
+ color: '#000000',
189
+ range: 'Custom'
190
+ }
191
+ ]
192
+ },
193
+ isEditor: true
194
+ }
195
+ }
196
+
197
+ // EDGE CASES
198
+
199
+ export const Edge_Region_At_Start: Story = {
200
+ args: {
201
+ config: {
202
+ ...baseDateTimeConfig,
203
+ title: 'Edge Case: Region at Start',
204
+ regions: [
205
+ {
206
+ from: '2024-01-01',
207
+ to: '2024-01-21',
208
+ fromType: 'Fixed',
209
+ toType: 'Fixed',
210
+ label: 'At Start',
211
+ background: '#0077cc',
212
+ color: '#000000',
213
+ range: 'Custom'
214
+ }
215
+ ]
216
+ },
217
+ isEditor: true
218
+ }
219
+ }
220
+
221
+ export const Edge_Region_At_End: Story = {
222
+ args: {
223
+ config: {
224
+ ...baseDateTimeConfig,
225
+ title: 'Edge Case: Region at End',
226
+ regions: [
227
+ {
228
+ from: '2024-02-19',
229
+ to: '2024-03-04',
230
+ fromType: 'Fixed',
231
+ toType: 'Fixed',
232
+ label: 'At End',
233
+ background: '#00aa55',
234
+ color: '#000000',
235
+ range: 'Custom'
236
+ }
237
+ ]
238
+ },
239
+ isEditor: true
240
+ }
241
+ }
242
+
243
+ export const Edge_Full_Coverage: Story = {
244
+ args: {
245
+ config: {
246
+ ...baseDateTimeConfig,
247
+ title: 'Edge Case: Full Chart Coverage',
248
+ regions: [
249
+ {
250
+ from: '2024-01-01',
251
+ to: '',
252
+ fromType: 'Fixed',
253
+ toType: 'Last Date',
254
+ label: 'Full Coverage',
255
+ background: '#cc7700',
256
+ color: '#000000',
257
+ range: 'Custom'
258
+ }
259
+ ]
260
+ },
261
+ isEditor: true
262
+ }
263
+ }
264
+
265
+ export const Multiple_Regions: Story = {
266
+ args: {
267
+ config: {
268
+ ...baseDateTimeConfig,
269
+ title: 'Multiple Regions',
270
+ regions: [
271
+ {
272
+ from: '2024-01-08',
273
+ to: '2024-01-21',
274
+ fromType: 'Fixed',
275
+ toType: 'Fixed',
276
+ label: 'Region 1',
277
+ background: '#0077cc',
278
+ color: '#000000',
279
+ range: 'Custom'
280
+ },
281
+ {
282
+ from: '2024-02-05',
283
+ to: '2024-02-18',
284
+ fromType: 'Fixed',
285
+ toType: 'Fixed',
286
+ label: 'Region 2',
287
+ background: '#00aa55',
288
+ color: '#000000',
289
+ range: 'Custom'
290
+ }
291
+ ]
292
+ },
293
+ isEditor: true
294
+ }
295
+ }
296
+
297
+ export default meta
@@ -0,0 +1,47 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
+ import Chart from '../CdcChartComponent'
3
+ import smallMultiplesBars from './_mock/small_multiples/small_multiples_bars.json'
4
+ import smallMultiplesBigDataBars from './_mock/small_multiples/small_multiples_big_data_bars.json'
5
+ import smallMultiplesLinesColors from './_mock/small_multiples/small_multiples_lines_colors.json'
6
+ import smallMultiplesLines from './_mock/small_multiples/small_multiples_lines.json'
7
+ import smallMultiplesStackedBars from './_mock/small_multiples/small_multiples_stacked_bars.json'
8
+
9
+ const meta: Meta<typeof Chart> = {
10
+ title: 'Components/Templates/Chart/Small Multiples',
11
+ component: Chart
12
+ }
13
+
14
+ type Story = StoryObj<typeof Chart>
15
+
16
+ export const smallMultiples_Bars: Story = {
17
+ args: {
18
+ config: smallMultiplesBars,
19
+ isEditor: false
20
+ }
21
+ }
22
+
23
+ export const smallMultiples_BigDataBars: Story = {
24
+ args: {
25
+ config: smallMultiplesBigDataBars,
26
+ isEditor: false
27
+ }
28
+ }
29
+ export const smallMultiples_LinesColors: Story = {
30
+ args: {
31
+ config: smallMultiplesLinesColors,
32
+ isEditor: false
33
+ }
34
+ }
35
+ export const smallMultiples_Lines: Story = {
36
+ args: {
37
+ config: smallMultiplesLines,
38
+ isEditor: false
39
+ }
40
+ }
41
+ export const smallMultiples_StackedBars: Story = {
42
+ args: {
43
+ config: smallMultiplesStackedBars,
44
+ isEditor: false
45
+ }
46
+ }
47
+ export default meta
@@ -7,6 +7,7 @@ import lollipop from './_mock/lollipop.json'
7
7
  import forestPlot from '../../examples/feature/forest-plot/forest-plot.json'
8
8
  import pairedBar from './_mock/paired-bar.json'
9
9
  import horizontalBarConfig from './_mock/horizontal_bar.json'
10
+ import horizontalBarsDynamicYAxis from './_mock/horizontal-bars-dynamic-y-axis.json'
10
11
  import barChartLabels from './_mock/barchart_labels.mock.json'
11
12
  import pieConfig from './_mock/pie_with_data.json'
12
13
  import pieCalculatedArea from './_mock/pie_calculated_area.json'
@@ -59,6 +60,13 @@ export const Horizontal_Bar: Story = {
59
60
  }
60
61
  }
61
62
 
63
+ export const Horizontal_Bars_Dynamic_Y_Axis: Story = {
64
+ args: {
65
+ config: horizontalBarsDynamicYAxis,
66
+ isEditor: false
67
+ }
68
+ }
69
+
62
70
  export const BarChart_Labels: Story = {
63
71
  args: {
64
72
  config: barChartLabels
@@ -13,19 +13,22 @@ type Story = StoryObj<typeof Chart>
13
13
 
14
14
  export const Chart_Annotation_Categorical: Story = {
15
15
  args: {
16
- config: annotationConfig
16
+ config: annotationConfig,
17
+ isEditor: true
17
18
  }
18
19
  }
19
20
 
20
21
  export const Chart_Annotation_Date_Linear: Story = {
21
22
  args: {
22
- config: annotationConfigDateLinear
23
+ config: annotationConfigDateLinear,
24
+ isEditor: true
23
25
  }
24
26
  }
25
27
 
26
28
  export const Chart_Annotation_Date_Time: Story = {
27
29
  args: {
28
- config: annotationConfigDateTime
30
+ config: annotationConfigDateTime,
31
+ isEditor: true
29
32
  }
30
33
  }
31
34