@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/dist/index.css CHANGED
@@ -850,6 +850,10 @@
850
850
  .a8ccharts-gnszbG-pie-chart__label-text {
851
851
  fill: var(--a8c-charts-color-label-inverse, #f0f0f0);
852
852
  }
853
+
854
+ .a8ccharts-gnszbG-pie-chart__label-text--on-light {
855
+ fill: var(--a8c-charts-color-label, #1e1e1e);
856
+ }
853
857
  .a8ccharts-YtTOxW-pie-semi-circle-chart__plot {
854
858
  position: relative;
855
859
  }
package/dist/index.d.cts CHANGED
@@ -1289,6 +1289,11 @@ interface GeoChartProps extends Pick<BaseChartProps, 'className' | 'chartId' | '
1289
1289
  * @default 'countries'
1290
1290
  */
1291
1291
  resolution?: GeoResolution;
1292
+ /**
1293
+ * ISO 3166-1 alpha-2 code of the country whose viewpoint sets the disputed borders
1294
+ * (e.g., 'IN' draws Kashmir as India shows it). Google's default borders apply when omitted.
1295
+ */
1296
+ domain?: string;
1292
1297
  /**
1293
1298
  * Callback fired when Google Charts emits a chart error.
1294
1299
  */
@@ -1714,9 +1719,11 @@ declare const validateHexColor: (hex: unknown) => void;
1714
1719
  */
1715
1720
  declare const hexToRgba: (hex: string, alpha: number) => string;
1716
1721
  /**
1717
- * Calculate the perceptual distance between two HSL colors
1718
- * @param hsl1 - first color in HSL format [h, s, l]
1719
- * @param hsl2 - second color in HSL format [h, s, l]
1722
+ * Weighted Euclidean distance between two HSL colors.
1723
+ *
1724
+ * @deprecated Not perceptual and blind to color vision deficiency, so charts no longer use it; it will be removed in a future major version.
1725
+ * @param hsl1 - first color in HSL format [h, s, l]
1726
+ * @param hsl2 - second color in HSL format [h, s, l]
1720
1727
  * @return distance value (0-100+, lower means more similar)
1721
1728
  */
1722
1729
  declare const getColorDistance: (hsl1: [number, number, number], hsl2: [number, number, number]) => number;
package/dist/index.d.ts CHANGED
@@ -1289,6 +1289,11 @@ interface GeoChartProps extends Pick<BaseChartProps, 'className' | 'chartId' | '
1289
1289
  * @default 'countries'
1290
1290
  */
1291
1291
  resolution?: GeoResolution;
1292
+ /**
1293
+ * ISO 3166-1 alpha-2 code of the country whose viewpoint sets the disputed borders
1294
+ * (e.g., 'IN' draws Kashmir as India shows it). Google's default borders apply when omitted.
1295
+ */
1296
+ domain?: string;
1292
1297
  /**
1293
1298
  * Callback fired when Google Charts emits a chart error.
1294
1299
  */
@@ -1714,9 +1719,11 @@ declare const validateHexColor: (hex: unknown) => void;
1714
1719
  */
1715
1720
  declare const hexToRgba: (hex: string, alpha: number) => string;
1716
1721
  /**
1717
- * Calculate the perceptual distance between two HSL colors
1718
- * @param hsl1 - first color in HSL format [h, s, l]
1719
- * @param hsl2 - second color in HSL format [h, s, l]
1722
+ * Weighted Euclidean distance between two HSL colors.
1723
+ *
1724
+ * @deprecated Not perceptual and blind to color vision deficiency, so charts no longer use it; it will be removed in a future major version.
1725
+ * @param hsl1 - first color in HSL format [h, s, l]
1726
+ * @param hsl2 - second color in HSL format [h, s, l]
1720
1727
  * @return distance value (0-100+, lower means more similar)
1721
1728
  */
1722
1729
  declare const getColorDistance: (hsl1: [number, number, number], hsl2: [number, number, number]) => number;