@automattic/charts 1.12.0 → 2.0.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.
- package/CHANGELOG.md +26 -0
- package/TOKENS.md +8 -1
- package/dist/index.cjs +2487 -3465
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +15 -18
- package/dist/index.d.cts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +452 -1429
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/charts/area-chart/area-chart.tsx +6 -7
- package/src/charts/bar-chart/bar-chart.tsx +24 -15
- package/src/charts/bar-chart/private/use-bar-chart-options.ts +197 -30
- package/src/charts/bar-chart/test/bar-chart.test.tsx +685 -1
- package/src/charts/conversion-funnel-chart/conversion-funnel-chart.module.scss +7 -7
- package/src/charts/line-chart/line-chart.module.scss +3 -3
- package/src/charts/line-chart/line-chart.tsx +6 -7
- package/src/charts/line-chart/test/line-chart.test.tsx +44 -4
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.module.scss +1 -1
- package/src/charts/private/test/time-axis.test.ts +427 -0
- package/src/charts/private/time-axis.ts +291 -23
- package/src/charts/private/x-zoom/test/x-zoom.test.tsx +52 -7
- package/src/charts/private/x-zoom/x-zoom.module.scss +7 -15
- package/src/charts/private/x-zoom/x-zoom.tsx +29 -40
- package/src/components/legend/private/base-legend.module.scss +1 -1
- package/src/components/legend/test/legend.test.tsx +2 -1
- package/src/components/tooltip/base-tooltip.module.scss +1 -1
- package/src/components/trend-indicator/test/trend-indicator.test.tsx +2 -1
- package/src/components/trend-indicator/trend-indicator.module.scss +1 -1
- package/src/hooks/test/use-chart-margin.test.tsx +60 -0
- package/src/hooks/test/use-xychart-theme-style-reads.test.tsx +83 -0
- package/src/hooks/use-chart-margin.tsx +3 -4
- package/src/hooks/use-xychart-theme.ts +17 -11
- package/src/index.ts +1 -0
- package/src/types.ts +15 -0
- package/src/utils/index.ts +1 -1
- package/src/utils/resolve-css-var.ts +69 -28
- package/src/utils/test/create-css-variable-resolver.test.ts +83 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,30 @@ 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.1] - 2026-08-19
|
|
9
|
+
### Changed
|
|
10
|
+
- Charts: adapt bar chart time-axis tick labels to the data's bucket resolution and time span, support the `tickResolution` hint, and name each bar's bucket in its tooltip. [#51274]
|
|
11
|
+
- Resolve an XY chart theme's color roles from a single computed-style snapshot, and rebuild the theme only when a series color changes rather than on every render. [#51342]
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- Charts: keep a bar chart's time axis on the buckets it actually draws, so a labelled bar, a comparison series, or a series hidden from the legend can no longer strand a tick at the axis origin, and label such a bar by its label in both the axis and the tooltip. [#51343]
|
|
15
|
+
- Charts: keep the year and the day on a bar chart's time axis, which could previously skip the tick that named them, and stop the same label falling on two ticks in a row. [#51339]
|
|
16
|
+
- Charts: measure a horizontal chart's left margin from the labels it will actually draw, so a caller's tick formatter is applied exactly once and time-of-day labels stop reserving room for the string "Invalid Date". [#51272]
|
|
17
|
+
- Charts: stop a bar chart's time axis dropping to a couple of ticks when it reaches for the year, and speed up how it picks them. [#51339]
|
|
18
|
+
|
|
19
|
+
## [2.0.0] - 2026-08-10
|
|
20
|
+
### Added
|
|
21
|
+
- 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]
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
- 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]
|
|
25
|
+
- Update package dependencies. [#50509]
|
|
26
|
+
- 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]
|
|
27
|
+
- 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]
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
- Time axis: Show date ticks rather than hour ticks for a daily-bucket pair spanning exactly one day. [#51013]
|
|
31
|
+
|
|
8
32
|
## [1.12.0] - 2026-08-03
|
|
9
33
|
### Added
|
|
10
34
|
- 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]
|
|
@@ -952,6 +976,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
952
976
|
- Fixed lints following ESLint rule changes for TS [#40584]
|
|
953
977
|
- Fixing a bug in Chart storybook data. [#40640]
|
|
954
978
|
|
|
979
|
+
[2.0.1]: https://github.com/Automattic/charts/compare/v2.0.0...v2.0.1
|
|
980
|
+
[2.0.0]: https://github.com/Automattic/charts/compare/v1.12.0...v2.0.0
|
|
955
981
|
[1.12.0]: https://github.com/Automattic/charts/compare/v1.11.0...v1.12.0
|
|
956
982
|
[1.11.0]: https://github.com/Automattic/charts/compare/v1.10.3...v1.11.0
|
|
957
983
|
[1.10.3]: https://github.com/Automattic/charts/compare/v1.10.2...v1.10.3
|
package/TOKENS.md
CHANGED
|
@@ -50,18 +50,25 @@ Instance styling knobs, on the same convention but not shared semantic roles:
|
|
|
50
50
|
`--a8c-charts-dimension-leaderboard-bar-hover-inset`,
|
|
51
51
|
`--a8c-charts-color-heatmap-*`, `--a8c-charts-dimension-heatmap-*`,
|
|
52
52
|
`--a8c-charts-heatmap-cell-intensity`,
|
|
53
|
-
`--a8c-charts-color-zoom-selection`, `--a8c-charts-color-zoom-selection-stroke
|
|
53
|
+
`--a8c-charts-color-zoom-selection`, `--a8c-charts-color-zoom-selection-stroke`,
|
|
54
|
+
`--a8c-charts-elevation-xs`.
|
|
54
55
|
|
|
55
56
|
| Role | Maps to `--wpds-*` | Fallback |
|
|
56
57
|
|---|---|---|
|
|
57
58
|
| `--a8c-charts-color-zoom-selection` | `--wpds-color-background-interactive-brand-strong` | `#3858e9` |
|
|
58
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` |
|
|
59
61
|
|
|
60
62
|
The zoom selection roles carry the drag-to-zoom rectangle's fill and border. Their
|
|
61
63
|
translucency is not part of the role: it lives in the `fill-opacity` /
|
|
62
64
|
`stroke-opacity` properties, so overriding either role sets an opaque colour and
|
|
63
65
|
keeps the intended transparency.
|
|
64
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.
|
|
71
|
+
|
|
65
72
|
`--a8c-charts-heatmap-cell-intensity` is the one variable without a `{category}`
|
|
66
73
|
segment: it holds a unitless 0–1 scalar consumed inside `color-mix()`, not a colour.
|
|
67
74
|
|