@automattic/charts 4.12.0 → 4.14.0

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 (47) hide show
  1. package/CHANGELOG.md +35 -29
  2. package/TOKENS.md +3 -0
  3. package/dist/index.cjs +733 -2203
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.css +42 -13
  6. package/dist/index.d.cts +41 -125
  7. package/dist/index.d.ts +41 -125
  8. package/dist/index.js +756 -1881
  9. package/dist/index.js.map +1 -1
  10. package/package.json +9 -9
  11. package/src/charts/area-chart/area-chart.tsx +16 -6
  12. package/src/charts/area-chart/test/area-chart.test.tsx +42 -9
  13. package/src/charts/bar-chart/bar-chart.tsx +17 -12
  14. package/src/charts/bar-chart/private/index.ts +1 -1
  15. package/src/charts/bar-chart/private/slot-tooltip-members.tsx +4 -5
  16. package/src/charts/bar-chart/private/use-bar-stops.ts +1 -3
  17. package/src/charts/bar-chart/private/use-overlap-slots.ts +35 -16
  18. package/src/charts/bar-chart/test/bar-chart.test.tsx +115 -0
  19. package/src/charts/conversion-funnel-chart/conversion-funnel-chart.module.scss +24 -11
  20. package/src/charts/conversion-funnel-chart/conversion-funnel-chart.tsx +235 -182
  21. package/src/charts/conversion-funnel-chart/index.ts +2 -0
  22. package/src/charts/conversion-funnel-chart/private/index.ts +1 -0
  23. package/src/charts/conversion-funnel-chart/private/use-funnel-selection.ts +9 -47
  24. package/src/charts/conversion-funnel-chart/private/use-roving-step-focus.ts +83 -0
  25. package/src/charts/conversion-funnel-chart/test/conversion-funnel-chart.test.tsx +312 -92
  26. package/src/charts/conversion-funnel-chart/test/use-funnel-selection.test.ts +23 -188
  27. package/src/charts/conversion-funnel-chart/types.ts +22 -0
  28. package/src/charts/leaderboard-chart/leaderboard-chart.module.scss +42 -2
  29. package/src/charts/leaderboard-chart/leaderboard-chart.tsx +124 -36
  30. package/src/charts/leaderboard-chart/private/resolve-leaderboard-entries.ts +53 -0
  31. package/src/charts/leaderboard-chart/test/leaderboard-chart.test.tsx +88 -0
  32. package/src/charts/leaderboard-chart/test/resolve-leaderboard-entries.test.ts +146 -0
  33. package/src/charts/leaderboard-chart/types.ts +6 -0
  34. package/src/charts/line-chart/line-chart.tsx +10 -8
  35. package/src/charts/line-chart/test/line-chart.test.tsx +75 -0
  36. package/src/components/legend/private/base-legend.tsx +13 -8
  37. package/src/components/legend/test/legend.test.tsx +125 -0
  38. package/src/components/legend/types.ts +9 -1
  39. package/src/components/tooltip/private/at-nearest-date.ts +49 -0
  40. package/src/components/tooltip/private/keyboard-stops.ts +67 -0
  41. package/src/components/tooltip/private/xy-chart-tooltip-overlay.tsx +10 -2
  42. package/src/components/tooltip/test/keyboard-stops.test.ts +36 -0
  43. package/src/components/tooltip/test/xy-chart-tooltip.test.tsx +135 -1
  44. package/src/components/tooltip/xy-chart-tooltip.tsx +8 -12
  45. package/src/index.ts +2 -0
  46. package/src/styles/chart-scope.scss +1 -0
  47. package/src/types.ts +5 -6
