@automattic/charts 1.10.3 → 1.12.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.
- package/CHANGELOG.md +19 -0
- package/TOKENS.md +83 -0
- package/dist/index.cjs +894 -139
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +58 -62
- package/dist/index.d.cts +75 -13
- package/dist/index.d.ts +75 -13
- package/dist/index.js +894 -139
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/src/charts/area-chart/area-chart.tsx +28 -8
- package/src/charts/area-chart/test/area-chart.test.tsx +102 -0
- package/src/charts/area-chart/types.ts +20 -6
- package/src/charts/bar-chart/bar-chart.tsx +33 -9
- package/src/charts/bar-chart/test/bar-chart.test.tsx +117 -0
- package/src/charts/conversion-funnel-chart/conversion-funnel-chart.module.scss +7 -7
- package/src/charts/heatmap-chart/heatmap-chart.module.scss +18 -13
- package/src/charts/heatmap-chart/heatmap-chart.tsx +11 -7
- package/src/charts/heatmap-chart/private/heatmap-legend.tsx +3 -3
- package/src/charts/heatmap-chart/test/heatmap-chart.test.tsx +13 -7
- package/src/charts/leaderboard-chart/hooks/index.ts +1 -0
- package/src/charts/leaderboard-chart/hooks/use-fitted-row-count.ts +115 -0
- package/src/charts/leaderboard-chart/leaderboard-chart.module.scss +39 -12
- package/src/charts/leaderboard-chart/leaderboard-chart.tsx +67 -14
- package/src/charts/leaderboard-chart/test/leaderboard-chart-fit-rows.test.tsx +365 -0
- package/src/charts/leaderboard-chart/test/leaderboard-chart.test.tsx +73 -2
- package/src/charts/leaderboard-chart/types.ts +12 -0
- package/src/charts/line-chart/line-chart.module.scss +2 -2
- package/src/charts/line-chart/line-chart.tsx +40 -5
- package/src/charts/line-chart/test/line-chart.test.tsx +190 -1
- package/src/charts/line-chart/types.ts +14 -0
- package/src/charts/private/grid-control/grid-control.module.scss +1 -1
- package/src/charts/private/svg-empty-state/svg-empty-state.module.scss +1 -1
- package/src/charts/private/x-zoom/index.ts +1 -0
- package/src/charts/private/{test → x-zoom/test}/x-zoom.test.tsx +46 -3
- package/src/charts/private/x-zoom/x-zoom.module.scss +43 -0
- package/src/charts/private/{x-zoom.tsx → x-zoom/x-zoom.tsx} +52 -24
- package/src/components/legend/hooks/test/use-chart-legend-items.test.tsx +152 -0
- package/src/components/legend/hooks/use-chart-legend-items.ts +118 -16
- package/src/components/legend/private/base-legend.tsx +21 -9
- package/src/components/legend/test/legend-config-types.test.tsx +32 -0
- package/src/components/legend/test/legend.test.tsx +121 -1
- package/src/components/legend/types.ts +6 -0
- package/src/components/tooltip/base-tooltip.module.scss +3 -2
- package/src/components/trend-indicator/trend-indicator.module.scss +6 -5
- package/src/index.ts +1 -0
- package/src/providers/chart-context/themes.ts +33 -19
- package/src/types.ts +18 -2
- package/src/charts/private/x-zoom.module.scss +0 -48
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,23 @@ 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
|
+
## [1.12.0] - 2026-08-03
|
|
9
|
+
### Added
|
|
10
|
+
- 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]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- 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]
|
|
14
|
+
|
|
15
|
+
## [1.11.0] - 2026-07-27
|
|
16
|
+
### Added
|
|
17
|
+
- Add a `fitRows` prop to LeaderboardChart so a chart in a fixed-height container shows only the rows that fit instead of scrolling. [#50688]
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
- Standardize CSS custom properties on the `--a8c-charts-{category}-{name}` naming convention; existing override variables keep working via deprecated aliases. [#50656]
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
- Leaderboard: Distinguish unavailable percentage changes from missing comparison data. [#50690]
|
|
24
|
+
|
|
8
25
|
## [1.10.3] - 2026-07-22
|
|
9
26
|
### Fixed
|
|
10
27
|
- LeaderboardChart: Keep row spacing and column alignment identical whether or not a row is interactive. [#50657]
|
|
@@ -935,6 +952,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
935
952
|
- Fixed lints following ESLint rule changes for TS [#40584]
|
|
936
953
|
- Fixing a bug in Chart storybook data. [#40640]
|
|
937
954
|
|
|
955
|
+
[1.12.0]: https://github.com/Automattic/charts/compare/v1.11.0...v1.12.0
|
|
956
|
+
[1.11.0]: https://github.com/Automattic/charts/compare/v1.10.3...v1.11.0
|
|
938
957
|
[1.10.3]: https://github.com/Automattic/charts/compare/v1.10.2...v1.10.3
|
|
939
958
|
[1.10.2]: https://github.com/Automattic/charts/compare/v1.10.1...v1.10.2
|
|
940
959
|
[1.10.1]: https://github.com/Automattic/charts/compare/v1.10.0...v1.10.1
|
package/TOKENS.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Charts CSS custom-property catalog
|
|
2
|
+
|
|
3
|
+
`@automattic/charts` exposes its themeable values as CSS custom properties under a
|
|
4
|
+
single convention: `--a8c-charts-{category}-{name}`. `{category}` mirrors the WPDS
|
|
5
|
+
token type (`color`, `dimension`, `border-radius`).
|
|
6
|
+
|
|
7
|
+
## How it resolves today
|
|
8
|
+
|
|
9
|
+
Nothing emits these variables at runtime yet (that is CHARTS-203). Each reference in
|
|
10
|
+
the library carries its default inline as a fallback:
|
|
11
|
+
|
|
12
|
+
```scss
|
|
13
|
+
stroke: var(--a8c-charts-color-grid, var(--wpds-color-stroke-surface-neutral, #dbdbdb));
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
So an `--a8c-charts-*` variable you set on a chart container wins; otherwise the
|
|
17
|
+
mapped `--wpds-*` token wins; otherwise the spec-value hex wins. Setting any
|
|
18
|
+
`--a8c-charts-*` variable on a chart ancestor overrides that role.
|
|
19
|
+
|
|
20
|
+
## Tier 1 — semantic catalog (shared, themeable roles)
|
|
21
|
+
|
|
22
|
+
| Role | Maps to `--wpds-*` | Fallback |
|
|
23
|
+
|---|---|---|
|
|
24
|
+
| `--a8c-charts-color-grid` | `--wpds-color-stroke-surface-neutral` | `#dbdbdb` |
|
|
25
|
+
| `--a8c-charts-color-axis` | `--wpds-color-stroke-surface-neutral` | `#dbdbdb` |
|
|
26
|
+
| `--a8c-charts-color-tick` | `--wpds-color-stroke-surface-neutral` | `#dbdbdb` |
|
|
27
|
+
| `--a8c-charts-color-label` | `--wpds-color-foreground-content-neutral` | `#1e1e1e` |
|
|
28
|
+
| `--a8c-charts-color-label-secondary` | `--wpds-color-foreground-content-neutral-weak` | `#707070` |
|
|
29
|
+
| `--a8c-charts-color-label-inverse` | `--wpds-color-foreground-interactive-neutral-strong` | `#f0f0f0` |
|
|
30
|
+
| `--a8c-charts-color-label-on-fill` | _(none — white-on-series-fill, no WPDS fit)_ | `#FFFFFF` |
|
|
31
|
+
| `--a8c-charts-color-annotation` | `--wpds-color-foreground-content-neutral` | `#1e1e1e` |
|
|
32
|
+
| `--a8c-charts-color-trend-up` | `--wpds-color-foreground-content-success-weak` | `#008030` |
|
|
33
|
+
| `--a8c-charts-color-trend-down` | `--wpds-color-foreground-content-error-weak` | `#cc1818` |
|
|
34
|
+
| `--a8c-charts-color-trend-neutral` | `--wpds-color-foreground-content-neutral-weak` | `#707070` |
|
|
35
|
+
| `--a8c-charts-color-background` | `--wpds-color-background-surface-neutral-strong` | `#fff` |
|
|
36
|
+
| `--a8c-charts-color-surface-secondary` | `--wpds-color-background-surface-neutral-weak` | `#f4f4f4` |
|
|
37
|
+
| `--a8c-charts-color-track` | `--wpds-color-background-track-neutral-weak` | `#f0f0f0` |
|
|
38
|
+
| `--a8c-charts-color-tooltip-surface` | _(none — translucent dark surface, no WPDS fit)_ | `rgba(0,0,0,0.85)` |
|
|
39
|
+
| `--a8c-charts-color-focus` | `--wpds-color-stroke-focus` | `#3858e9` |
|
|
40
|
+
|
|
41
|
+
`--a8c-charts-color-axis` (axis line) and `--a8c-charts-color-tick` (tick marks)
|
|
42
|
+
resolve to the same value as `--a8c-charts-color-grid` by default. They are kept as
|
|
43
|
+
distinct roles so axis, tick marks, and gridlines can be themed independently; each
|
|
44
|
+
maps directly to its own `--wpds-*` token rather than chaining through `grid`.
|
|
45
|
+
|
|
46
|
+
## Tier 2 — component-specific variables
|
|
47
|
+
|
|
48
|
+
Instance styling knobs, on the same convention but not shared semantic roles:
|
|
49
|
+
`--a8c-charts-border-radius-leaderboard-bar`,
|
|
50
|
+
`--a8c-charts-dimension-leaderboard-bar-hover-inset`,
|
|
51
|
+
`--a8c-charts-color-heatmap-*`, `--a8c-charts-dimension-heatmap-*`,
|
|
52
|
+
`--a8c-charts-heatmap-cell-intensity`,
|
|
53
|
+
`--a8c-charts-color-zoom-selection`, `--a8c-charts-color-zoom-selection-stroke`.
|
|
54
|
+
|
|
55
|
+
| Role | Maps to `--wpds-*` | Fallback |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| `--a8c-charts-color-zoom-selection` | `--wpds-color-background-interactive-brand-strong` | `#3858e9` |
|
|
58
|
+
| `--a8c-charts-color-zoom-selection-stroke` | `--wpds-color-stroke-interactive-brand` | `#3858e9` |
|
|
59
|
+
|
|
60
|
+
The zoom selection roles carry the drag-to-zoom rectangle's fill and border. Their
|
|
61
|
+
translucency is not part of the role: it lives in the `fill-opacity` /
|
|
62
|
+
`stroke-opacity` properties, so overriding either role sets an opaque colour and
|
|
63
|
+
keeps the intended transparency.
|
|
64
|
+
|
|
65
|
+
`--a8c-charts-heatmap-cell-intensity` is the one variable without a `{category}`
|
|
66
|
+
segment: it holds a unitless 0–1 scalar consumed inside `color-mix()`, not a colour.
|
|
67
|
+
|
|
68
|
+
The heatmap Tier-2 variables (`--a8c-charts-color-heatmap-*`,
|
|
69
|
+
`--a8c-charts-dimension-heatmap-*`, `--a8c-charts-heatmap-cell-intensity`) are
|
|
70
|
+
**component-emitted** — the chart sets them from JS per render — not consumer
|
|
71
|
+
override points.
|
|
72
|
+
|
|
73
|
+
## Public override variables
|
|
74
|
+
|
|
75
|
+
These are documented, supported override points. Deprecated names still work — they
|
|
76
|
+
are read as an inner fallback behind the new name:
|
|
77
|
+
|
|
78
|
+
| New | Deprecated alias |
|
|
79
|
+
|---|---|
|
|
80
|
+
| `--a8c-charts-color-trend-up` | `--charts-trend-up-color` |
|
|
81
|
+
| `--a8c-charts-color-trend-down` | `--charts-trend-down-color` |
|
|
82
|
+
| `--a8c-charts-color-trend-neutral` | `--charts-trend-neutral-color` |
|
|
83
|
+
| `--a8c-charts-border-radius-leaderboard-bar` | `--a8c--charts--leaderboard--bar--border-radius` |
|