@automattic/charts 1.11.0 → 2.0.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 (39) hide show
  1. package/CHANGELOG.md +24 -2
  2. package/TOKENS.md +19 -1
  3. package/dist/index.cjs +2196 -2711
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.css +23 -43
  6. package/dist/index.d.cts +72 -6
  7. package/dist/index.d.ts +72 -6
  8. package/dist/index.js +278 -792
  9. package/dist/index.js.map +1 -1
  10. package/package.json +5 -4
  11. package/src/charts/area-chart/area-chart.tsx +31 -10
  12. package/src/charts/area-chart/test/area-chart.test.tsx +102 -0
  13. package/src/charts/area-chart/types.ts +20 -6
  14. package/src/charts/bar-chart/bar-chart.tsx +33 -9
  15. package/src/charts/bar-chart/test/bar-chart.test.tsx +117 -0
  16. package/src/charts/conversion-funnel-chart/conversion-funnel-chart.module.scss +7 -7
  17. package/src/charts/line-chart/line-chart.module.scss +3 -3
  18. package/src/charts/line-chart/line-chart.tsx +43 -7
  19. package/src/charts/line-chart/test/line-chart.test.tsx +234 -5
  20. package/src/charts/line-chart/types.ts +14 -0
  21. package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.module.scss +1 -1
  22. package/src/charts/private/test/time-axis.test.ts +182 -0
  23. package/src/charts/private/time-axis.ts +84 -5
  24. package/src/charts/private/x-zoom/index.ts +1 -0
  25. package/src/charts/private/{test → x-zoom/test}/x-zoom.test.tsx +92 -4
  26. package/src/charts/private/x-zoom/x-zoom.module.scss +35 -0
  27. package/src/charts/private/{x-zoom.tsx → x-zoom/x-zoom.tsx} +44 -27
  28. package/src/components/legend/hooks/test/use-chart-legend-items.test.tsx +152 -0
  29. package/src/components/legend/hooks/use-chart-legend-items.ts +118 -16
  30. package/src/components/legend/private/base-legend.module.scss +1 -1
  31. package/src/components/legend/private/base-legend.tsx +21 -9
  32. package/src/components/legend/test/legend-config-types.test.tsx +32 -0
  33. package/src/components/legend/test/legend.test.tsx +121 -1
  34. package/src/components/legend/types.ts +6 -0
  35. package/src/components/tooltip/base-tooltip.module.scss +1 -1
  36. package/src/components/trend-indicator/trend-indicator.module.scss +1 -1
  37. package/src/index.ts +2 -0
  38. package/src/types.ts +31 -0
  39. package/src/charts/private/x-zoom.module.scss +0 -50