package/CHANGELOG.md CHANGED
@@ -5,6 +5,27 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [4.14.0] - 2026-11-02
9
+ ### Added
10
+ - Leaderboard chart: Derive bar shares and percentage change from the values when an entry omits them, and add a `negativeBars` option to draw negative values as empty bars. [#54250]
11
+ - Legend: Let an interactive legend item own its pressed state and toggle handler. [#54328]
12
+
13
+ ### Changed
14
+ - Update package dependencies. [#53869]
15
+
16
+ ### Fixed
17
+ - Leaderboard chart: Inset overlay labels from the inline start, so they keep their padding in right-to-left languages, and expose the label inset as a CSS custom property. [#54192]
18
+
19
+ ## [4.13.0] - 2026-10-28
20
+ ### Added
21
+ - Conversion funnel chart: Add `getTooltipContent` to set what each step's tooltip shows, which screen readers also read, and show the default tooltip's count and conversion rate as labeled lines. [#53637]
22
+ - Leaderboard Chart: Show negative values as bars extending left of a shared zero point. [#53794]
23
+
24
+ ### Fixed
25
+ - Conversion funnel chart: Select a step and show its tooltip when it takes keyboard focus, move between steps with the arrow keys, and have screen readers read the tooltip as the step's description. [#53637]
26
+ - Leaderboard chart: Line the values up on the right edge and the deltas in a column of their own when a comparison is shown, instead of letting a wide delta push its row's value out of line. [#54162]
27
+ - Read every series at the selected or hovered date in tooltips, so series that skip a date no longer pair points from different dates. [#54132]
28
+
8
29
  ## [4.12.0] - 2026-10-26
9
30
  ### Added
10
31
  - Bar chart: Add an overlap layout that draws each group inside the one before it, with comparisons in a slot beside them, and expose its bar colors through a `useBarColors` hook. [#53836]
@@ -27,9 +48,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
27
48
  - Heatmap chart: Lighten the color scale to 2.5:1 contrast at the lowest step and 6:1 at the highest, and keep the two ends apart when the empty-cell color sits far from the background. [#53450]
28
49
  - Heatmap chart: Offset the grid's focus ring by the design system focus width. [#53522]
29
50
  - Legend: Set wrapped rows of a horizontal legend closer together than items on one row, and expose both gaps as CSS variables. [#53704]
30
- - Update package dependencies. [#53004]
31
- - Update package dependencies. [#53678]
32
- - Update package dependencies. [#53806]
51
+ - Update package dependencies. [#53004] [#53678] [#53806]
33
52
 
34
53
  ### Fixed
35
54
  - Conversion funnel chart: Show a focus ring on the focused step bar. [#53522]
@@ -141,8 +160,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
141
160
  - Heatmap chart: Add `tooltipVariant="dark"`, which draws the tooltip on the package's dark tooltip surface, `tooltipStyle` for inline box overrides, and a `variant="bar"` legend that joins the scale steps into one continuous band. [#52368]
142
161
 
143
162
  ### Changed
144
- - Update package dependencies. [#52187]
145
- - Update package dependencies. [#52401]
163
+ - Update package dependencies. [#52187] [#52401]
146
164
 
147
165
  ### Fixed
148
166
  - Bar chart: Align grid lines with axis ticks (explicit or derived). [#52234]
@@ -381,12 +399,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
381
399
 
382
400
  ## [1.4.3] - 2026-05-25
383
401
  ### Changed
384
- - Update dependencies. [#43811]
402
+ - Update dependencies.
385
403
 
386
404
  ## [1.4.2] - 2026-05-21
387
405
  ### Changed
388
- - Update package dependencies. [#48405]
389
- - Update package dependencies. [#49012]
406
+ - Update package dependencies. [#48405] [#49012]
390
407
 
391
408
  ## [1.4.1] - 2026-05-19
392
409
  ### Changed
@@ -403,7 +420,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
403
420
 
404
421
  ## [1.3.1] - 2026-05-11
405
422
  ### Changed
406
- - Update dependencies. [#43811]
423
+ - Update dependencies.
407
424
 
408
425
  ## [1.3.0] - 2026-05-04
409
426
  ### Added
@@ -583,7 +600,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
583
600
 
584
601
  ## [0.54.1] - 2026-01-26
585
602
  ### Changed
586
- - Update dependencies. [#43811]
603
+ - Update dependencies.
587
604
 
588
605
  ## [0.54.0] - 2026-01-21
589
606
  ### Added
@@ -614,8 +631,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
614
631
 
615
632
  ### Changed
616
633
  - Change Geo Chart data format to handle all Google Charts data [#46330]
617
- - Update package dependencies. [#46362]
618
- - Update package dependencies. [#46363]
634
+ - Update package dependencies. [#46362] [#46363]
619
635
 
620
636
  ### Fixed
621
637
  - Charts: Add documentation and API references of animation feature. [#46326]
@@ -748,7 +764,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
748
764
 
749
765
  ## [0.38.2] - 2025-09-22
750
766
  ### Changed
751
- - Update dependencies. [#43811]
767
+ - Update dependencies.
752
768
 
753
769
  ## [0.38.1] - 2025-09-19
754
770
  ### Changed
@@ -1021,16 +1037,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1021
1037
  - Add dynamic chart margin calculation and improve Y-axis tick formatting [#43679]
1022
1038
  - Refactor BarChart to use @visx/xychart [#43677]
1023
1039
  - Update dependencies. [#43068]
1024
- - Update package dependencies. [#43326]
1025
- - Update package dependencies. [#43354]
1026
- - Update package dependencies. [#43398]
1027
- - Update package dependencies. [#43399]
1028
- - Update package dependencies. [#43400]
1029
- - Update package dependencies. [#43516]
1030
- - Update package dependencies. [#43578]
1031
- - Update package dependencies. [#43718]
1032
- - Update package dependencies. [#43734]
1033
- - Update package dependencies. [#43766]
1040
+ - Update package dependencies. [#43326] [#43354] [#43398] [#43399] [#43400] [#43516] [#43578] [#43718] [#43734] [#43766]
1034
1041
 
1035
1042
  ### Removed
1036
1043
  - Removed animation for line and bar charts [#43809]
@@ -1060,8 +1067,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1060
1067
 
1061
1068
  ### Changed
1062
1069
  - Code: First pass of style coding standards. [#42734]
1063
- - Update package dependencies. [#42762]
1064
- - Update package dependencies. [#42809]
1070
+ - Update package dependencies. [#42762] [#42809]
1065
1071
 
1066
1072
  ### Fixed
1067
1073
  - Code: Update stylesheets to use hex instead of named colors. [#42920]
@@ -1077,8 +1083,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1077
1083
  - Introduce Theme seriesLineStyles property [#42530]
1078
1084
 
1079
1085
  ### Changed
1080
- - Update package dependencies. [#42509]
1081
- - Update package dependencies. [#42511]
1086
+ - Update package dependencies. [#42509] [#42511]
1082
1087
 
1083
1088
  ### Fixed
1084
1089
  - Bar chart: fix tickFormat not working issue [#42524]
@@ -1086,8 +1091,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1086
1091
  ## [0.10.0] - 2025-03-17
1087
1092
  ### Changed
1088
1093
  - Bar chart: align options with line chart [#42448]
1089
- - Update package dependencies. [#42163]
1090
- - Update package dependencies. [#42384]
1094
+ - Update package dependencies. [#42163] [#42384]
1091
1095
 
1092
1096
  ## [0.9.0] - 2025-03-02
1093
1097
  ### Added
@@ -1216,6 +1220,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1216
1220
  - Fixed lints following ESLint rule changes for TS [#40584]
1217
1221
  - Fixing a bug in Chart storybook data. [#40640]
1218
1222
 
1223
+ [4.14.0]: https://github.com/Automattic/charts/compare/v4.13.0...v4.14.0
1224
+ [4.13.0]: https://github.com/Automattic/charts/compare/v4.12.0...v4.13.0
1219
1225
  [4.12.0]: https://github.com/Automattic/charts/compare/v4.11.1...v4.12.0
1220
1226
  [4.11.1]: https://github.com/Automattic/charts/compare/v4.11.0...v4.11.1
1221
1227
  [4.11.0]: https://github.com/Automattic/charts/compare/v4.10.0...v4.11.0
package/TOKENS.md CHANGED
@@ -152,6 +152,7 @@ The palette is resolved per provider, so one `ColorCache` and one group-to-color
152
152
  | `--a8c-charts-border-radius-leaderboard-bar` | _(none — pill shape, no WPDS radius fits)_ | `9999px` |
153
153
  | `--a8c-charts-dimension-leaderboard-row-gap` | `--wpds-dimension-gap-md` | `12px` |
154
154
  | `--a8c-charts-dimension-leaderboard-column-gap` | `--wpds-dimension-gap-xs` | `4px` |
155
+ | `--a8c-charts-dimension-leaderboard-label-inset` | `--wpds-dimension-padding-sm` | `8px` |
155
156
  | `--a8c-charts-dimension-legend-column-gap` | `--wpds-dimension-gap-lg` | `16px` |
156
157
  | `--a8c-charts-dimension-legend-row-gap` | `--wpds-dimension-gap-sm` | `8px` |
157
158
  | `--a8c-charts-elevation-xs` | _(none — `--wpds-elevation-*` removed in theme 1.0.0)_ | `0 1px 1px 0 #00000008, 0 1px 2px 0 #00000005, 0 3px 3px 0 #00000005, 0 4px 4px 0 #00000003` |
@@ -161,6 +162,8 @@ The motion pair carries the one-shot reveal a data mark plays on first paint, ac
161
162
 
162
163
  `--a8c-charts-border-radius-bar` rounds the conversion funnel's bars. `--a8c-charts-border-radius-bar-chart` rounds the bars of the bar chart and bar list chart; set it to a radius such as `var(--wpds-border-radius-sm)` to opt in. Bar charts apply it as the CSS `rx` property, so it rounds all four corners of a bar. It resolves in CSS at the bar, so an override set anywhere inside the provider tree applies, the chart's own class included; see [Precedence](#precedence) for overrides above the provider.
163
164
 
165
+ `--a8c-charts-dimension-leaderboard-label-inset` pads an overlay label at its inline start, inside the `--wpds-border-width-focus` every row reserves for its focus ring. Read both to line up content outside the chart, such as a column header, with the row text.
166
+
164
167
  The legend pair spaces the items of a horizontal legend: the column gap between items on one line, and the smaller row gap between lines once the legend wraps.
165
168
 
166
169
  The elevation fallbacks hold the values their removed `--wpds-elevation-*` tokens used to resolve to, until a replacement exists.