@automattic/charts 3.1.0 → 3.2.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 (41) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/TOKENS.md +51 -12
  3. package/dist/index.cjs +307 -213
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.css +7 -1
  6. package/dist/index.d.cts +223 -127
  7. package/dist/index.d.ts +223 -127
  8. package/dist/index.js +306 -212
  9. package/dist/index.js.map +1 -1
  10. package/package.json +8 -8
  11. package/src/charts/area-chart/area-chart.tsx +2 -2
  12. package/src/charts/area-chart/test/area-chart.test.tsx +45 -0
  13. package/src/charts/bar-chart/bar-chart.tsx +36 -10
  14. package/src/charts/bar-chart/private/use-bar-chart-options.ts +19 -12
  15. package/src/charts/bar-chart/test/bar-chart-pointer-events.test.tsx +67 -0
  16. package/src/charts/bar-chart/test/bar-chart.test.tsx +101 -0
  17. package/src/charts/bar-list-chart/bar-list-chart.tsx +40 -2
  18. package/src/charts/bar-list-chart/test/bar-list-chart.test.tsx +38 -0
  19. package/src/charts/line-chart/line-chart.tsx +18 -3
  20. package/src/charts/line-chart/test/line-chart.test.tsx +98 -0
  21. package/src/charts/sparkline/sparkline.tsx +9 -3
  22. package/src/charts/sparkline/types.ts +1 -1
  23. package/src/components/tooltip/accessible-tooltip.tsx +32 -2
  24. package/src/components/tooltip/test/accessible-tooltip.test.tsx +68 -0
  25. package/src/hooks/test/use-xychart-theme-provider-override.test.tsx +4 -4
  26. package/src/hooks/test/use-xychart-theme-style-reads.test.tsx +17 -10
  27. package/src/hooks/test/use-xychart-theme.test.tsx +50 -5
  28. package/src/hooks/use-xychart-theme.ts +14 -20
  29. package/src/providers/chart-context/global-charts-provider.tsx +44 -33
  30. package/src/providers/chart-context/private/series-palette.ts +45 -0
  31. package/src/providers/chart-context/private/theme-override-vars.ts +46 -2
  32. package/src/providers/chart-context/private/with-catalog-pointers.ts +45 -2
  33. package/src/providers/chart-context/test/sparse-theme.test.ts +16 -2
  34. package/src/providers/chart-context/test/theme-override-vars.test.ts +65 -0
  35. package/src/providers/chart-context/test/use-global-charts-theme.test.tsx +8 -1
  36. package/src/providers/chart-context/test/with-catalog-pointers.test.ts +57 -0
  37. package/src/providers/chart-context/themes.ts +8 -3
  38. package/src/styles/chart-scope.scss +52 -24
  39. package/src/styles/test/chart-scope.test.ts +22 -9
  40. package/src/types.ts +148 -31
  41. package/src/utils/get-styles.ts +7 -1
package/dist/index.js CHANGED
@@ -45,7 +45,7 @@ var __copyProps = (to, from, except, desc) => {
45
45
  }
46
46
  return to;
47
47
  };
48
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
48
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
49
49
  value: mod,
50
50
  enumerable: true
51
51
  }) : target, mod));