package/CHANGELOG.md CHANGED
@@ -5,12 +5,32 @@ 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
+ ## [2.0.0] - 2026-08-10
9
+ ### Added
10
+ - Time axis: Accept a tickResolution hint on the x-axis options so callers that know the data's bucket size can set tick formats directly instead of relying on inference. [#51017]
11
+
12
+ ### Changed
13
+ - Time axis: Pick tick formats by bucket resolution as well as span — hour ticks (with the date at midnight boundaries) for sub-daily series spanning up to a week, and month ticks (with the year at January) instead of full dates for month-or-coarser buckets. [#51010]
14
+ - Update package dependencies. [#50509]
15
+ - Zoom: Expose the reset button's shadow as `--a8c-charts-elevation-xs`, replacing the `--wpds-elevation-xs` token removed in `@wordpress/theme` 1.0.0. [#50509]
16
+ - Zoom: Restore the accessible tooltip on the reset control. `@wordpress/ui` is no longer bundled into the package output, so each consumer's bundler now resolves it. It remains a dependency and resolves from node_modules by default, but a bundler that externalizes `@wordpress/*` to `window.wp.*` must bundle `@wordpress/ui` instead — `window.wp.ui` does not exist. [#51016]
17
+
18
+ ### Fixed
19
+ - Time axis: Show date ticks rather than hour ticks for a daily-bucket pair spanning exactly one day. [#51013]
20
+
21
+ ## [1.12.0] - 2026-08-03
22
+ ### Added
23
+ - New `legend.collapseGroups` option folds series that share a `group` into a single legend item, labelled by the group's primary series; with `legend.interactive` that item toggles the whole group in one click. Off by default, so legends keep one item per series unless you opt in. Available on the bar, line and area charts. The line chart gains a `rescaleYOnVisibilityChange` prop (matching the area chart) to pin the value axis to the full data range while series are hidden; and when every series is hidden, the grid and axes are dropped so the empty state stands on its own. The area chart's `rescaleYOnLegendToggle` prop is deprecated in favour of `rescaleYOnVisibilityChange` (still honoured as an alias). [#50194]
24
+
25
+ ### Changed
26
+ - Zoom: Render the reset control with the WordPress UI Button, fix keyboard activation, expose the selection rectangle's colors as `--a8c-charts-color-zoom-selection` and `--a8c-charts-color-zoom-selection-stroke`, and document the `zoomable` prop for the line and area charts. [#50796]
27
+
8
28
  ## [1.11.0] - 2026-07-27
9
29
  ### Added
10
- - Charts: add a `fitRows` prop to LeaderboardChart so a chart in a fixed-height container shows only the rows that fit instead of scrolling. [#50688]
30
+ - Add a `fitRows` prop to LeaderboardChart so a chart in a fixed-height container shows only the rows that fit instead of scrolling. [#50688]
11
31
 
12
32
  ### Changed
13
- - Charts: standardise package CSS custom properties on the --a8c-charts-{category}-{name} naming convention and document the token catalog; existing public override variables keep working via deprecated aliases. [#50656]
33
+ - Standardize CSS custom properties on the `--a8c-charts-{category}-{name}` naming convention; existing override variables keep working via deprecated aliases. [#50656]
14
34
 
15
35
  ### Fixed
16
36
  - Leaderboard: Distinguish unavailable percentage changes from missing comparison data. [#50690]
@@ -945,6 +965,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
945
965
  - Fixed lints following ESLint rule changes for TS [#40584]
946
966
  - Fixing a bug in Chart storybook data. [#40640]
947
967
 
968
+ [2.0.0]: https://github.com/Automattic/charts/compare/v1.12.0...v2.0.0
969
+ [1.12.0]: https://github.com/Automattic/charts/compare/v1.11.0...v1.12.0
948
970
  [1.11.0]: https://github.com/Automattic/charts/compare/v1.10.3...v1.11.0
949
971
  [1.10.3]: https://github.com/Automattic/charts/compare/v1.10.2...v1.10.3
950
972
  [1.10.2]: https://github.com/Automattic/charts/compare/v1.10.1...v1.10.2
package/TOKENS.md CHANGED
@@ -49,7 +49,25 @@ Instance styling knobs, on the same convention but not shared semantic roles:
49
49
  `--a8c-charts-border-radius-leaderboard-bar`,
50
50
  `--a8c-charts-dimension-leaderboard-bar-hover-inset`,
51
51
  `--a8c-charts-color-heatmap-*`, `--a8c-charts-dimension-heatmap-*`,
52
- `--a8c-charts-heatmap-cell-intensity`.
52
+ `--a8c-charts-heatmap-cell-intensity`,
53
+ `--a8c-charts-color-zoom-selection`, `--a8c-charts-color-zoom-selection-stroke`,
54
+ `--a8c-charts-elevation-xs`.
55
+
56
+ | Role | Maps to `--wpds-*` | Fallback |
57
+ |---|---|---|
58
+ | `--a8c-charts-color-zoom-selection` | `--wpds-color-background-interactive-brand-strong` | `#3858e9` |
59
+ | `--a8c-charts-color-zoom-selection-stroke` | `--wpds-color-stroke-interactive-brand` | `#3858e9` |
60
+ | `--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` |
61
+
62
+ The zoom selection roles carry the drag-to-zoom rectangle's fill and border. Their
63
+ translucency is not part of the role: it lives in the `fill-opacity` /
64
+ `stroke-opacity` properties, so overriding either role sets an opaque colour and
65
+ keeps the intended transparency.
66
+
67
+ `--a8c-charts-elevation-xs` carries the zoom reset button's shadow. It has no
68
+ `--wpds-*` mapping: `@wordpress/theme` 1.0.0 removed the whole
69
+ `--wpds-elevation-*` group without a replacement, so the fallback holds the value
70
+ `--wpds-elevation-xs` used to resolve to.
53
71
 
54
72
  `--a8c-charts-heatmap-cell-intensity` is the one variable without a `{category}`
55
73
  segment: it holds a unitless 0–1 scalar consumed inside `color-mix()`, not a colour.