@automattic/charts 4.4.0 → 4.5.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 (35) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/TOKENS.md +2 -2
  3. package/dist/index.cjs +521 -203
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.css +4 -0
  6. package/dist/index.d.cts +10 -3
  7. package/dist/index.d.ts +10 -3
  8. package/dist/index.js +521 -203
  9. package/dist/index.js.map +1 -1
  10. package/package.json +2 -2
  11. package/src/charts/bar-chart/bar-chart.tsx +22 -10
  12. package/src/charts/bar-chart/private/band-tooltip.tsx +18 -12
  13. package/src/charts/geo-chart/geo-chart.tsx +4 -0
  14. package/src/charts/geo-chart/test/geo-chart.test.tsx +8 -0
  15. package/src/charts/geo-chart/types.ts +5 -0
  16. package/src/charts/heatmap-chart/test/heatmap-chart.test.tsx +1 -1
  17. package/src/charts/pie-chart/pie-chart.module.scss +4 -0
  18. package/src/charts/pie-chart/pie-chart.tsx +103 -7
  19. package/src/charts/pie-chart/test/pie-chart.test.tsx +149 -0
  20. package/src/charts/private/chart-layout/chart-layout.tsx +5 -1
  21. package/src/components/tooltip/accessible-tooltip.tsx +40 -4
  22. package/src/components/tooltip/test/accessible-tooltip.test.tsx +82 -5
  23. package/src/providers/chart-context/global-charts-provider.tsx +57 -41
  24. package/src/providers/chart-context/private/catalog-pointers.ts +9 -1
  25. package/src/providers/chart-context/private/palette-generator.ts +305 -0
  26. package/src/providers/chart-context/private/perceptual-color.ts +219 -0
  27. package/src/providers/chart-context/private/series-palette.ts +1 -1
  28. package/src/providers/chart-context/test/chart-context.test.tsx +88 -8
  29. package/src/providers/chart-context/test/global-charts-provider-first-render.test.tsx +27 -0
  30. package/src/providers/chart-context/test/palette-generator.test.ts +181 -0
  31. package/src/providers/chart-context/test/perceptual-color.test.ts +75 -0
  32. package/src/test-utils/zoned-parsing-suite.ts +1 -1
  33. package/src/utils/color-utils.ts +5 -3
  34. package/src/utils/test/date-formatting.test.ts +1 -1
  35. package/src/providers/chart-context/private/get-chart-color.ts +0 -223
package/CHANGELOG.md CHANGED
@@ -5,6 +5,17 @@ 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.5.0] - 2026-09-28
9
+ ### Added
10
+ - GeoChart: Add a `domain` prop that draws disputed borders from a given country's viewpoint. [#52805]
11
+
12
+ ### Deprecated
13
+ - Deprecate getColorDistance, which is not perceptual and is no longer used to generate palette colors. [#52680]
14
+
15
+ ### Fixed
16
+ - Bar chart: End a keyboard selection when the pointer moves over the chart, instead of flickering between the hovered and selected bars. [#52821]
17
+ - Keep generated series colors distinguishable from each other, including for color-blind viewers, and legible on the chart background; pick pie label text that contrasts with each slice. [#52680]
18
+
8
19
  ## [4.4.0] - 2026-09-23
9
20
  ### Added
10
21
  - Bar chart: Add per-datum bar classes and tooltip box style overrides. [#52547]
@@ -1115,6 +1126,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1115
1126
  - Fixed lints following ESLint rule changes for TS [#40584]
1116
1127
  - Fixing a bug in Chart storybook data. [#40640]
1117
1128
 
1129
+ [4.5.0]: https://github.com/Automattic/charts/compare/v4.4.0...v4.5.0
1118
1130
  [4.4.0]: https://github.com/Automattic/charts/compare/v4.3.0...v4.4.0
1119
1131
  [4.3.0]: https://github.com/Automattic/charts/compare/v4.2.0...v4.3.0
1120
1132
  [4.2.0]: https://github.com/Automattic/charts/compare/v4.1.1...v4.2.0
package/TOKENS.md CHANGED
@@ -41,7 +41,7 @@ Some roles are deliberately narrower than the obvious name, so that moving one t
41
41
 
42
42
  | Narrow role | Broad role | What the broad one also reaches |
43
43
  |---|---|---|
44
- | `--a8c-charts-color-label-axis` | `--a8c-charts-color-label` | legend labels, `.heatmap-chart__cell-value`, funnel labels, the line-chart tooltip |
44
+ | `--a8c-charts-color-label-axis` | `--a8c-charts-color-label` | legend labels, `.heatmap-chart__cell-value`, funnel labels, the line-chart tooltip, pie labels on light slices |
45
45
  | `--a8c-charts-color-background` | — | — |
46
46
 
47
47
  Outside forced-colors mode, `--a8c-charts-color-label-axis` derives from `--a8c-charts-color-label`, so setting the broad role moves every label at once and setting the narrow one moves only the SVG axis labels. See [One pair of roles per axis](#one-pair-of-roles-per-axis) for forced-colors defaults.
@@ -56,7 +56,7 @@ That is what makes the role read **at the painted element** rather than snapshot
56
56
 
57
57
  There is no stylesheet and no class involved. In particular the axes need neither: visx takes a separate style object per axis, so each one is handed its own roles and nothing has to distinguish them after the fact.
58
58
 
59
- What else crosses in JS is what something reads as a *value*: the series palette, which visx turns into its `colorScale`, and the background, which the default glyph, the area-chart band, the line-chart gradient stops, the heatmap's contrast math and `GeoChart` each consume as a concrete string.
59
+ What else crosses in JS is what something reads as a *value*: the series palette, which visx turns into its `colorScale`; the background, which the default glyph, the area-chart band, the line-chart gradient stops, the heatmap's contrast math and `GeoChart` each consume as a concrete string; and, for the pie chart, `label` and `label-inverse` against the resolved slice fill, to pick which one contrasts more before painting the label.
60
60
 
61
61
  **The tooltip used to be the one painted exception, because visx painted it outside the scope.** `@visx/tooltip` appends each portal container straight to `document.body`, where the catalog is not declared, so a chain handed to one reached only its own hardcoded fallback — never the role, never a consumer's override. Charts no longer take that route: the box renders into the chart's own wrapper and the crosshairs and glyphs are drawn into the chart SVG, both inside the scope, so a chain handed to either resolves there natively.
62
62