@@ -250,7 +250,8 @@ const formatPercentage = (value) => {
250
250
  */
251
251
  const getLongestTickWidth = (ticks, formatTick, labelStyle) => {
252
252
  const formattedTicks = ticks.map((tick) => formatTick(tick, 0, []));
253
- return getStringWidth(formattedTicks.reduce((longest, current) => longest.length >= current.length ? longest : current, formattedTicks[0]), labelStyle);
253
+ const longestTick = formattedTicks.reduce((longest, current) => longest.length >= current.length ? longest : current, formattedTicks[0]);
254
+ return getStringWidth(longestTick, labelStyle);
254
255
  };
255
256
  //#endregion
256
257
  //#region src/utils/get-styles.ts
@@ -760,6 +761,16 @@ const getChartColor = (index, colorCache) => {
760
761
  const fallbackLightness = BASE_LIGHTNESS + index % LIGHTNESS_VARIATION_STEPS * LIGHTNESS_INCREMENT;
761
762
  return hsl(Math.round(fallbackHue), fallbackSaturation / 100, fallbackLightness / 100).formatHex();
762
763
  };
764
+ /**
765
+ * The catalog role holding one series-palette slot.
766
+ *
767
+ * @param slot - The one-based slot number.
768
+ * @return The role name.
769
+ */
770
+ const seriesRole = (slot) => `--a8c-charts-color-series-${slot}`;
771
+ const SERIES_SLOT_1_FALLBACK = "#3858e9";
772
+ /** The catalog pointer for every slot, in slot order. */
773
+ const SERIES_PALETTE_POINTERS = Array.from({ length: 5 }, (_, index) => index === 0 ? `var(${seriesRole(1)}, ${SERIES_SLOT_1_FALLBACK})` : `var(${seriesRole(index + 1)})`);
763
774
  //#endregion
764
775
  //#region src/providers/chart-context/private/theme-override-vars.ts
765
776
  const ROLE_FOR_FIELD = [
@@ -767,8 +778,22 @@ const ROLE_FOR_FIELD = [
767
778
  ["--a8c-charts-color-grid", (theme) => theme.gridStyles?.stroke],
768
779
  ["--a8c-charts-color-axis", (theme) => theme.xAxisLineStyles?.stroke],
769
780
  ["--a8c-charts-color-tick", (theme) => theme.xTickLineStyles?.stroke],
770
- ["--a8c-charts-color-label-axis", (theme) => theme.svgLabelSmall?.fill]
781
+ ["--a8c-charts-color-label-axis", (theme) => theme.svgLabelSmall?.fill],
782
+ ["--a8c-charts-color-label-background", (theme) => theme.labelBackgroundColor],
783
+ ["--a8c-charts-color-label-on-fill", (theme) => theme.labelTextColor],
784
+ ...Array.from({ length: 5 }, (_, index) => [seriesRole(index + 1), (theme) => theme.colors?.[index]])
771
785
  ];
786
+ let warnedAboutExtraColors = false;
787
+ /**
788
+ * Warns once when a consumer passes more colors than there are slots to publish them into.
789
+ *
790
+ * @param count - How many entries `theme.colors` holds.
791
+ */
792
+ function warnOnceAboutExtraColors(count) {
793
+ if (warnedAboutExtraColors || process.env.NODE_ENV === "production") return;
794
+ warnedAboutExtraColors = true;
795
+ console.warn(`[Charts] theme.colors holds ${count} colors and the palette has 5 slots, so entries past the 5th are ignored. Set a per-series color with \`options.stroke\` instead.`);
796
+ }
772
797
  /**
773
798
  * The variable a `theme` prop override is published as, one layer outside the role itself.
774
799
  *
@@ -782,7 +807,7 @@ ROLE_FOR_FIELD.map(([role]) => role);
782
807
  /**
783
808
  * Whether a value reads the role it is being published for, which would make the catalog entry depend on itself.
784
809
  *
785
- * The dependency runs `<role>: var(<role>-theme, …)`, so a value naming `<role>` closes a cycle through the catalog entry. CSS marks every custom property in a cycle invalid at computed-value time — the role's own fallback is *not* used, so the token resolves to nothing and every chart loses that colour. Verified in Chrome: `--role-theme: var(--role, blue); --role: var(--role-theme, green)` leaves `--role` empty, not `green`.
810
+ * The dependency runs `<role>: var(<role>-theme, …)`, so a value naming `<role>` closes a cycle through the catalog entry. CSS marks every custom property in a cycle invalid at computed-value time — the role's own fallback is *not* used, so the token resolves to nothing and every chart loses that color. Verified in Chrome: `--role-theme: var(--role, blue); --role: var(--role-theme, green)` leaves `--role` empty, not `green`.
786
811
  *
787
812
  * Three things this has to get right, none of which a plain substring test gets:
788
813
  *
@@ -798,10 +823,12 @@ ROLE_FOR_FIELD.map(([role]) => role);
798
823
  */
799
824
  const readsOwnRole = (value, role) => value.trim() === role || new RegExp(`var\\(\\s*${role.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\\w-])`).test(value);
800
825
  /**
801
- * Maps a sparse consumer theme onto the theme-layer variables its overridden catalog roles read, so CSS-painted and JS-resolved colours read one source.
826
+ * Maps a sparse consumer theme onto the theme-layer variables its overridden catalog roles read, so CSS-painted and JS-resolved colors read one source.
802
827
  *
803
828
  * A value that reads the role it would override is left unpublished — that is the default theme's own pointer surviving `mergeThemes`, and publishing it would invalidate the role. The role is still reported in `roles`: `withCatalogPointers` restores its theme field to the catalog pointer either way, so CSS and visx agree on the catalog default rather than visx painting a literal CSS never sees.
804
829
  *
830
+ * `theme.colors` publishes through the same mechanism, one slot per entry, so a CSS declaration of `--a8c-charts-color-series-N` still beats it and a short array leaves the later slots unset rather than blank.
831
+ *
805
832
  * @param theme - The consumer's `theme` prop, before merging with the default theme.
806
833
  * @return The wrapper's custom properties, and the roles the consumer overrode.
807
834
  */
@@ -810,6 +837,7 @@ const themeOverrideVars = (theme) => {
810
837
  vars: {},
811
838
  roles: []
812
839
  };
840
+ if (Array.isArray(theme.colors) && theme.colors.length > 5) warnOnceAboutExtraColors(theme.colors.length);
813
841
  const vars = {};
814
842
  const roles = [];
815
843
  for (const [role, read] of ROLE_FOR_FIELD) {
@@ -830,15 +858,9 @@ const themeOverrideVars = (theme) => {
830
858
  */
831
859
  const defaultTheme = {
832
860
  backgroundColor: "var(--a8c-charts-color-background, #fff)",
833
- labelBackgroundColor: "transparent",
861
+ labelBackgroundColor: "var(--a8c-charts-color-label-background, transparent)",
834
862
  labelTextColor: "var(--a8c-charts-color-label-on-fill, #FFFFFF)",
835
- colors: [
836
- "#98C8DF",
837
- "#006DAB",
838
- "#A6DC80",
839
- "#1F9828",
840
- "#FF8C8F"
841
- ],
863
+ colors: [...SERIES_PALETTE_POINTERS],
842
864
  gridStyles: {
843
865
  stroke: "var(--a8c-charts-color-grid, #dbdbdb)",
844
866
  strokeWidth: 1
@@ -918,7 +940,23 @@ const defaultTheme = {
918
940
  };
919
941
  //#endregion
920
942
  //#region src/providers/chart-context/private/with-catalog-pointers.ts
943
+ /**
944
+ * The pointer one palette slot is restored to.
945
+ *
946
+ * Unlike the other roles, this keeps the consumer's own color as the pointer's terminal literal instead of the catalog's. The literal is only ever reached where `getComputedStyle` resolves nothing — SSR and jsdom — and there the palette is the one field where falling back to the catalog default would be visible: every series would paint the same seeded blue. In a browser the slot resolves first, so a CSS declaration of it still outranks the consumer's `theme.colors`.
947
+ *
948
+ * @param index - The slot's zero-based index in `colors`.
949
+ * @param value - The merged theme's entry for it.
950
+ * @return The catalog pointer for that slot.
951
+ */
952
+ const seriesPointer = (index, value) => {
953
+ const role = seriesRole(index + 1);
954
+ if (typeof value === "string" && value.startsWith(`var(${role}`)) return value;
955
+ if (typeof value !== "string" || value === "") return SERIES_PALETTE_POINTERS[index];
956
+ return `var(${role}, ${value})`;
957
+ };
921
958
  const CATALOG_RESTORE_FOR_ROLE = {
959
+ ...Object.fromEntries(Array.from({ length: 5 }, (_, index) => [seriesRole(index + 1), (theme) => ({ colors: SERIES_PALETTE_POINTERS.map((_pointer, slot) => seriesPointer(slot, theme.colors?.[slot])) })])),
922
960
  "--a8c-charts-color-background": () => ({ backgroundColor: defaultTheme.backgroundColor }),
923
961
  "--a8c-charts-color-grid": (theme) => ({ gridStyles: {
924
962
  ...theme.gridStyles,
@@ -935,14 +973,16 @@ const CATALOG_RESTORE_FOR_ROLE = {
935
973
  "--a8c-charts-color-label-axis": (theme) => ({ svgLabelSmall: {
936
974
  ...theme.svgLabelSmall,
937
975
  fill: defaultTheme.svgLabelSmall.fill
938
- } })
976
+ } }),
977
+ "--a8c-charts-color-label-background": () => ({ labelBackgroundColor: defaultTheme.labelBackgroundColor }),
978
+ "--a8c-charts-color-label-on-fill": () => ({ labelTextColor: defaultTheme.labelTextColor })
939
979
  };
940
980
  /**
941
981
  * Restores the mapped theme fields of `overriddenRoles` to their catalog pointer, so the theme-layer variable `themeOverrideVars` writes on the provider wrapper is the only carrier for an overridden role — CSS and the JS bridge (`useXYChartTheme`) then resolve it through the same cascade instead of visx reading a baked literal that can disagree with a closer CSS override.
942
982
  *
943
983
  * This covers roles `themeOverrideVars` deliberately left unpublished as well as the ones it published. A value that reads its own role is not publishable, but leaving visx the consumer's literal is what the whole mechanism exists to prevent: `theme={ { gridStyles: { stroke: 'var(--brand, var(--a8c-charts-color-grid, red))' } } }` would have CSS paint the catalog default while visx painted `--brand`.
944
984
  *
945
- * Every field outside the five mapped roles is left exactly as `merged` provided it: those aren't published as theme-layer vars, so rewriting them would erase a consumer's override with no replacement carrier.
985
+ * Every field outside the mapped roles is left exactly as `merged` provided it: those aren't published as theme-layer vars, so rewriting them would erase a consumer's override with no replacement carrier.
946
986
  *
947
987
  * @param merged - The consumer theme merged onto `defaultTheme` (`mergeThemes` output).
948
988
  * @param overriddenRoles - The catalog roles the consumer overrode, from `themeOverrideVars`.
@@ -987,29 +1027,26 @@ const GlobalChartsProvider = ({ children, theme }) => {
987
1027
  const [isColorPaletteResolved, setIsColorPaletteResolved] = useState(false);
988
1028
  useLayoutEffect(() => {
989
1029
  setIsColorPaletteResolved(false);
990
- const { colors } = providerTheme;
991
1030
  const resolvedColors = [];
992
1031
  const hues = [];
993
1032
  const existingHslColors = [];
994
1033
  let minHue = 360;
995
1034
  let maxHue = 0;
996
- if (Array.isArray(colors)) {
997
- for (const color of colors) if (color && typeof color === "string") {
998
- const normalizedColor = normalizeColorToHex(color, wrapperRef.current, resolveCssVariable);
999
- if (normalizedColor.startsWith("#")) {
1000
- resolvedColors.push(normalizedColor);
1001
- const hslColor = hsl(normalizedColor);
1002
- if (!isNaN(hslColor.h)) {
1003
- const hslTuple = [
1004
- hslColor.h,
1005
- hslColor.s * 100,
1006
- hslColor.l * 100
1007
- ];
1008
- hues.push(hslTuple[0]);
1009
- existingHslColors.push(hslTuple);
1010
- minHue = Math.min(minHue, hslTuple[0]);
1011
- maxHue = Math.max(maxHue, hslTuple[0]);
1012
- }
1035
+ for (const color of providerTheme.colors ?? SERIES_PALETTE_POINTERS) {
1036
+ const normalizedColor = normalizeColorToHex(color, wrapperRef.current, resolveCssVariable);
1037
+ if (normalizedColor.startsWith("#")) {
1038
+ resolvedColors.push(normalizedColor);
1039
+ const hslColor = hsl(normalizedColor);
1040
+ if (!isNaN(hslColor.h)) {
1041
+ const hslTuple = [
1042
+ hslColor.h,
1043
+ hslColor.s * 100,
1044
+ hslColor.l * 100
1045
+ ];
1046
+ hues.push(hslTuple[0]);
1047
+ existingHslColors.push(hslTuple);
1048
+ minHue = Math.min(minHue, hslTuple[0]);
1049
+ maxHue = Math.max(maxHue, hslTuple[0]);
1013
1050
  }
1014
1051
  }
1015
1052
  }
@@ -1025,9 +1062,10 @@ const GlobalChartsProvider = ({ children, theme }) => {
1025
1062
  if (colorCache.colors.length > 0) setIsColorPaletteResolved(true);
1026
1063
  }, [colorCache]);
1027
1064
  const [groupToColorMap, setGroupToColorMap] = useState(() => /* @__PURE__ */ new Map());
1065
+ const paletteKey = colorCache.colors.join(",");
1028
1066
  useEffect(() => {
1029
1067
  setGroupToColorMap(/* @__PURE__ */ new Map());
1030
- }, [providerTheme.colors]);
1068
+ }, [paletteKey]);
1031
1069
  const registerChart = useCallback((id, data) => {
1032
1070
  setCharts((prev) => new Map(prev).set(id, data));
1033
1071
  }, []);
@@ -1240,27 +1278,13 @@ const useXYChartTheme = (data) => {
1240
1278
  return useMemo(() => {
1241
1279
  const resolve = createCssVariableResolver(scopeElement);
1242
1280
  const resolveColor = (value) => value ? resolve(value) ?? value : value;
1243
- const seriesColors = JSON.parse(seriesColorKey);
1281
+ const paletteColors = [...JSON.parse(seriesColorKey), ...theme.colors ?? []].map((color) => resolveColor(color)).filter((color) => Boolean(color) && !color.includes("var("));
1282
+ const htmlLabelColor = resolveColor(theme.svgLabelSmall?.fill);
1244
1283
  return buildChartTheme({
1245
1284
  ...theme,
1246
- colors: [...seriesColors, ...theme.colors ?? []],
1285
+ colors: paletteColors,
1247
1286
  backgroundColor: resolveColor(theme.backgroundColor),
1248
- gridStyles: theme.gridStyles && {
1249
- ...theme.gridStyles,
1250
- stroke: resolveColor(theme.gridStyles.stroke)
1251
- },
1252
- xAxisLineStyles: theme.xAxisLineStyles && {
1253
- ...theme.xAxisLineStyles,
1254
- stroke: resolveColor(theme.xAxisLineStyles.stroke)
1255
- },
1256
- xTickLineStyles: theme.xTickLineStyles && {
1257
- ...theme.xTickLineStyles,
1258
- stroke: resolveColor(theme.xTickLineStyles.stroke)
1259
- },
1260
- svgLabelSmall: theme.svgLabelSmall && {
1261
- ...theme.svgLabelSmall,
1262
- fill: resolveColor(theme.svgLabelSmall.fill)
1263
- }
1287
+ htmlLabel: htmlLabelColor ? { color: htmlLabelColor } : void 0
1264
1288
  });
1265
1289
  }, [
1266
1290
  theme,
@@ -1357,11 +1381,12 @@ const useChartMargin = (height, options, data, theme, horizontal = false) => {
1357
1381
  if (options.axis?.y?.tickValues?.length) return options.axis.y.tickValues;
1358
1382
  const minY = Math.min(...allDataPoints.map((d) => d.value));
1359
1383
  const maxY = Math.max(...allDataPoints.map((d) => d.value));
1360
- return getTicks(createScale({
1384
+ const yScale = createScale({
1361
1385
  ...options.yScale,
1362
1386
  domain: [minY, maxY],
1363
1387
  range: [height, 0]
1364
- }), options.axis?.y?.numTicks);
1388
+ });
1389
+ return getTicks(yScale, options.axis?.y?.numTicks);
1365
1390
  }, [
1366
1391
  options,
1367
1392
  data,
@@ -1486,7 +1511,7 @@ const MIN_PIXEL_SIZE = 3;
1486
1511
  /**
1487
1512
  * Pixel size for zero-value bars (1px less than near-zero to be visually distinguishable).
1488
1513
  */
1489
- const ZERO_PIXEL_SIZE = MIN_PIXEL_SIZE - 1;
1514
+ const ZERO_PIXEL_SIZE = 2;
1490
1515
  const useZeroValueDisplay = (data, options = { enabled: false }) => {
1491
1516
  const { enabled, valueAxisLength } = options;
1492
1517
  return useMemo(() => {
@@ -2102,8 +2127,14 @@ const BaseTooltip = ({ data, top, left, component: Component = DefaultTooltipCon
2102
2127
  };
2103
2128
  //#endregion
2104
2129
  //#region src/components/tooltip/accessible-tooltip.tsx
2105
- const AccessibleTooltip = ({ renderTooltip, selectedIndex, tooltipRef, keyboardFocusedClassName, series = [], mode = "group", ...props }) => {
2130
+ const AccessibleTooltip = ({ renderTooltip, selectedIndex, tooltipRef, keyboardFocusedClassName, series = [], mode = "group", verticalCrosshairStyle, horizontalCrosshairStyle, ...props }) => {
2106
2131
  const tooltipContext = useContext(TooltipContext);
2132
+ const scopeElement = useChartScopeElement();
2133
+ const gridStroke = useGlobalChartsTheme().gridStyles?.stroke;
2134
+ const crosshairStroke = useMemo(() => {
2135
+ const stroke = gridStroke ? resolveCssVariable(gridStroke, scopeElement) : null;
2136
+ return stroke ? { stroke } : void 0;
2137
+ }, [gridStroke, scopeElement]);
2107
2138
  const tooltipData = useMemo(() => {
2108
2139
  if (mode !== "individual") return [];
2109
2140
  if (series.length === 0) return [];
@@ -2182,10 +2213,18 @@ const AccessibleTooltip = ({ renderTooltip, selectedIndex, tooltipRef, keyboardF
2182
2213
  ]);
2183
2214
  return /* @__PURE__ */ jsx(Tooltip, {
2184
2215
  ...props,
2216
+ verticalCrosshairStyle: {
2217
+ ...crosshairStroke,
2218
+ ...verticalCrosshairStyle
2219
+ },
2220
+ horizontalCrosshairStyle: {
2221
+ ...crosshairStroke,
2222
+ ...horizontalCrosshairStyle
2223
+ },
2185
2224
  renderTooltip: focusableRenderTooltip
2186
2225
  });
2187
2226
  };
2188
- const useKeyboardNavigation = ({ selectedIndex, setSelectedIndex, isNavigating, setIsNavigating, chartRef, totalPoints }) => {
2227
+ const useKeyboardNavigation = ({ selectedIndex, setSelectedIndex, isNavigating, setIsNavigating, chartRef, totalPoints, onActivate }) => {
2189
2228
  return {
2190
2229
  tooltipRef: useCallback((element) => {
2191
2230
  if (element && selectedIndex !== void 0) element.focus();
@@ -2226,13 +2265,14 @@ const useKeyboardNavigation = ({ selectedIndex, setSelectedIndex, isNavigating,
2226
2265
  setSelectedIndex(void 0);
2227
2266
  setIsNavigating(false);
2228
2267
  chartRef.current?.focus();
2229
- }
2268
+ } else if ((event.key === "Enter" || event.key === " ") && selectedIndex !== void 0) onActivate?.(selectedIndex);
2230
2269
  }, [
2231
2270
  totalPoints,
2232
2271
  selectedIndex,
2233
2272
  setSelectedIndex,
2234
2273
  setIsNavigating,
2235
- chartRef
2274
+ chartRef,
2275
+ onActivate
2236
2276
  ])
2237
2277
  };
2238
2278
  };
@@ -2999,7 +3039,7 @@ const LineChartAnnotationLabelWithPopover = ({ title, subtitle, renderLabel, ren
2999
3039
  style: {
3000
3040
  width: `44px`,
3001
3041
  height: `44px`,
3002
- transform: `translate(${44 / 2}px, 0)`
3042
+ transform: `translate(22px, 0)`
3003
3043
  },
3004
3044
  "aria-label": title || __("View details", "jetpack-charts"),
3005
3045
  children: renderLabel({
@@ -3420,7 +3460,7 @@ const LineChartScalesRef = ({ chartRef, width, height, margin }) => {
3420
3460
  ]);
3421
3461
  return null;
3422
3462
  };
3423
- const LineChartInternal = forwardRef(({ data, chartId: providedChartId, width, height, className, margin, withTooltips = true, withTooltipCrosshairs, showLegend = false, legend = {}, renderGlyph = defaultRenderGlyph, glyphStyle = {}, withLegendGlyph = false, withGradientFill = false, smoothing = true, curveType, renderTooltip = renderDefaultTooltip, withStartGlyphs = false, withEndGlyphs = false, animation, options = {}, onPointerDown = void 0, onPointerUp = void 0, onPointerMove = void 0, onPointerOut = void 0, zoomable = false, rescaleYOnVisibilityChange = true, defaultHiddenSeries, children, gridVisibility, gap = "md" }, ref) => {
3463
+ const LineChartInternal = forwardRef(({ data, chartId: providedChartId, width, height, className, margin, withTooltips = true, withTooltipCrosshairs, showLegend = false, legend = {}, renderGlyph = defaultRenderGlyph, glyphStyle = {}, withLegendGlyph = false, withGradientFill = false, smoothing = true, curveType, renderTooltip = renderDefaultTooltip, withStartGlyphs = false, withEndGlyphs = false, animation, options = {}, onPointerDown = void 0, onPointerUp = void 0, onPointerMove = void 0, onPointerOut = void 0, onDatumActivate = void 0, zoomable = false, rescaleYOnVisibilityChange = true, defaultHiddenSeries, children, gridVisibility, gap = "md" }, ref) => {
3424
3464
  const legendInteractive = legend.interactive ?? false;
3425
3465
  const legendCollapseGroups = legend.collapseGroups ?? false;
3426
3466
  const legendShape = legend.shape ?? "line";
@@ -3482,17 +3522,27 @@ const LineChartInternal = forwardRef(({ data, chartId: providedChartId, width, h
3482
3522
  }
3483
3523
  return min < max ? [min, max] : void 0;
3484
3524
  }, [rescaleYOnVisibilityChange, dataSorted]);
3525
+ const activateSelectedPoint = useCallback((index) => {
3526
+ const series = dataSorted[0];
3527
+ const datum = series?.data[index];
3528
+ if (series && datum) onDatumActivate?.({
3529
+ datum,
3530
+ index,
3531
+ key: series.label
3532
+ });
3533
+ }, [dataSorted, onDatumActivate]);
3485
3534
  const { tooltipRef, onChartFocus, onChartBlur, onChartKeyDown } = useKeyboardNavigation({
3486
3535
  selectedIndex,
3487
3536
  setSelectedIndex,
3488
3537
  isNavigating,
3489
3538
  setIsNavigating,
3490
3539
  chartRef,
3491
- totalPoints: dataSorted[0]?.data.length || 0
3540
+ totalPoints: dataSorted[0]?.data.length || 0,
3541
+ onActivate: activateSelectedPoint
3492
3542
  });
3493
3543
  const chartOptions = useMemo(() => {
3494
- const { tickResolution, ...xAxisOptions } = options?.axis?.x ?? {};
3495
- const formatter = xAxisOptions.tickFormat || getFormatter(dataSorted, tickResolution);
3544
+ const { tickResolution, tickFormat, ...xAxisOptions } = options?.axis?.x ?? {};
3545
+ const formatter = tickFormat || getFormatter(dataSorted, tickResolution);
3496
3546
  return {
3497
3547
  axis: {
3498
3548
  x: {
@@ -3552,36 +3602,38 @@ const LineChartInternal = forwardRef(({ data, chartId: providedChartId, width, h
3552
3602
  const defaultMargin = useChartMargin(height, chartOptions, dataSorted, theme);
3553
3603
  const error = validateData$4(dataSorted);
3554
3604
  const isDataValid = !error;
3605
+ const legendItems = useChartLegendItems(dataSorted, useMemo(() => ({
3606
+ withGlyph: withLegendGlyph,
3607
+ glyphSize: Math.max(0, toNumber(glyphStyle?.radius) ?? 4),
3608
+ collapseGroups: legendCollapseGroups,
3609
+ renderGlyph
3610
+ }), [
3611
+ withLegendGlyph,
3612
+ glyphStyle?.radius,
3613
+ legendCollapseGroups,
3614
+ renderGlyph
3615
+ ]), legendShape);
3616
+ const chartMetadata = useMemo(() => ({
3617
+ withGradientFill,
3618
+ smoothing,
3619
+ curveType,
3620
+ withStartGlyphs,
3621
+ withEndGlyphs,
3622
+ withLegendGlyph
3623
+ }), [
3624
+ withGradientFill,
3625
+ smoothing,
3626
+ curveType,
3627
+ withStartGlyphs,
3628
+ withEndGlyphs,
3629
+ withLegendGlyph
3630
+ ]);
3555
3631
  useChartRegistration({
3556
3632
  chartId,
3557
- legendItems: useChartLegendItems(dataSorted, useMemo(() => ({
3558
- withGlyph: withLegendGlyph,
3559
- glyphSize: Math.max(0, toNumber(glyphStyle?.radius) ?? 4),
3560
- collapseGroups: legendCollapseGroups,
3561
- renderGlyph
3562
- }), [
3563
- withLegendGlyph,
3564
- glyphStyle?.radius,
3565
- legendCollapseGroups,
3566
- renderGlyph
3567
- ]), legendShape),
3633
+ legendItems,
3568
3634
  chartType: "line",
3569
3635
  isDataValid,
3570
- metadata: useMemo(() => ({
3571
- withGradientFill,
3572
- smoothing,
3573
- curveType,
3574
- withStartGlyphs,
3575
- withEndGlyphs,
3576
- withLegendGlyph
3577
- }), [
3578
- withGradientFill,
3579
- smoothing,
3580
- curveType,
3581
- withStartGlyphs,
3582
- withEndGlyphs,
3583
- withLegendGlyph
3584
- ])
3636
+ metadata: chartMetadata
3585
3637
  });
3586
3638
  const prefersReducedMotion = usePrefersReducedMotion();
3587
3639
  const accessors = {
@@ -3958,8 +4010,8 @@ const AreaChartInternal = forwardRef(({ data, chartId: providedChartId, width, h
3958
4010
  rescaleYOnVisibility
3959
4011
  ]);
3960
4012
  const chartOptions = useMemo(() => {
3961
- const { tickResolution, ...xAxisOptions } = options?.axis?.x ?? {};
3962
- const formatter = xAxisOptions.tickFormat || getFormatter(dataSorted, tickResolution);
4013
+ const { tickResolution, tickFormat, ...xAxisOptions } = options?.axis?.x ?? {};
4014
+ const formatter = tickFormat || getFormatter(dataSorted, tickResolution);
3963
4015
  return {
3964
4016
  axis: {
3965
4017
  x: {
@@ -4001,26 +4053,28 @@ const AreaChartInternal = forwardRef(({ data, chartId: providedChartId, width, h
4001
4053
  const defaultMargin = useChartMargin(height, chartOptions, dataSorted, theme);
4002
4054
  const error = validateData$3(dataSorted);
4003
4055
  const isDataValid = !error;
4056
+ const legendItems = useChartLegendItems(dataSorted, useMemo(() => ({
4057
+ withGlyph: false,
4058
+ glyphSize: 0,
4059
+ collapseGroups: legend.collapseGroups ?? false
4060
+ }), [legend.collapseGroups]), legendShape);
4061
+ const chartMetadata = useMemo(() => ({
4062
+ stacked,
4063
+ stackOffset,
4064
+ smoothing,
4065
+ curveType
4066
+ }), [
4067
+ stacked,
4068
+ stackOffset,
4069
+ smoothing,
4070
+ curveType
4071
+ ]);
4004
4072
  useChartRegistration({
4005
4073
  chartId,
4006
- legendItems: useChartLegendItems(dataSorted, useMemo(() => ({
4007
- withGlyph: false,
4008
- glyphSize: 0,
4009
- collapseGroups: legend.collapseGroups ?? false
4010
- }), [legend.collapseGroups]), legendShape),
4074
+ legendItems,
4011
4075
  chartType: "area",
4012
4076
  isDataValid,
4013
- metadata: useMemo(() => ({
4014
- stacked,
4015
- stackOffset,
4016
- smoothing,
4017
- curveType
4018
- }), [
4019
- stacked,
4020
- stackOffset,
4021
- smoothing,
4022
- curveType
4023
- ])
4077
+ metadata: chartMetadata
4024
4078
  });
4025
4079
  const prefersReducedMotion = usePrefersReducedMotion();
4026
4080
  const animationEnabled = !!animation && !prefersReducedMotion;
@@ -4428,11 +4482,13 @@ const getGroupPadding = (scale) => {
4428
4482
  function useBarChartOptions(data, horizontal, options = {}, isSeriesRendered = ALL_RENDERED) {
4429
4483
  const stableOptions = useDeepMemo(options);
4430
4484
  const axisConfig = useMemo(() => {
4431
- const { labelOverflow: xLabelOverflow, tickResolution: xTickResolution, ...xAxisOptions } = stableOptions.axis?.x || {};
4432
- const { labelOverflow: yLabelOverflow, tickResolution: yTickResolution, ...yAxisOptions } = stableOptions.axis?.y || {};
4485
+ const { labelOverflow: xLabelOverflow, tickResolution: xTickResolution, tickFormat: xTickFormat, ...xAxisOptions } = stableOptions.axis?.x || {};
4486
+ const { labelOverflow: yLabelOverflow, tickResolution: yTickResolution, tickFormat: yTickFormat, ...yAxisOptions } = stableOptions.axis?.y || {};
4433
4487
  return {
4434
4488
  xLabelOverflow,
4435
4489
  yLabelOverflow,
4490
+ xTickFormat,
4491
+ yTickFormat,
4436
4492
  xAxisOptions,
4437
4493
  yAxisOptions,
4438
4494
  tickResolution: horizontal ? yTickResolution : xTickResolution
@@ -4492,7 +4548,7 @@ function useBarChartOptions(data, horizontal, options = {}, isSeriesRendered = A
4492
4548
  isSeriesRendered
4493
4549
  ]);
4494
4550
  return useMemo(() => {
4495
- const { xTickFormat, yTickFormat, tooltipLabelFormatter: defaultTooltipLabelFormatter, xAccessor, yAccessor, gridVisibility, xScale: baseXScale, yScale: baseYScale } = defaultOptions[horizontal ? "horizontal" : "vertical"];
4551
+ const { xTickFormat: defaultXTickFormat, yTickFormat: defaultYTickFormat, tooltipLabelFormatter: defaultTooltipLabelFormatter, xAccessor, yAccessor, gridVisibility, xScale: baseXScale, yScale: baseYScale } = defaultOptions[horizontal ? "horizontal" : "vertical"];
4496
4552
  let valueScaleDomainOverride = {};
4497
4553
  if (data.some((s) => s.options?.type === "comparison")) {
4498
4554
  if (!(!horizontal ? stableOptions.yScale?.domain : stableOptions.xScale?.domain)) {
@@ -4517,11 +4573,11 @@ function useBarChartOptions(data, horizontal, options = {}, isSeriesRendered = A
4517
4573
  ...stableOptions.yScale || {},
4518
4574
  ...!horizontal ? valueScaleDomainOverride : {}
4519
4575
  };
4520
- const { xLabelOverflow, yLabelOverflow, xAxisOptions, yAxisOptions } = axisConfig;
4521
- const providedToolTipLabelFormatter = horizontal ? yAxisOptions.tickFormat : xAxisOptions.tickFormat;
4576
+ const { xLabelOverflow, yLabelOverflow, xTickFormat, yTickFormat, xAxisOptions, yAxisOptions } = axisConfig;
4577
+ const dateAxisTickFormat = horizontal ? yTickFormat : xTickFormat;
4522
4578
  const { timeAxis } = defaultOptions;
4523
4579
  const dateAxisOptions = horizontal ? yAxisOptions : xAxisOptions;
4524
- const bandTickValues = timeAxis && !dateAxisOptions.tickFormat ? getBandTickValues(timeAxis.domain, timeAxis.tickFormatter, dateAxisOptions.numTicks ?? DEFAULT_NUM_TICKS) : null;
4580
+ const bandTickValues = timeAxis && !dateAxisTickFormat ? getBandTickValues(timeAxis.domain, timeAxis.tickFormatter, dateAxisOptions.numTicks ?? DEFAULT_NUM_TICKS) : null;
4525
4581
  const dateAxisTickValues = bandTickValues ? { tickValues: bandTickValues } : {};
4526
4582
  return {
4527
4583
  gridVisibility,
@@ -4535,7 +4591,7 @@ function useBarChartOptions(data, horizontal, options = {}, isSeriesRendered = A
4535
4591
  x: {
4536
4592
  orientation: "bottom",
4537
4593
  numTicks: DEFAULT_NUM_TICKS,
4538
- tickFormat: xTickFormat,
4594
+ tickFormat: xTickFormat || defaultXTickFormat,
4539
4595
  ...horizontal ? {} : dateAxisTickValues,
4540
4596
  ...xLabelOverflow === "ellipsis" ? { tickComponent: TruncatedXTickComponent } : {},
4541
4597
  ...xAxisOptions
@@ -4543,14 +4599,14 @@ function useBarChartOptions(data, horizontal, options = {}, isSeriesRendered = A
4543
4599
  y: {
4544
4600
  orientation: "left",
4545
4601
  numTicks: DEFAULT_NUM_TICKS,
4546
- tickFormat: yTickFormat,
4602
+ tickFormat: yTickFormat || defaultYTickFormat,
4547
4603
  ...horizontal ? dateAxisTickValues : {},
4548
4604
  ...yLabelOverflow === "ellipsis" ? { tickComponent: TruncatedYTickComponent } : {},
4549
4605
  ...yAxisOptions
4550
4606
  }
4551
4607
  },
4552
4608
  barGroup: { padding: getGroupPadding(horizontal ? yScale : xScale) },
4553
- tooltip: { labelFormatter: providedToolTipLabelFormatter || defaultTooltipLabelFormatter }
4609
+ tooltip: { labelFormatter: dateAxisTickFormat || defaultTooltipLabelFormatter }
4554
4610
  };
4555
4611
  }, [
4556
4612
  defaultOptions,
@@ -4613,11 +4669,6 @@ function computeComparisonRect(params) {
4613
4669
  };
4614
4670
  }
4615
4671
  /**
4616
- * Fraction of each per-series step left as a gap between bars within a single tick.
4617
- * Larger = more space between adjacent series; the shadow spans `1 - COMPARISON_INNER_GAP` of the step.
4618
- */
4619
- const COMPARISON_INNER_GAP = .1;
4620
- /**
4621
4672
  * Upper clamp on the computed group padding, so bars can never collapse to zero width
4622
4673
  * even at very large `widthFactor` values.
4623
4674
  */
@@ -4705,7 +4756,7 @@ const renderTooltipRow = (label, value) => /* @__PURE__ */ jsx("div", {
4705
4756
  className: bar_chart_module_default["bar-chart__tooltip-row"],
4706
4757
  children: sprintf(__("%1$s: %2$s", "jetpack-charts"), label, value)
4707
4758
  });
4708
- const BarChartInternal = ({ data, chartId: providedChartId, width, height, className, margin, withTooltips = false, showLegend = false, legend = {}, gridVisibility: gridVisibilityProp, renderTooltip, options = {}, orientation = "vertical", withPatterns = false, showZeroValues = false, defaultHiddenSeries, animation, children, gap = "md" }) => {
4759
+ const BarChartInternal = ({ data, chartId: providedChartId, width, height, className, margin, withTooltips = false, showLegend = false, legend = {}, gridVisibility: gridVisibilityProp, renderTooltip, options = {}, orientation = "vertical", withPatterns = false, showZeroValues = false, defaultHiddenSeries, animation, children, gap = "md", onPointerDown, onPointerUp, onDatumActivate }) => {
4709
4760
  const legendInteractive = legend.interactive ?? false;
4710
4761
  const legendCollapseGroups = legend.collapseGroups ?? false;
4711
4762
  const horizontal = orientation === "horizontal";
@@ -4732,14 +4783,7 @@ const BarChartInternal = ({ data, chartId: providedChartId, width, height, class
4732
4783
  const [selectedIndex, setSelectedIndex] = useState(void 0);
4733
4784
  const [isNavigating, setIsNavigating] = useState(false);
4734
4785
  const primarySeriesForNav = dataWithVisibleZeros.filter((s) => s.options?.type !== "comparison");
4735
- const { tooltipRef, onChartFocus, onChartBlur, onChartKeyDown } = useKeyboardNavigation({
4736
- selectedIndex,
4737
- setSelectedIndex,
4738
- isNavigating,
4739
- setIsNavigating,
4740
- chartRef,
4741
- totalPoints: Math.max(0, ...primarySeriesForNav.map((s) => s.data?.length || 0)) * primarySeriesForNav.length
4742
- });
4786
+ const totalPoints = Math.max(0, ...primarySeriesForNav.map((s) => s.data?.length || 0)) * primarySeriesForNav.length;
4743
4787
  const seriesWithVisibility = useMemo(() => dataWithVisibleZeros.map((series, index) => ({
4744
4788
  series,
4745
4789
  index,
@@ -4751,6 +4795,27 @@ const BarChartInternal = ({ data, chartId: providedChartId, width, height, class
4751
4795
  const primaryEntries = useMemo(() => seriesWithVisibility.filter(({ isVisible, series }) => isVisible && series.options?.type !== "comparison"), [seriesWithVisibility]);
4752
4796
  const primaryKeys = useMemo(() => primaryEntries.map(({ series }) => series.label), [primaryEntries]);
4753
4797
  const primarySeries = useMemo(() => primaryEntries.map(({ series }) => series), [primaryEntries]);
4798
+ const activateSelectedBar = useCallback((index) => {
4799
+ const primaryCount = primaryEntries.length;
4800
+ if (!primaryCount) return;
4801
+ const dataPointIndex = Math.floor(index / primaryCount);
4802
+ const series = primaryEntries[index % primaryCount]?.series;
4803
+ const datum = series?.data[dataPointIndex];
4804
+ if (series && datum) onDatumActivate?.({
4805
+ datum,
4806
+ index: dataPointIndex,
4807
+ key: series.label
4808
+ });
4809
+ }, [primaryEntries, onDatumActivate]);
4810
+ const { tooltipRef, onChartFocus, onChartBlur, onChartKeyDown } = useKeyboardNavigation({
4811
+ selectedIndex,
4812
+ setSelectedIndex,
4813
+ isNavigating,
4814
+ setIsNavigating,
4815
+ chartRef,
4816
+ totalPoints,
4817
+ onActivate: activateSelectedBar
4818
+ });
4754
4819
  const comparisonEntries = useMemo(() => {
4755
4820
  const primaryByGroup = new Map(primaryEntries.map(({ series, index }) => [series.group, {
4756
4821
  label: series.label,
@@ -4787,7 +4852,7 @@ const BarChartInternal = ({ data, chartId: providedChartId, width, height, class
4787
4852
  const groupPadding = useMemo(() => {
4788
4853
  const basePadding = chartOptions.barGroup.padding;
4789
4854
  if (!comparisonWidthFactor || comparisonWidthFactor <= 1) return basePadding;
4790
- const p = 1 - (1 - COMPARISON_INNER_GAP) / comparisonWidthFactor;
4855
+ const p = 1 - .9 / comparisonWidthFactor;
4791
4856
  return Math.min(Math.max(p, basePadding), MAX_GROUP_PADDING);
4792
4857
  }, [chartOptions.barGroup.padding, comparisonWidthFactor]);
4793
4858
  const { xScale, yScale } = useMemo(() => {
@@ -4925,15 +4990,17 @@ const BarChartInternal = ({ data, chartId: providedChartId, width, height, class
4925
4990
  chartId
4926
4991
  ]);
4927
4992
  const error = validateData$2(dataSorted);
4993
+ const isDataValid = !error;
4994
+ const chartMetadata = useMemo(() => ({
4995
+ orientation,
4996
+ withPatterns
4997
+ }), [orientation, withPatterns]);
4928
4998
  useChartRegistration({
4929
4999
  chartId,
4930
5000
  legendItems,
4931
5001
  chartType: "bar",
4932
- isDataValid: !error,
4933
- metadata: useMemo(() => ({
4934
- orientation,
4935
- withPatterns
4936
- }), [orientation, withPatterns])
5002
+ isDataValid,
5003
+ metadata: chartMetadata
4937
5004
  });
4938
5005
  const prefersReducedMotion = usePrefersReducedMotion();
4939
5006
  if (error) return /* @__PURE__ */ jsx("div", {
@@ -4998,6 +5065,8 @@ const BarChartInternal = ({ data, chartId: providedChartId, width, height, class
4998
5065
  xScale,
4999
5066
  yScale,
5000
5067
  horizontal,
5068
+ onPointerDown,
5069
+ onPointerUp,
5001
5070
  pointerEventsDataKey: "nearest",
5002
5071
  children: [
5003
5072
  !allSeriesHidden && /* @__PURE__ */ jsx(Grid, {
@@ -5153,6 +5222,25 @@ const BarListChartInternal = ({ data, width, height, options = {}, margin = {
5153
5222
  bottom: 0,
5154
5223
  top: 0
5155
5224
  }, ...rest }) => {
5225
+ const { getElementStyles } = useGlobalChartsContext();
5226
+ const tintedData = useMemo(() => {
5227
+ if (data.length > 1) return data;
5228
+ return data.map((series, index) => {
5229
+ if (series.options?.stroke) return series;
5230
+ const { color } = getElementStyles({
5231
+ data: series,
5232
+ index
5233
+ });
5234
+ if (!isValidHexColor(color)) return series;
5235
+ return {
5236
+ ...series,
5237
+ options: {
5238
+ ...series.options,
5239
+ stroke: lightenHexColor(color, .6)
5240
+ }
5241
+ };
5242
+ });
5243
+ }, [data, getElementStyles]);
5156
5244
  const chartOptions = useMemo(() => {
5157
5245
  const isMultiSeries = data.length > 1;
5158
5246
  const defaultYScale = {
@@ -5185,7 +5273,7 @@ const BarListChartInternal = ({ data, width, height, options = {}, margin = {
5185
5273
  return /* @__PURE__ */ jsx(BarChart, {
5186
5274
  orientation: "horizontal",
5187
5275
  gridVisibility: "none",
5188
- data,
5276
+ data: tintedData,
5189
5277
  width,
5190
5278
  height,
5191
5279
  margin,
@@ -5446,20 +5534,21 @@ const ConversionFunnelChartInternal = ({ mainRate, changeIndicator, steps, loadi
5446
5534
  })]
5447
5535
  });
5448
5536
  const isDataValid = Boolean(steps && steps.length > 0);
5537
+ const chartMetadata = useMemo(() => ({
5538
+ mainRate,
5539
+ changeIndicator,
5540
+ stepsCount: steps?.length || 0
5541
+ }), [
5542
+ mainRate,
5543
+ changeIndicator,
5544
+ steps?.length
5545
+ ]);
5449
5546
  useChartRegistration({
5450
5547
  chartId,
5451
5548
  legendItems: [],
5452
5549
  chartType: "conversion-funnel",
5453
5550
  isDataValid,
5454
- metadata: useMemo(() => ({
5455
- mainRate,
5456
- changeIndicator,
5457
- stepsCount: steps?.length || 0
5458
- }), [
5459
- mainRate,
5460
- changeIndicator,
5461
- steps?.length
5462
- ])
5551
+ metadata: chartMetadata
5463
5552
  });
5464
5553
  const prefersReducedMotion = usePrefersReducedMotion();
5465
5554
  if (!isDataValid) return /* @__PURE__ */ jsx(Stack, {
@@ -6063,7 +6152,7 @@ const HeatmapChartInternal = ({ data, chartId: providedChartId, width = 0, heigh
6063
6152
  });
6064
6153
  const chartBackgroundHex = normalizeColorToHex(theme.backgroundColor, scopeElement, resolveCssVariable);
6065
6154
  const primaryHex = normalizeColorToHex(primaryColorHex);
6066
- const cellHasLightText = (intensity) => isValidHexColor(primaryHex) && isValidHexColor(chartBackgroundHex) && prefersLightText(mixHexColors(primaryHex, chartBackgroundHex, 1 - (CELL_MIX_FLOOR + (1 - CELL_MIX_FLOOR) * intensity)));
6155
+ const cellHasLightText = (intensity) => isValidHexColor(primaryHex) && isValidHexColor(chartBackgroundHex) && prefersLightText(mixHexColors(primaryHex, chartBackgroundHex, 1 - (CELL_MIX_FLOOR + .85 * intensity)));
6067
6156
  const extent = useMemo(() => getValueExtent(data), [data]);
6068
6157
  const heatmapContext = useMemo(() => ({
6069
6158
  extent,
@@ -6386,7 +6475,7 @@ function paramCase(input, options) {
6386
6475
  return dotCase(input, __assign({ delimiter: "-" }, options));
6387
6476
  }
6388
6477
  //#endregion
6389
- //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/hooks/use-update-effect.mjs
6478
+ //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react-dom@18.3.7_@types+react@18.3.31__@types+react_e283446b3cbc213906bb0d97b3dd78c5/node_modules/@wordpress/components/build-module/utils/hooks/use-update-effect.mjs
6390
6479
  function useUpdateEffect(effect, deps) {
6391
6480
  const mountedRef = useRef$1(false);
6392
6481
  useEffect$1(() => {
@@ -6418,10 +6507,11 @@ var StyleSheet = /*#__PURE__*/ function() {
6418
6507
  var _this = this;
6419
6508
  this._insertTag = function(tag) {
6420
6509
  var before;
6421
- if (_this.tags.length === 0) if (_this.insertionPoint) before = _this.insertionPoint.nextSibling;
6422
- else if (_this.prepend) before = _this.container.firstChild;
6423
- else before = _this.before;
6424
- else before = _this.tags[_this.tags.length - 1].nextSibling;
6510
+ if (_this.tags.length === 0) {
6511
+ if (_this.insertionPoint) before = _this.insertionPoint.nextSibling;
6512
+ else if (_this.prepend) before = _this.container.firstChild;
6513
+ else before = _this.before;
6514
+ } else before = _this.tags[_this.tags.length - 1].nextSibling;
6425
6515
  _this.container.insertBefore(tag, before);
6426
6516
  _this.tags.push(tag);
6427
6517
  };
@@ -6740,9 +6830,7 @@ function delimiter(type) {
6740
6830
  case 40:
6741
6831
  if (type === 41) delimiter(type);
6742
6832
  break;
6743
- case 92:
6744
- next();
6745
- break;
6833
+ case 92: next();
6746
6834
  }
6747
6835
  return position;
6748
6836
  }
@@ -7718,14 +7806,12 @@ function handleInterpolation(mergedProps, registered, interpolation) {
7718
7806
  return serializedStyles.styles + ";";
7719
7807
  }
7720
7808
  return createStringFromObject(mergedProps, registered, interpolation);
7721
- case "function":
7722
- if (mergedProps !== void 0) {
7723
- var previousCursor = cursor;
7724
- var result = interpolation(mergedProps);
7725
- cursor = previousCursor;
7726
- return handleInterpolation(mergedProps, registered, result);
7727
- }
7728
- break;
7809
+ case "function": if (mergedProps !== void 0) {
7810
+ var previousCursor = cursor;
7811
+ var result = interpolation(mergedProps);
7812
+ cursor = previousCursor;
7813
+ return handleInterpolation(mergedProps, registered, result);
7814
+ }
7729
7815
  }
7730
7816
  var asString = interpolation;
7731
7817
  if (registered == null) return asString;
@@ -7959,7 +8045,7 @@ _createEmotion.css;
7959
8045
  _createEmotion.sheet;
7960
8046
  _createEmotion.cache;
7961
8047
  //#endregion
7962
- //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/hooks/use-cx.mjs
8048
+ //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react-dom@18.3.7_@types+react@18.3.31__@types+react_e283446b3cbc213906bb0d97b3dd78c5/node_modules/@wordpress/components/build-module/utils/hooks/use-cx.mjs
7963
8049
  var isSerializedStyles = (o) => typeof o !== "undefined" && o !== null && ["name", "styles"].every((p) => typeof o[p] !== "undefined");
7964
8050
  var useCx = () => {
7965
8051
  const cache = __unsafe_useEmotionCache();
@@ -8066,7 +8152,7 @@ function memize(fn, options) {
8066
8152
  return memoized;
8067
8153
  }
8068
8154
  //#endregion
8069
- //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/colors-values.mjs
8155
+ //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react-dom@18.3.7_@types+react@18.3.31__@types+react_e283446b3cbc213906bb0d97b3dd78c5/node_modules/@wordpress/components/build-module/utils/colors-values.mjs
8070
8156
  var white = "#fff";
8071
8157
  var GRAY = {
8072
8158
  900: "#1e1e1e",
@@ -8145,7 +8231,7 @@ var COLORS = Object.freeze({
8145
8231
  ui: UI
8146
8232
  });
8147
8233
  //#endregion
8148
- //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/config-values.mjs
8234
+ //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react-dom@18.3.7_@types+react@18.3.31__@types+react_e283446b3cbc213906bb0d97b3dd78c5/node_modules/@wordpress/components/build-module/utils/config-values.mjs
8149
8235
  var CONTROL_HEIGHT = "36px";
8150
8236
  var CONTROL_PROPS = {
8151
8237
  controlPaddingX: 12,
@@ -8250,10 +8336,10 @@ var require_es6 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8250
8336
  };
8251
8337
  }));
8252
8338
  //#endregion
8253
- //#region ../../../node_modules/.pnpm/@wordpress+warning@3.52.0/node_modules/@wordpress/warning/build-module/utils.mjs
8339
+ //#region ../../../node_modules/.pnpm/@wordpress+warning@3.53.0/node_modules/@wordpress/warning/build-module/utils.mjs
8254
8340
  var logged = /* @__PURE__ */ new Set();
8255
8341
  //#endregion
8256
- //#region ../../../node_modules/.pnpm/@wordpress+warning@3.52.0/node_modules/@wordpress/warning/build-module/index.mjs
8342
+ //#region ../../../node_modules/.pnpm/@wordpress+warning@3.53.0/node_modules/@wordpress/warning/build-module/index.mjs
8257
8343
  function isDev() {
8258
8344
  return globalThis.SCRIPT_DEBUG === true;
8259
8345
  }
@@ -8267,7 +8353,7 @@ function warning(message) {
8267
8353
  logged.add(message);
8268
8354
  }
8269
8355
  //#endregion
8270
- //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/context/context-system-provider.mjs
8356
+ //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react-dom@18.3.7_@types+react@18.3.31__@types+react_e283446b3cbc213906bb0d97b3dd78c5/node_modules/@wordpress/components/build-module/context/context-system-provider.mjs
8271
8357
  var import_es6 = /* @__PURE__ */ __toESM(require_es6(), 1);
8272
8358
  var ComponentsContext = createContext$1(
8273
8359
  /** @type {Record<string, any>} */
@@ -8294,18 +8380,18 @@ var BaseContextSystemProvider = ({ children, value }) => {
8294
8380
  };
8295
8381
  memo(BaseContextSystemProvider);
8296
8382
  //#endregion
8297
- //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/context/constants.mjs
8383
+ //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react-dom@18.3.7_@types+react@18.3.31__@types+react_e283446b3cbc213906bb0d97b3dd78c5/node_modules/@wordpress/components/build-module/context/constants.mjs
8298
8384
  var COMPONENT_NAMESPACE = "data-wp-component";
8299
8385
  var CONNECTED_NAMESPACE = "data-wp-c16t";
8300
8386
  var CONNECT_STATIC_NAMESPACE = "__contextSystemKey__";
8301
8387
  //#endregion
8302
- //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/context/get-styled-class-name-from-key.mjs
8388
+ //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react-dom@18.3.7_@types+react@18.3.31__@types+react_e283446b3cbc213906bb0d97b3dd78c5/node_modules/@wordpress/components/build-module/context/get-styled-class-name-from-key.mjs
8303
8389
  function getStyledClassName(namespace) {
8304
8390
  return `components-${paramCase(namespace)}`;
8305
8391
  }
8306
8392
  var getStyledClassNameFromKey = memize(getStyledClassName);
8307
8393
  //#endregion
8308
- //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/context/context-connect.mjs
8394
+ //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react-dom@18.3.7_@types+react@18.3.31__@types+react_e283446b3cbc213906bb0d97b3dd78c5/node_modules/@wordpress/components/build-module/context/context-connect.mjs
8309
8395
  function contextConnect(Component, namespace) {
8310
8396
  return _contextConnect(Component, namespace, { forwardsRef: true });
8311
8397
  }
@@ -8322,7 +8408,7 @@ function _contextConnect(Component, namespace, options) {
8322
8408
  });
8323
8409
  }
8324
8410
  //#endregion
8325
- //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/context/utils.mjs
8411
+ //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react-dom@18.3.7_@types+react@18.3.31__@types+react_e283446b3cbc213906bb0d97b3dd78c5/node_modules/@wordpress/components/build-module/context/utils.mjs
8326
8412
  function getNamespace(componentName) {
8327
8413
  return { [COMPONENT_NAMESPACE]: componentName };
8328
8414
  }
@@ -8330,7 +8416,7 @@ function getConnectedNamespace() {
8330
8416
  return { [CONNECTED_NAMESPACE]: true };
8331
8417
  }
8332
8418
  //#endregion
8333
- //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/context/use-context-system.mjs
8419
+ //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react-dom@18.3.7_@types+react@18.3.31__@types+react_e283446b3cbc213906bb0d97b3dd78c5/node_modules/@wordpress/components/build-module/context/use-context-system.mjs
8334
8420
  function useContextSystem(props, namespace) {
8335
8421
  const contextSystemProps = useComponentsContext();
8336
8422
  if (typeof namespace === "undefined") globalThis.SCRIPT_DEBUG === true && warning("useContextSystem: Please provide a namespace");
@@ -8350,7 +8436,7 @@ function useContextSystem(props, namespace) {
8350
8436
  return finalComponentProps;
8351
8437
  }
8352
8438
  //#endregion
8353
- //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/visually-hidden/styles.mjs
8439
+ //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react-dom@18.3.7_@types+react@18.3.31__@types+react_e283446b3cbc213906bb0d97b3dd78c5/node_modules/@wordpress/components/build-module/visually-hidden/styles.mjs
8354
8440
  var visuallyHidden = {
8355
8441
  border: 0,
8356
8442
  clip: "rect(1px, 1px, 1px, 1px)",
@@ -8366,7 +8452,7 @@ var visuallyHidden = {
8366
8452
  wordBreak: "normal"
8367
8453
  };
8368
8454
  //#endregion
8369
- //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/polymorphic-element.mjs
8455
+ //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react-dom@18.3.7_@types+react@18.3.31__@types+react_e283446b3cbc213906bb0d97b3dd78c5/node_modules/@wordpress/components/build-module/utils/polymorphic-element.mjs
8370
8456
  var customAttributeRegExp = /^(data|aria|x)-/i;
8371
8457
  var eventHandlerRegExp = /^on[A-Z]/;
8372
8458
  var svgElementNames = new Set(`animate animateMotion animateTransform circle clipPath defs desc ellipse
@@ -8448,14 +8534,15 @@ function filterIntrinsicElementProps(props, element) {
8448
8534
  }
8449
8535
  function UnforwardedPolymorphicElement({ as, ...props }, ref) {
8450
8536
  const Element = as || "div";
8537
+ const forwardedProps = typeof Element === "string" ? filterIntrinsicElementProps(props, Element) : props;
8451
8538
  return /* @__PURE__ */ jsx(Element, {
8452
8539
  ref,
8453
- ...typeof Element === "string" ? filterIntrinsicElementProps(props, Element) : props
8540
+ ...forwardedProps
8454
8541
  });
8455
8542
  }
8456
8543
  var PolymorphicElement = forwardRef$1(UnforwardedPolymorphicElement);
8457
8544
  //#endregion
8458
- //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/view/component.mjs
8545
+ //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react-dom@18.3.7_@types+react@18.3.31__@types+react_e283446b3cbc213906bb0d97b3dd78c5/node_modules/@wordpress/components/build-module/view/component.mjs
8459
8546
  function UnforwardedView({ css, ...restProps }, ref) {
8460
8547
  return /* @__PURE__ */ jsx(PolymorphicElement, {
8461
8548
  ref,
@@ -8464,7 +8551,7 @@ function UnforwardedView({ css, ...restProps }, ref) {
8464
8551
  }
8465
8552
  var component_default$2 = Object.assign(forwardRef$1(UnforwardedView), { selector: ".components-view" });
8466
8553
  //#endregion
8467
- //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/visually-hidden/component.mjs
8554
+ //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react-dom@18.3.7_@types+react@18.3.31__@types+react_e283446b3cbc213906bb0d97b3dd78c5/node_modules/@wordpress/components/build-module/visually-hidden/component.mjs
8468
8555
  function UnconnectedVisuallyHidden(props, forwardedRef) {
8469
8556
  const { style: styleProp, ...contextProps } = useContextSystem(props, "VisuallyHidden");
8470
8557
  return /* @__PURE__ */ jsx(component_default$2, {
@@ -8479,7 +8566,7 @@ function UnconnectedVisuallyHidden(props, forwardedRef) {
8479
8566
  }
8480
8567
  var component_default$1 = contextConnect(UnconnectedVisuallyHidden, "VisuallyHidden");
8481
8568
  //#endregion
8482
- //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/use-responsive-value.mjs
8569
+ //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react-dom@18.3.7_@types+react@18.3.31__@types+react_e283446b3cbc213906bb0d97b3dd78c5/node_modules/@wordpress/components/build-module/utils/use-responsive-value.mjs
8483
8570
  var breakpoints = [
8484
8571
  "40em",
8485
8572
  "52em",
@@ -8513,7 +8600,7 @@ function useResponsiveValue(values, options = {}) {
8513
8600
  return array[index >= array.length ? array.length - 1 : index];
8514
8601
  }
8515
8602
  //#endregion
8516
- //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/grid/utils.mjs
8603
+ //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react-dom@18.3.7_@types+react@18.3.31__@types+react_e283446b3cbc213906bb0d97b3dd78c5/node_modules/@wordpress/components/build-module/grid/utils.mjs
8517
8604
  var ALIGNMENTS = {
8518
8605
  bottom: {
8519
8606
  alignItems: "flex-end",
@@ -8561,7 +8648,7 @@ function getAlignmentProps(alignment) {
8561
8648
  return alignment ? ALIGNMENTS[alignment] : {};
8562
8649
  }
8563
8650
  //#endregion
8564
- //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/grid/hook.mjs
8651
+ //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react-dom@18.3.7_@types+react@18.3.31__@types+react_e283446b3cbc213906bb0d97b3dd78c5/node_modules/@wordpress/components/build-module/grid/hook.mjs
8565
8652
  function useGrid(props) {
8566
8653
  const { align, alignment, className, columnGap, columns = 2, gap = 3, isInline = false, justify, rowGap, rows, templateColumns, templateRows, ...otherProps } = useContextSystem(props, "Grid");
8567
8654
  const column = useResponsiveValue(Array.isArray(columns) ? columns : [columns]);
@@ -8603,10 +8690,11 @@ function useGrid(props) {
8603
8690
  };
8604
8691
  }
8605
8692
  //#endregion
8606
- //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/grid/component.mjs
8693
+ //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react-dom@18.3.7_@types+react@18.3.31__@types+react_e283446b3cbc213906bb0d97b3dd78c5/node_modules/@wordpress/components/build-module/grid/component.mjs
8607
8694
  function UnconnectedGrid(props, forwardedRef) {
8695
+ const gridProps = useGrid(props);
8608
8696
  return /* @__PURE__ */ jsx(component_default$2, {
8609
- ...useGrid(props),
8697
+ ...gridProps,
8610
8698
  ref: forwardedRef
8611
8699
  });
8612
8700
  }
@@ -8918,15 +9006,17 @@ const LeaderboardChartInternal = ({ data, chartId: providedChartId, width: propW
8918
9006
  withComparison,
8919
9007
  withOverlayLabel
8920
9008
  ]);
9009
+ const isDataValid = Boolean(data && data.length > 0);
9010
+ const chartMetadata = useMemo(() => ({
9011
+ withComparison,
9012
+ withOverlayLabel
9013
+ }), [withComparison, withOverlayLabel]);
8921
9014
  useChartRegistration({
8922
9015
  chartId,
8923
9016
  legendItems,
8924
9017
  chartType: "leaderboard",
8925
- isDataValid: Boolean(data && data.length > 0),
8926
- metadata: useMemo(() => ({
8927
- withComparison,
8928
- withOverlayLabel
8929
- }), [withComparison, withOverlayLabel])
9018
+ isDataValid,
9019
+ metadata: chartMetadata
8930
9020
  });
8931
9021
  const prefersReducedMotion = usePrefersReducedMotion();
8932
9022
  const { contentRef, fittedCount, isMeasurable } = useFittedRowCount(fitRows && !allSeriesHidden, data?.length ?? 0, data);
@@ -9181,8 +9271,9 @@ const PieChartInternal = ({ data, chartId: providedChartId, withTooltips = false
9181
9271
  hideTooltip();
9182
9272
  }, [withTooltips, hideTooltip]);
9183
9273
  const { getElementStyles, isSeriesVisible } = useGlobalChartsContext();
9274
+ const dataWithPercentages = useDataWithPercentages(data);
9184
9275
  const { visibleData, allSegmentsHidden, legendData } = useLegendVisibilityData({
9185
- data: useDataWithPercentages(data),
9276
+ data: dataWithPercentages,
9186
9277
  chartId,
9187
9278
  isSeriesVisible
9188
9279
  });
@@ -9192,20 +9283,21 @@ const PieChartInternal = ({ data, chartId: providedChartId, withTooltips = false
9192
9283
  }), [legendValueDisplay]));
9193
9284
  const { isValid, message } = validateData$1(data);
9194
9285
  const { svgChildren, htmlChildren, legendChildren, otherChildren } = useChartChildren(children, "PieChart");
9286
+ const chartMetadata = useMemo(() => ({
9287
+ thickness,
9288
+ gapScale,
9289
+ cornerScale
9290
+ }), [
9291
+ thickness,
9292
+ gapScale,
9293
+ cornerScale
9294
+ ]);
9195
9295
  useChartRegistration({
9196
9296
  chartId,
9197
9297
  legendItems,
9198
9298
  chartType: "pie",
9199
9299
  isDataValid: isValid,
9200
- metadata: useMemo(() => ({
9201
- thickness,
9202
- gapScale,
9203
- cornerScale
9204
- }), [
9205
- thickness,
9206
- gapScale,
9207
- cornerScale
9208
- ])
9300
+ metadata: chartMetadata
9209
9301
  });
9210
9302
  const prefersReducedMotion = usePrefersReducedMotion();
9211
9303
  if (!isValid) return /* @__PURE__ */ jsx("div", {
@@ -9334,14 +9426,12 @@ const PieChartInternal = ({ data, chartId: providedChartId, withTooltips = false
9334
9426
  }
9335
9427
  const svgLabelSmall = providerTheme.svgLabelSmall;
9336
9428
  const fontSize = resolveFontSize(svgLabelSmall?.fontSize) ?? 12;
9337
- const estimatedTextWidth = getStringWidth$1(arc.data.label, {
9429
+ const backgroundWidth = getStringWidth$1(arc.data.label, {
9338
9430
  fontSize,
9339
9431
  fontFamily: svgLabelSmall?.fontFamily,
9340
9432
  fontWeight: svgLabelSmall?.fontWeight
9341
- });
9342
- const labelPadding = 6;
9343
- const backgroundWidth = estimatedTextWidth + labelPadding * 2;
9344
- const backgroundHeight = fontSize + labelPadding * 2;
9433
+ }) + 12;
9434
+ const backgroundHeight = fontSize + 12;
9345
9435
  return /* @__PURE__ */ jsxs("g", {
9346
9436
  ...groupProps,
9347
9437
  children: [/* @__PURE__ */ jsx("path", { ...pathProps }), showLabels && hasSpaceForLabel && /* @__PURE__ */ jsxs("g", { children: [providerTheme.labelBackgroundColor && /* @__PURE__ */ jsx("rect", {
@@ -9473,8 +9563,9 @@ const PieSemiCircleChartInternal = ({ data, chartId: providedChartId, width: pro
9473
9563
  }, [handleMouseMove]);
9474
9564
  const { isValid, message } = validateData(data);
9475
9565
  const { getElementStyles, isSeriesVisible } = useGlobalChartsContext();
9566
+ const dataWithPercentages = useDataWithPercentages(data);
9476
9567
  const { visibleData, allSegmentsHidden, legendData } = useLegendVisibilityData({
9477
- data: useDataWithPercentages(data),
9568
+ data: dataWithPercentages,
9478
9569
  chartId,
9479
9570
  isSeriesVisible
9480
9571
  });
@@ -9491,15 +9582,16 @@ const PieSemiCircleChartInternal = ({ data, chartId: providedChartId, width: pro
9491
9582
  legendValueDisplay
9492
9583
  }), [legendValueDisplay]));
9493
9584
  const { svgChildren, htmlChildren, legendChildren, otherChildren } = useChartChildren(children, "PieSemiCircleChart");
9585
+ const chartMetadata = useMemo(() => ({
9586
+ thickness,
9587
+ clockwise
9588
+ }), [thickness, clockwise]);
9494
9589
  useChartRegistration({
9495
9590
  chartId,
9496
9591
  legendItems,
9497
9592
  chartType: "pie-semi-circle",
9498
9593
  isDataValid: isValid,
9499
- metadata: useMemo(() => ({
9500
- thickness,
9501
- clockwise
9502
- }), [thickness, clockwise])
9594
+ metadata: chartMetadata
9503
9595
  });
9504
9596
  const prefersReducedMotion = usePrefersReducedMotion();
9505
9597
  const effectiveWidth = propWidth || DEFAULT_WIDTH$1;
@@ -9690,6 +9782,7 @@ const transformToSeriesData = (data, color, strokeWidth) => {
9690
9782
  };
9691
9783
  const SparklineComponent = forwardRef(({ data, width = DEFAULT_WIDTH, height = DEFAULT_HEIGHT, color, strokeWidth: strokeWidthProp, withGradientFill = true, gradient, className, chartId, margin: marginProp, animation }, ref) => {
9692
9784
  const theme = useGlobalChartsTheme();
9785
+ const chartsContext = useContext(GlobalChartsContext);
9693
9786
  const themeStrokeWidth = theme.sparkline?.strokeWidth ?? 1.5;
9694
9787
  const strokeWidth = strokeWidthProp ?? themeStrokeWidth;
9695
9788
  const seriesData = useMemo(() => {
@@ -9743,7 +9836,7 @@ const SparklineComponent = forwardRef(({ data, width = DEFAULT_WIDTH, height = D
9743
9836
  if (data.length === 1) {
9744
9837
  const cx = width / 2;
9745
9838
  const cy = height / 2;
9746
- const resolvedColor = color || "#000000";
9839
+ const resolvedColor = color || chartsContext?.getElementStyles({ index: 0 }).color || "#000000";
9747
9840
  return /* @__PURE__ */ jsx("div", {
9748
9841
  ref,
9749
9842
  className: clsx("sparkline", sparkline_module_default.sparkline, sparkline_module_default["sparkline--single-point"], className),
@@ -9846,8 +9939,9 @@ const Icon$1 = ({ direction }) => {
9846
9939
  */
9847
9940
  function TrendIndicator({ direction, value, className, style, showIcon = true }) {
9848
9941
  const ariaLabel = `${DIRECTION_LABELS[direction]}: ${value}`;
9942
+ const standaloneScopeClass = useStandaloneScopeClass();
9849
9943
  return /* @__PURE__ */ jsxs("span", {
9850
- className: clsx(useStandaloneScopeClass(), trend_indicator_module_default["trend-indicator"], trend_indicator_module_default[`trend-indicator--${direction}`], className),
9944
+ className: clsx(standaloneScopeClass, trend_indicator_module_default["trend-indicator"], trend_indicator_module_default[`trend-indicator--${direction}`], className),
9851
9945
  style,
9852
9946
  "aria-label": ariaLabel,
9853
9947
  children: [showIcon && /* @__PURE__ */ jsx(Icon$1, { direction }), /* @__PURE__ */ jsx("span", {