@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
@@ -0,0 +1,520 @@
1
+ {
2
+ "filters": [],
3
+ "filterBehavior": "Filter Change",
4
+ "openModal": true,
5
+ "uid": "chart1750783711238",
6
+ "type": "chart",
7
+ "visualizationType": "Bar",
8
+ "dataKey": "NNDSSTestConditions20162022.csv",
9
+ "description": "",
10
+ "dataDescription": {
11
+ "horizontal": false,
12
+ "series": false
13
+ },
14
+ "annotations": [],
15
+ "debugSvg": false,
16
+ "chartMessage": {
17
+ "noData": "No Data Available"
18
+ },
19
+ "title": "",
20
+ "showTitle": false,
21
+ "showDownloadMediaButton": false,
22
+ "theme": "theme-blue",
23
+ "animate": false,
24
+ "lineDatapointStyle": "hover",
25
+ "lineDatapointColor": "Same as Line",
26
+ "barHasBorder": "false",
27
+ "isLollipopChart": false,
28
+ "lollipopShape": "circle",
29
+ "lollipopColorStyle": "two-tone",
30
+ "visualizationSubType": "stacked",
31
+ "barStyle": "",
32
+ "roundingStyle": "standard",
33
+ "tipRounding": "top",
34
+ "isResponsiveTicks": false,
35
+ "general": {
36
+ "annotationDropdownText": "Annotations",
37
+ "showMissingDataLabel": false,
38
+ "showSuppressedSymbol": true,
39
+ "showZeroValueData": false,
40
+ "hideNullValue": true
41
+ },
42
+ "padding": {
43
+ "left": 5,
44
+ "right": 5
45
+ },
46
+ "preliminaryData": [],
47
+ "yAxis": {
48
+ "hideAxis": true,
49
+ "displayNumbersOnBar": false,
50
+ "hideLabel": false,
51
+ "hideTicks": true,
52
+ "size": 45,
53
+ "gridLines": true,
54
+ "enablePadding": false,
55
+ "min": "",
56
+ "max": 200,
57
+ "labelColor": "#333",
58
+ "tickLabelColor": "#333",
59
+ "tickColor": "#333",
60
+ "rightHideAxis": false,
61
+ "rightAxisSize": 0,
62
+ "rightLabel": "",
63
+ "rightLabelOffsetSize": 0,
64
+ "rightAxisLabelColor": "#333",
65
+ "rightAxisTickLabelColor": "#333",
66
+ "rightAxisTickColor": "#333",
67
+ "numTicks": "5",
68
+ "axisPadding": 0,
69
+ "scalePadding": 10,
70
+ "tickRotation": 0,
71
+ "anchors": [],
72
+ "shoMissingDataLabel": true,
73
+ "showMissingDataLine": true,
74
+ "categories": [],
75
+ "inlineLabel": " cases"
76
+ },
77
+ "boxplot": {
78
+ "plots": [],
79
+ "borders": "true",
80
+ "plotOutlierValues": false,
81
+ "plotNonOutlierValues": true,
82
+ "labels": {
83
+ "q1": "Lower Quartile",
84
+ "q2": "q2",
85
+ "q3": "Upper Quartile",
86
+ "q4": "q4",
87
+ "minimum": "Minimum",
88
+ "maximum": "Maximum",
89
+ "mean": "Mean",
90
+ "median": "Median",
91
+ "sd": "Standard Deviation",
92
+ "iqr": "Interquartile Range",
93
+ "count": "Count",
94
+ "outliers": "Outliers",
95
+ "values": "Values",
96
+ "lowerBounds": "Lower Bounds",
97
+ "upperBounds": "Upper Bounds"
98
+ }
99
+ },
100
+ "topAxis": {
101
+ "hasLine": false
102
+ },
103
+ "isLegendValue": false,
104
+ "barThickness": 0.9,
105
+ "barHeight": 25,
106
+ "barSpace": 15,
107
+ "heights": {
108
+ "vertical": 300,
109
+ "horizontal": 750,
110
+ "mobileVertical": 200
111
+ },
112
+ "xAxis": {
113
+ "sortDates": false,
114
+ "anchors": [],
115
+ "type": "date",
116
+ "showTargetLabel": true,
117
+ "targetLabel": "Target",
118
+ "hideAxis": false,
119
+ "hideLabel": false,
120
+ "hideTicks": false,
121
+ "size": 75,
122
+ "tickRotation": 0,
123
+ "min": "",
124
+ "max": "",
125
+ "labelColor": "#333",
126
+ "tickLabelColor": "#333",
127
+ "tickColor": "#333",
128
+ "numTicks": "",
129
+ "labelOffset": 0,
130
+ "axisPadding": 200,
131
+ "target": 0,
132
+ "maxTickRotation": 0,
133
+ "padding": 5,
134
+ "showYearsOnce": false,
135
+ "sortByRecentDate": false,
136
+ "brushActive": false,
137
+ "dataKey": "year",
138
+ "axisBBox": 8,
139
+ "tickWidthMax": 39,
140
+ "dateParseFormat": "%Y",
141
+ "dateDisplayFormat": "%Y",
142
+ "viewportNumTicks": {
143
+ "xs": "4",
144
+ "xxs": "4"
145
+ }
146
+ },
147
+ "table": {
148
+ "label": "Data Table",
149
+ "expanded": false,
150
+ "limitHeight": false,
151
+ "height": "",
152
+ "caption": "",
153
+ "showDownloadUrl": false,
154
+ "showDataTableLink": false,
155
+ "showDownloadLinkBelow": true,
156
+ "indexLabel": "",
157
+ "download": true,
158
+ "showVertical": true,
159
+ "dateDisplayFormat": "",
160
+ "showMissingDataLabel": true,
161
+ "showSuppressedSymbol": true,
162
+ "show": true
163
+ },
164
+ "orientation": "vertical",
165
+ "color": "pinkpurple",
166
+ "columns": {
167
+ "domestic_count": {
168
+ "label": "Domestic Cases",
169
+ "dataTable": true,
170
+ "tooltips": false,
171
+ "prefix": "",
172
+ "suffix": "",
173
+ "forestPlot": false,
174
+ "startingPoint": "0",
175
+ "forestPlotAlignRight": false,
176
+ "roundToPlace": 0,
177
+ "commas": true,
178
+ "showInViz": false,
179
+ "forestPlotStartingPoint": 0,
180
+ "name": "domestic_count"
181
+ },
182
+ "abroad_count": {
183
+ "label": "Cases Abroad",
184
+ "dataTable": true,
185
+ "tooltips": false,
186
+ "prefix": "",
187
+ "suffix": "",
188
+ "forestPlot": false,
189
+ "startingPoint": "0",
190
+ "forestPlotAlignRight": false,
191
+ "roundToPlace": 0,
192
+ "commas": true,
193
+ "showInViz": false,
194
+ "forestPlotStartingPoint": 0,
195
+ "name": "abroad_count"
196
+ },
197
+ "year": {
198
+ "label": "Year",
199
+ "dataTable": true,
200
+ "tooltips": false,
201
+ "prefix": "",
202
+ "suffix": "",
203
+ "forestPlot": false,
204
+ "startingPoint": "0",
205
+ "forestPlotAlignRight": false,
206
+ "roundToPlace": 0,
207
+ "commas": false,
208
+ "showInViz": false,
209
+ "forestPlotStartingPoint": 0,
210
+ "name": "year"
211
+ }
212
+ },
213
+ "legend": {
214
+ "hide": false,
215
+ "behavior": "isolate",
216
+ "axisAlign": true,
217
+ "singleRow": true,
218
+ "colorCode": "recon_prov",
219
+ "reverseLabelOrder": true,
220
+ "description": "",
221
+ "dynamicLegend": false,
222
+ "dynamicLegendDefaultText": "Show All",
223
+ "dynamicLegendItemLimit": 5,
224
+ "dynamicLegendItemLimitMessage": "Dynamic Legend Item Limit Hit.",
225
+ "dynamicLegendChartMessage": "Select Options from the Legend",
226
+ "label": "",
227
+ "lineMode": false,
228
+ "verticalSorted": false,
229
+ "highlightOnHover": false,
230
+ "hideSuppressedLabels": false,
231
+ "hideSuppressionLink": false,
232
+ "seriesHighlight": [],
233
+ "style": "boxes",
234
+ "subStyle": "linear blocks",
235
+ "groupBy": "",
236
+ "shape": "circle",
237
+ "tickRotation": "",
238
+ "order": "dataColumn",
239
+ "hideBorder": {
240
+ "side": false,
241
+ "topBottom": true
242
+ },
243
+ "position": "top",
244
+ "orderedValues": [],
245
+ "unified": true,
246
+ "patterns": {
247
+ "Provisional": {
248
+ "label": "Provisional Data",
249
+ "color": "#000000",
250
+ "shape": "diagonalLines",
251
+ "dataKey": "recon_prov",
252
+ "dataValue": "Provisional",
253
+ "patternSize": 10
254
+ }
255
+ }
256
+ },
257
+ "brush": {
258
+ "isActive": false,
259
+ "isBrushing": false,
260
+ "data": [],
261
+ "height": 45,
262
+ "active": false
263
+ },
264
+ "exclusions": {
265
+ "active": false,
266
+ "keys": []
267
+ },
268
+ "palette": "qualitative-bold",
269
+ "isPaletteReversed": false,
270
+ "twoColor": {
271
+ "palette": "monochrome-1",
272
+ "isPaletteReversed": false
273
+ },
274
+ "labels": false,
275
+ "dataFormat": {
276
+ "commas": true,
277
+ "prefix": "",
278
+ "suffix": "",
279
+ "abbreviated": false,
280
+ "bottomSuffix": "",
281
+ "bottomPrefix": "",
282
+ "bottomAbbreviated": false
283
+ },
284
+ "confidenceKeys": {},
285
+ "visual": {
286
+ "border": true,
287
+ "accent": true,
288
+ "background": true,
289
+ "verticalHoverLine": true,
290
+ "horizontalHoverLine": false,
291
+ "lineDatapointSymbol": "none",
292
+ "maximumShapeAmount": 7
293
+ },
294
+ "useLogScale": false,
295
+ "highlightedBarValues": [],
296
+ "series": [
297
+ {
298
+ "dataKey": "domestic_count",
299
+ "type": "Bar",
300
+ "axis": "Left",
301
+ "tooltip": true,
302
+ "name": "Domestic Cases"
303
+ },
304
+ {
305
+ "dataKey": "abroad_count",
306
+ "type": "Bar",
307
+ "axis": "Left",
308
+ "tooltip": true,
309
+ "name": "Cases Abroad"
310
+ }
311
+ ],
312
+ "tooltips": {
313
+ "opacity": 90,
314
+ "singleSeries": false,
315
+ "dateDisplayFormat": ""
316
+ },
317
+ "forestPlot": {
318
+ "startAt": 0,
319
+ "colors": {
320
+ "line": "",
321
+ "shape": ""
322
+ },
323
+ "lineOfNoEffect": {
324
+ "show": true
325
+ },
326
+ "type": "",
327
+ "pooledResult": {
328
+ "diamondHeight": 5,
329
+ "column": ""
330
+ },
331
+ "estimateField": "",
332
+ "estimateRadius": "",
333
+ "shape": "square",
334
+ "rowHeight": 20,
335
+ "description": {
336
+ "show": true,
337
+ "text": "description",
338
+ "location": 0
339
+ },
340
+ "result": {
341
+ "show": true,
342
+ "text": "result",
343
+ "location": 100
344
+ },
345
+ "radius": {
346
+ "min": 2,
347
+ "max": 10,
348
+ "scalingColumn": ""
349
+ },
350
+ "regression": {
351
+ "lower": 0,
352
+ "upper": 0,
353
+ "estimateField": 0
354
+ },
355
+ "leftWidthOffset": 0,
356
+ "rightWidthOffset": 0,
357
+ "showZeroLine": false,
358
+ "leftLabel": "",
359
+ "rightLabel": ""
360
+ },
361
+ "area": {
362
+ "isStacked": false
363
+ },
364
+ "sankey": {
365
+ "title": {
366
+ "defaultColor": "black"
367
+ },
368
+ "iterations": 1,
369
+ "rxValue": 0.9,
370
+ "overallSize": {
371
+ "width": 900,
372
+ "height": 700
373
+ },
374
+ "margin": {
375
+ "margin_y": 25,
376
+ "margin_x": 0
377
+ },
378
+ "nodeSize": {
379
+ "nodeWidth": 26,
380
+ "nodeHeight": 40
381
+ },
382
+ "nodePadding": 55,
383
+ "nodeFontColor": "black",
384
+ "nodeColor": {
385
+ "default": "#ff8500",
386
+ "inactive": "#808080"
387
+ },
388
+ "linkColor": {
389
+ "default": "#ffc900",
390
+ "inactive": "#D3D3D3"
391
+ },
392
+ "opacity": {
393
+ "nodeOpacityDefault": 1,
394
+ "nodeOpacityInactive": 0.1,
395
+ "LinkOpacityDefault": 1,
396
+ "LinkOpacityInactive": 0.1
397
+ },
398
+ "storyNodeFontColor": "#006778",
399
+ "storyNodeText": [],
400
+ "nodeValueStyle": {
401
+ "textBefore": "(",
402
+ "textAfter": ")"
403
+ },
404
+ "data": []
405
+ },
406
+ "dynamicMarginTop": 0,
407
+ "dataFileName": "nndss_annual_epi_curve.json",
408
+ "dataFileSourceType": "file",
409
+ "allowLineToBarGraph": "__​undefined__",
410
+ "version": "4.25.6",
411
+ "migrations": {
412
+ "addColorMigration": true
413
+ },
414
+ "regions": [],
415
+ "customColors": ["#377eb8", "#9fd4ff"],
416
+ "data": [
417
+ {
418
+ "condition_identifier": "leptospirosis",
419
+ "na_reason": "",
420
+ "year": 2025,
421
+ "domestic_count": 46,
422
+ "abroad_count": 12,
423
+ "condition": "Leptospirosis",
424
+ "category": "Animal-borne diseases",
425
+ "recon_prov": "Provisional"
426
+ },
427
+ {
428
+ "condition_identifier": "leptospirosis",
429
+ "na_reason": "",
430
+ "year": 2024,
431
+ "domestic_count": 120,
432
+ "abroad_count": 18,
433
+ "condition": "Leptospirosis",
434
+ "category": "Animal-borne diseases",
435
+ "recon_prov": "Provisional"
436
+ },
437
+ {
438
+ "condition_identifier": "leptospirosis",
439
+ "na_reason": "",
440
+ "year": 2023,
441
+ "domestic_count": 94,
442
+ "abroad_count": 8,
443
+ "condition": "Leptospirosis",
444
+ "category": "Animal-borne diseases",
445
+ "recon_prov": "Provisional"
446
+ },
447
+ {
448
+ "condition_identifier": "leptospirosis",
449
+ "na_reason": "",
450
+ "year": 2022,
451
+ "domestic_count": 62,
452
+ "abroad_count": 15,
453
+ "condition": "Leptospirosis",
454
+ "category": "Animal-borne diseases",
455
+ "recon_prov": "Reconciled"
456
+ },
457
+ {
458
+ "condition_identifier": "leptospirosis",
459
+ "na_reason": "",
460
+ "year": 2021,
461
+ "domestic_count": 69,
462
+ "abroad_count": 22,
463
+ "condition": "Leptospirosis",
464
+ "category": "Animal-borne diseases",
465
+ "recon_prov": "Reconciled"
466
+ }
467
+ ],
468
+ "formattedData": [
469
+ {
470
+ "condition_identifier": "leptospirosis",
471
+ "na_reason": "",
472
+ "year": 2025,
473
+ "domestic_count": 46,
474
+ "abroad_count": 12,
475
+ "condition": "Leptospirosis",
476
+ "category": "Animal-borne diseases",
477
+ "recon_prov": "Provisional"
478
+ },
479
+ {
480
+ "condition_identifier": "leptospirosis",
481
+ "na_reason": "",
482
+ "year": 2024,
483
+ "domestic_count": 120,
484
+ "abroad_count": 18,
485
+ "condition": "Leptospirosis",
486
+ "category": "Animal-borne diseases",
487
+ "recon_prov": "Provisional"
488
+ },
489
+ {
490
+ "condition_identifier": "leptospirosis",
491
+ "na_reason": "",
492
+ "year": 2023,
493
+ "domestic_count": 94,
494
+ "abroad_count": 8,
495
+ "condition": "Leptospirosis",
496
+ "category": "Animal-borne diseases",
497
+ "recon_prov": "Provisional"
498
+ },
499
+ {
500
+ "condition_identifier": "leptospirosis",
501
+ "na_reason": "",
502
+ "year": 2022,
503
+ "domestic_count": 62,
504
+ "abroad_count": 15,
505
+ "condition": "Leptospirosis",
506
+ "category": "Animal-borne diseases",
507
+ "recon_prov": "Reconciled"
508
+ },
509
+ {
510
+ "condition_identifier": "leptospirosis",
511
+ "na_reason": "",
512
+ "year": 2021,
513
+ "domestic_count": 69,
514
+ "abroad_count": 22,
515
+ "condition": "Leptospirosis",
516
+ "category": "Animal-borne diseases",
517
+ "recon_prov": "Reconciled"
518
+ }
519
+ ]
520
+ }
@@ -49,6 +49,7 @@ const Annotations = ({ xScale, yScale, xScaleAnnotation, xMax, svgRef, onDragSta
49
49
 
50
50
  return (
51
51
  <AnnotationComponent
52
+ key={`annotation-${index}`}
52
53
  width={200}
53
54
  height={height}
54
55
  dx={annotation.dx} // label position
@@ -51,7 +51,7 @@ const AnnotationDropdown = () => {
51
51
  }}
52
52
  tabIndex={0}
53
53
  onKeyDown={e => {
54
- if (e.keyCode === 13) {
54
+ if (e.key === 'Enter') {
55
55
  setExpanded(!expanded)
56
56
  }
57
57
  }}
@@ -1,41 +1,3 @@
1
- import { timeParse } from 'd3-time-format'
2
-
3
- const getXValueFromCoordinate = (x, isClick = false) => {
4
- if (visualizationType === 'Pie') return
5
- if (orientation === 'horizontal') return
6
-
7
- // Check the type of x equal to point or if the type of xAxis is equal to continuous or date
8
- if (config.xAxis.type === 'categorical' || (visualizationType === 'Combo' && orientation !== 'horizontal' && visualizationType !== 'Forest Plot')) {
9
- let range = xScale.range()[1] - xScale.range()[0]
10
- let eachBand = range / (xScale.domain().length + 1)
11
-
12
- let numerator = x
13
- const index = Math.floor((Number(numerator) - eachBand / 2) / eachBand)
14
- return xScale.domain()[index] // fixes off by 1 error
15
- }
16
-
17
- if (config.xAxis.type === 'date') {
18
- const xValue = x // Assuming x is the coordinate on the chart
19
- const xTimestamp = convertXValueToTimestamp(x, 0, xMax, xScale.domain())
20
-
21
- // Calculate the closest date to the x coordinate
22
- let closestDate = null
23
- let minDistance = Number.MAX_VALUE
24
-
25
- xScale.domain().forEach(timestamp => {
26
- const distance = Math.abs(xTimestamp - timestamp)
27
- if (distance < minDistance) {
28
- minDistance = distance
29
- closestDate = timestamp
30
- }
31
- })
32
-
33
- return closestDate
34
- }
35
-
36
- return x
37
- }
38
-
39
1
  const findNearestDatum = ({ data, xScale, yScale, config, xMax, annotationSeriesKey }, xPosition) => {
40
2
  const { xAxis, visualizationType, orientation } = config
41
3
 
@@ -62,7 +24,7 @@ const findNearestDatum = ({ data, xScale, yScale, config, xMax, annotationSeries
62
24
  return domain[index]
63
25
  }
64
26
 
65
- const getXValueFromCoordinate = (x, isClick = false) => {
27
+ const getXValueFromCoordinate = x => {
66
28
  if (visualizationType === 'Pie') return
67
29
  if (orientation === 'horizontal') return
68
30
 
@@ -85,7 +47,10 @@ const findNearestDatum = ({ data, xScale, yScale, config, xMax, annotationSeries
85
47
  }
86
48
 
87
49
  // Check the type of x equal to point or if the type of xAxis is equal to continuous or date
88
- if (config.xAxis.type === 'categorical' || (visualizationType === 'Combo' && orientation !== 'horizontal' && visualizationType !== 'Forest Plot')) {
50
+ if (
51
+ config.xAxis.type === 'categorical' ||
52
+ (visualizationType === 'Combo' && orientation !== 'horizontal' && visualizationType !== 'Forest Plot')
53
+ ) {
89
54
  const range = xScale.range()[1] - xScale.range()[0]
90
55
  const eachBand = range / (xScale.domain().length + 1)
91
56
 
@@ -135,4 +100,4 @@ const findNearestDatum = ({ data, xScale, yScale, config, xMax, annotationSeries
135
100
  return { x, y }
136
101
  }
137
102
 
138
- export { findNearestDatum, getXValueFromCoordinate }
103
+ export { findNearestDatum }
@@ -13,17 +13,21 @@ import { approvedCurveTypes } from '@cdc/core/helpers/lineChartHelpers'
13
13
 
14
14
  const AreaChartStacked = ({ xScale, yScale, yMax, xMax, handleTooltipMouseOver, handleTooltipMouseOff }) => {
15
15
  // import data from context
16
- let { transformedData, config, seriesHighlight, colorScale, rawData } = useContext(ConfigContext)
16
+ let { transformedData, config, seriesHighlight, colorScale, rawData, parseDate } = useContext(ConfigContext)
17
17
  const data = config.brush?.active && config.brush.data?.length ? config.brush.data : transformedData
18
18
  // Draw transparent bars over the chart to get tooltip data
19
19
  // Turn DEBUG on for additional context.
20
20
  if (!data) return
21
21
 
22
22
  const handleDateCategory = value => {
23
- if (config.xAxis.type === 'categorical') return xScale(value)
23
+ if (config.xAxis.type === 'categorical') {
24
+ return xScale(value) + (xScale.bandwidth ? xScale.bandwidth() / 2 : 0)
25
+ }
24
26
  if (isDateScale(config.xAxis)) {
25
- let date = new Date(value)
26
- return xScale(date)
27
+ const scaledValue = xScale(parseDate(value, false))
28
+ // Add bandwidth offset to center on band scales (date type)
29
+ // For date-time (time scale), bandwidth doesn't exist so no offset added
30
+ return scaledValue + (xScale.bandwidth ? xScale.bandwidth() / 2 : 0)
27
31
  }
28
32
  }
29
33
 
@@ -65,7 +69,7 @@ const AreaChartStacked = ({ xScale, yScale, yMax, xMax, handleTooltipMouseOver,
65
69
  key={stack.key}
66
70
  d={path(stack) || ''}
67
71
  strokeWidth={2}
68
- stroke={displayArea ? colorScale ? colorScale(config.runtime.seriesLabels ? config.runtime.seriesLabels[stack.key] : stack.key) : '#000' : 'transparent'}
72
+ stroke={displayArea ? colorScale ? colorScale(config.runtime.seriesLabels ? config.runtime.seriesLabels[stack.key] : stack.key) : '#000' : 'transparent'}
69
73
  fillOpacity={transparentArea ? 0.2 : 1}
70
74
  fill={displayArea ? colorScale ? colorScale(config.runtime.seriesLabels ? config.runtime.seriesLabels[stack.key] : stack.key) : '#000' : 'transparent'}
71
75
  />
@@ -74,7 +78,7 @@ const AreaChartStacked = ({ xScale, yScale, yMax, xMax, handleTooltipMouseOver,
74
78
  }}
75
79
  </AreaStack>
76
80
  {/* prettier-ignore */}
77
- <Bar width={Number(xMax)} height={Number(yMax)} fill={'transparent'} onMouseMove={e => handleTooltipMouseOver(e, rawData)} onMouseLeave={handleTooltipMouseOff} />
81
+ <Bar width={Number(xMax)} height={Number(yMax)} fill={'transparent'} onMouseMove={e => handleTooltipMouseOver(e, rawData)} onMouseLeave={handleTooltipMouseOff} />
78
82
  </Group>
79
83
  </ErrorBoundary>
80
84
  </svg>
@@ -1,4 +1,3 @@
1
- import AreaChart from './components/AreaChart'
2
1
  import AreaChartStacked from './components/AreaChart.Stacked'
3
2
 
4
- export { AreaChart, AreaChartStacked }
3
+ export { AreaChartStacked }