@automattic/charts 0.44.0 → 0.46.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 (113) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/{chunk-2HB55BRH.js → chunk-4H3J2HCD.js} +102 -47
  3. package/dist/chunk-4H3J2HCD.js.map +1 -0
  4. package/dist/{chunk-G4FX5I3V.cjs → chunk-7AH76DXF.cjs} +119 -64
  5. package/dist/chunk-7AH76DXF.cjs.map +1 -0
  6. package/dist/{chunk-3O6FHD2T.js → chunk-A3PGOCJO.js} +46 -4
  7. package/dist/chunk-A3PGOCJO.js.map +1 -0
  8. package/dist/{chunk-G66WE3ON.js → chunk-BWEMZ72V.js} +41 -15
  9. package/dist/chunk-BWEMZ72V.js.map +1 -0
  10. package/dist/{chunk-BZ6UDD37.cjs → chunk-CNAKHZMW.cjs} +69 -31
  11. package/dist/chunk-CNAKHZMW.cjs.map +1 -0
  12. package/dist/{chunk-MAV6SE6L.cjs → chunk-GEB4GELE.cjs} +24 -24
  13. package/dist/{chunk-MAV6SE6L.cjs.map → chunk-GEB4GELE.cjs.map} +1 -1
  14. package/dist/{chunk-KM62I6SD.js → chunk-HVWETEEV.js} +53 -15
  15. package/dist/chunk-HVWETEEV.js.map +1 -0
  16. package/dist/{chunk-HYHBAHIU.js → chunk-JGX3ZNK5.js} +3 -3
  17. package/dist/{chunk-W5RFMC3A.js → chunk-JI6OGGGF.js} +3 -3
  18. package/dist/{chunk-SHADFB3T.js → chunk-KEBKTDOQ.js} +2 -2
  19. package/dist/{chunk-2HUX2CAT.cjs → chunk-LSGYIUQX.cjs} +44 -2
  20. package/dist/chunk-LSGYIUQX.cjs.map +1 -0
  21. package/dist/{chunk-UHESRL2F.cjs → chunk-N36WJKYM.cjs} +6 -6
  22. package/dist/{chunk-UHESRL2F.cjs.map → chunk-N36WJKYM.cjs.map} +1 -1
  23. package/dist/{chunk-Q2LDRQN7.js → chunk-PFT2X4OW.js} +2 -2
  24. package/dist/{chunk-GK3XEXVI.cjs → chunk-PNSMPZ3E.cjs} +8 -8
  25. package/dist/{chunk-GK3XEXVI.cjs.map → chunk-PNSMPZ3E.cjs.map} +1 -1
  26. package/dist/{chunk-SC462VDM.cjs → chunk-QPHNEQCK.cjs} +11 -11
  27. package/dist/{chunk-SC462VDM.cjs.map → chunk-QPHNEQCK.cjs.map} +1 -1
  28. package/dist/{chunk-ZA7OWPY7.cjs → chunk-VOMSG7KV.cjs} +50 -24
  29. package/dist/chunk-VOMSG7KV.cjs.map +1 -0
  30. package/dist/{chunk-QLLKOSJ6.cjs → chunk-YKVKFUV7.cjs} +50 -24
  31. package/dist/chunk-YKVKFUV7.cjs.map +1 -0
  32. package/dist/{chunk-XDIWMJZD.js → chunk-ZSNO2BYX.js} +39 -13
  33. package/dist/chunk-ZSNO2BYX.js.map +1 -0
  34. package/dist/components/bar-chart/index.cjs +4 -4
  35. package/dist/components/bar-chart/index.d.cts +2 -1
  36. package/dist/components/bar-chart/index.d.ts +2 -1
  37. package/dist/components/bar-chart/index.js +3 -3
  38. package/dist/components/bar-list-chart/index.cjs +5 -5
  39. package/dist/components/bar-list-chart/index.d.cts +1 -1
  40. package/dist/components/bar-list-chart/index.d.ts +1 -1
  41. package/dist/components/bar-list-chart/index.js +4 -4
  42. package/dist/components/conversion-funnel-chart/index.cjs +3 -3
  43. package/dist/components/conversion-funnel-chart/index.d.cts +1 -1
  44. package/dist/components/conversion-funnel-chart/index.d.ts +1 -1
  45. package/dist/components/conversion-funnel-chart/index.js +2 -2
  46. package/dist/components/leaderboard-chart/index.cjs +4 -4
  47. package/dist/components/leaderboard-chart/index.d.cts +2 -2
  48. package/dist/components/leaderboard-chart/index.d.ts +2 -2
  49. package/dist/components/leaderboard-chart/index.js +3 -3
  50. package/dist/components/legend/index.cjs +3 -3
  51. package/dist/components/legend/index.d.cts +1 -1
  52. package/dist/components/legend/index.d.ts +1 -1
  53. package/dist/components/legend/index.js +2 -2
  54. package/dist/components/line-chart/index.cjs +4 -4
  55. package/dist/components/line-chart/index.d.cts +1 -1
  56. package/dist/components/line-chart/index.d.ts +1 -1
  57. package/dist/components/line-chart/index.js +3 -3
  58. package/dist/components/pie-chart/index.cjs +4 -4
  59. package/dist/components/pie-chart/index.d.cts +7 -1
  60. package/dist/components/pie-chart/index.d.ts +7 -1
  61. package/dist/components/pie-chart/index.js +3 -3
  62. package/dist/components/pie-semi-circle-chart/index.cjs +4 -4
  63. package/dist/components/pie-semi-circle-chart/index.d.cts +7 -1
  64. package/dist/components/pie-semi-circle-chart/index.d.ts +7 -1
  65. package/dist/components/pie-semi-circle-chart/index.js +3 -3
  66. package/dist/components/tooltip/index.d.cts +1 -1
  67. package/dist/components/tooltip/index.d.ts +1 -1
  68. package/dist/hooks/index.cjs +4 -2
  69. package/dist/hooks/index.cjs.map +1 -1
  70. package/dist/hooks/index.d.cts +79 -2
  71. package/dist/hooks/index.d.ts +79 -2
  72. package/dist/hooks/index.js +3 -1
  73. package/dist/index.cjs +10 -10
  74. package/dist/index.d.cts +3 -3
  75. package/dist/index.d.ts +3 -3
  76. package/dist/index.js +9 -9
  77. package/dist/{leaderboard-chart-BWEheWCd.d.cts → leaderboard-chart-B5JRimc9.d.cts} +2 -2
  78. package/dist/{leaderboard-chart-rqyTz1m6.d.ts → leaderboard-chart-DQ8i8GMA.d.ts} +2 -2
  79. package/dist/providers/index.cjs +2 -2
  80. package/dist/providers/index.d.cts +2 -2
  81. package/dist/providers/index.d.ts +2 -2
  82. package/dist/providers/index.js +1 -1
  83. package/dist/{themes-CGUHFZ5g.d.ts → themes-CN85BQM1.d.ts} +1 -1
  84. package/dist/{themes-B4swlmql.d.cts → themes-TIJq1lG_.d.cts} +1 -1
  85. package/dist/{types-cEbX_Q2K.d.ts → types-73KOEWs9.d.cts} +3 -1
  86. package/dist/{types-cEbX_Q2K.d.cts → types-73KOEWs9.d.ts} +3 -1
  87. package/package.json +3 -3
  88. package/src/components/bar-chart/bar-chart.tsx +57 -11
  89. package/src/components/bar-chart/test/bar-chart.test.tsx +114 -0
  90. package/src/components/leaderboard-chart/leaderboard-chart.tsx +85 -38
  91. package/src/components/leaderboard-chart/test/leaderboard-chart.test.tsx +48 -0
  92. package/src/components/leaderboard-chart/types.ts +1 -0
  93. package/src/components/pie-chart/pie-chart.tsx +130 -93
  94. package/src/components/pie-chart/test/pie-chart.test.tsx +174 -0
  95. package/src/components/pie-semi-circle-chart/pie-semi-circle-chart.tsx +96 -57
  96. package/src/components/pie-semi-circle-chart/test/pie-semi-circle-chart.test.tsx +84 -0
  97. package/src/hooks/index.ts +1 -0
  98. package/src/hooks/use-interactive-legend-data.ts +138 -0
  99. package/src/types.ts +3 -1
  100. package/dist/chunk-2HB55BRH.js.map +0 -1
  101. package/dist/chunk-2HUX2CAT.cjs.map +0 -1
  102. package/dist/chunk-3O6FHD2T.js.map +0 -1
  103. package/dist/chunk-BZ6UDD37.cjs.map +0 -1
  104. package/dist/chunk-G4FX5I3V.cjs.map +0 -1
  105. package/dist/chunk-G66WE3ON.js.map +0 -1
  106. package/dist/chunk-KM62I6SD.js.map +0 -1
  107. package/dist/chunk-QLLKOSJ6.cjs.map +0 -1
  108. package/dist/chunk-XDIWMJZD.js.map +0 -1
  109. package/dist/chunk-ZA7OWPY7.cjs.map +0 -1
  110. /package/dist/{chunk-HYHBAHIU.js.map → chunk-JGX3ZNK5.js.map} +0 -0
  111. /package/dist/{chunk-W5RFMC3A.js.map → chunk-JI6OGGGF.js.map} +0 -0
  112. /package/dist/{chunk-SHADFB3T.js.map → chunk-KEBKTDOQ.js.map} +0 -0
  113. /package/dist/{chunk-Q2LDRQN7.js.map → chunk-PFT2X4OW.js.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,18 @@ 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
+ ## [0.46.0] - 2025-10-28
9
+ ### Added
10
+ - Charts: Add interactive legend support to LeaderboardChart [#45581]
11
+
12
+ ### Changed
13
+ - Update package dependencies. [#45652]
14
+
15
+ ## [0.45.0] - 2025-10-27
16
+ ### Added
17
+ - Add interactive legend support to BarChart. [#45561]
18
+ - Add interactive legend to pie charts. [#45580]
19
+
8
20
  ## [0.44.0] - 2025-10-21
9
21
  ### Changed
10
22
  - Improve legends toggling. [#45545]
@@ -523,6 +535,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
523
535
  - Fixed lints following ESLint rule changes for TS [#40584]
524
536
  - Fixing a bug in Chart storybook data. [#40640]
525
537
 
538
+ [0.46.0]: https://github.com/Automattic/charts/compare/v0.45.0...v0.46.0
539
+ [0.45.0]: https://github.com/Automattic/charts/compare/v0.44.0...v0.45.0
526
540
  [0.44.0]: https://github.com/Automattic/charts/compare/v0.43.0...v0.44.0
527
541
  [0.43.0]: https://github.com/Automattic/charts/compare/v0.42.0...v0.43.0
528
542
  [0.42.0]: https://github.com/Automattic/charts/compare/v0.41.1...v0.42.0
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  Legend,
9
9
  SingleChartContext
10
- } from "./chunk-Q2LDRQN7.js";
10
+ } from "./chunk-PFT2X4OW.js";
11
11
  import {
12
12
  GlobalChartsContext,
13
13
  GlobalChartsProvider,
@@ -17,7 +17,7 @@ import {
17
17
  useChartRegistration,
18
18
  useGlobalChartsContext,
19
19
  useGlobalChartsTheme
20
- } from "./chunk-3O6FHD2T.js";
20
+ } from "./chunk-A3PGOCJO.js";
21
21
  import {
22
22
  __commonJS,
23
23
  __export,
@@ -630,21 +630,23 @@ function paramCase(input, options) {
630
630
  return dotCase(input, __assign2({ delimiter: "-" }, options));
631
631
  }
632
632
 
633
- // ../../../node_modules/.pnpm/@wordpress+hooks@4.32.0/node_modules/@wordpress/hooks/build-module/validateNamespace.js
633
+ // ../../../node_modules/.pnpm/@wordpress+hooks@4.33.0/node_modules/@wordpress/hooks/build-module/validateNamespace.js
634
634
  function validateNamespace(namespace) {
635
635
  if ("string" !== typeof namespace || "" === namespace) {
636
636
  console.error("The namespace must be a non-empty string.");
637
637
  return false;
638
638
  }
639
639
  if (!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(namespace)) {
640
- console.error("The namespace can only contain numbers, letters, dashes, periods, underscores and slashes.");
640
+ console.error(
641
+ "The namespace can only contain numbers, letters, dashes, periods, underscores and slashes."
642
+ );
641
643
  return false;
642
644
  }
643
645
  return true;
644
646
  }
645
647
  var validateNamespace_default = validateNamespace;
646
648
 
647
- // ../../../node_modules/.pnpm/@wordpress+hooks@4.32.0/node_modules/@wordpress/hooks/build-module/validateHookName.js
649
+ // ../../../node_modules/.pnpm/@wordpress+hooks@4.33.0/node_modules/@wordpress/hooks/build-module/validateHookName.js
648
650
  function validateHookName(hookName) {
649
651
  if ("string" !== typeof hookName || "" === hookName) {
650
652
  console.error("The hook name must be a non-empty string.");
@@ -655,14 +657,16 @@ function validateHookName(hookName) {
655
657
  return false;
656
658
  }
657
659
  if (!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(hookName)) {
658
- console.error("The hook name can only contain numbers, letters, dashes, periods and underscores.");
660
+ console.error(
661
+ "The hook name can only contain numbers, letters, dashes, periods and underscores."
662
+ );
659
663
  return false;
660
664
  }
661
665
  return true;
662
666
  }
663
667
  var validateHookName_default = validateHookName;
664
668
 
665
- // ../../../node_modules/.pnpm/@wordpress+hooks@4.32.0/node_modules/@wordpress/hooks/build-module/createAddHook.js
669
+ // ../../../node_modules/.pnpm/@wordpress+hooks@4.33.0/node_modules/@wordpress/hooks/build-module/createAddHook.js
666
670
  function createAddHook(hooks, storeKey) {
667
671
  return function addHook(hookName, namespace, callback, priority = 10) {
668
672
  const hooksStore = hooks[storeKey];
@@ -677,14 +681,12 @@ function createAddHook(hooks, storeKey) {
677
681
  return;
678
682
  }
679
683
  if ("number" !== typeof priority) {
680
- console.error("If specified, the hook priority must be a number.");
684
+ console.error(
685
+ "If specified, the hook priority must be a number."
686
+ );
681
687
  return;
682
688
  }
683
- const handler = {
684
- callback,
685
- priority,
686
- namespace
687
- };
689
+ const handler = { callback, priority, namespace };
688
690
  if (hooksStore[hookName]) {
689
691
  const handlers = hooksStore[hookName].handlers;
690
692
  let i2;
@@ -710,13 +712,19 @@ function createAddHook(hooks, storeKey) {
710
712
  };
711
713
  }
712
714
  if (hookName !== "hookAdded") {
713
- hooks.doAction("hookAdded", hookName, namespace, callback, priority);
715
+ hooks.doAction(
716
+ "hookAdded",
717
+ hookName,
718
+ namespace,
719
+ callback,
720
+ priority
721
+ );
714
722
  }
715
723
  };
716
724
  }
717
725
  var createAddHook_default = createAddHook;
718
726
 
719
- // ../../../node_modules/.pnpm/@wordpress+hooks@4.32.0/node_modules/@wordpress/hooks/build-module/createRemoveHook.js
727
+ // ../../../node_modules/.pnpm/@wordpress+hooks@4.33.0/node_modules/@wordpress/hooks/build-module/createRemoveHook.js
720
728
  function createRemoveHook(hooks, storeKey, removeAll = false) {
721
729
  return function removeHook(hookName, namespace) {
722
730
  const hooksStore = hooks[storeKey];
@@ -758,19 +766,21 @@ function createRemoveHook(hooks, storeKey, removeAll = false) {
758
766
  }
759
767
  var createRemoveHook_default = createRemoveHook;
760
768
 
761
- // ../../../node_modules/.pnpm/@wordpress+hooks@4.32.0/node_modules/@wordpress/hooks/build-module/createHasHook.js
769
+ // ../../../node_modules/.pnpm/@wordpress+hooks@4.33.0/node_modules/@wordpress/hooks/build-module/createHasHook.js
762
770
  function createHasHook(hooks, storeKey) {
763
771
  return function hasHook(hookName, namespace) {
764
772
  const hooksStore = hooks[storeKey];
765
773
  if ("undefined" !== typeof namespace) {
766
- return hookName in hooksStore && hooksStore[hookName].handlers.some((hook) => hook.namespace === namespace);
774
+ return hookName in hooksStore && hooksStore[hookName].handlers.some(
775
+ (hook) => hook.namespace === namespace
776
+ );
767
777
  }
768
778
  return hookName in hooksStore;
769
779
  };
770
780
  }
771
781
  var createHasHook_default = createHasHook;
772
782
 
773
- // ../../../node_modules/.pnpm/@wordpress+hooks@4.32.0/node_modules/@wordpress/hooks/build-module/createRunHook.js
783
+ // ../../../node_modules/.pnpm/@wordpress+hooks@4.33.0/node_modules/@wordpress/hooks/build-module/createRunHook.js
774
784
  function createRunHook(hooks, storeKey, returnFirstArg, async) {
775
785
  return function runHook(hookName, ...args) {
776
786
  const hooksStore = hooks[storeKey];
@@ -833,30 +843,31 @@ function createRunHook(hooks, storeKey, returnFirstArg, async) {
833
843
  }
834
844
  var createRunHook_default = createRunHook;
835
845
 
836
- // ../../../node_modules/.pnpm/@wordpress+hooks@4.32.0/node_modules/@wordpress/hooks/build-module/createCurrentHook.js
846
+ // ../../../node_modules/.pnpm/@wordpress+hooks@4.33.0/node_modules/@wordpress/hooks/build-module/createCurrentHook.js
837
847
  function createCurrentHook(hooks, storeKey) {
838
848
  return function currentHook() {
839
- var _currentArray$at$name;
840
849
  const hooksStore = hooks[storeKey];
841
850
  const currentArray = Array.from(hooksStore.__current);
842
- return (_currentArray$at$name = currentArray.at(-1)?.name) !== null && _currentArray$at$name !== void 0 ? _currentArray$at$name : null;
851
+ return currentArray.at(-1)?.name ?? null;
843
852
  };
844
853
  }
845
854
  var createCurrentHook_default = createCurrentHook;
846
855
 
847
- // ../../../node_modules/.pnpm/@wordpress+hooks@4.32.0/node_modules/@wordpress/hooks/build-module/createDoingHook.js
856
+ // ../../../node_modules/.pnpm/@wordpress+hooks@4.33.0/node_modules/@wordpress/hooks/build-module/createDoingHook.js
848
857
  function createDoingHook(hooks, storeKey) {
849
858
  return function doingHook(hookName) {
850
859
  const hooksStore = hooks[storeKey];
851
860
  if ("undefined" === typeof hookName) {
852
861
  return hooksStore.__current.size > 0;
853
862
  }
854
- return Array.from(hooksStore.__current).some((hook) => hook.name === hookName);
863
+ return Array.from(hooksStore.__current).some(
864
+ (hook) => hook.name === hookName
865
+ );
855
866
  };
856
867
  }
857
868
  var createDoingHook_default = createDoingHook;
858
869
 
859
- // ../../../node_modules/.pnpm/@wordpress+hooks@4.32.0/node_modules/@wordpress/hooks/build-module/createDidHook.js
870
+ // ../../../node_modules/.pnpm/@wordpress+hooks@4.33.0/node_modules/@wordpress/hooks/build-module/createDidHook.js
860
871
  function createDidHook(hooks, storeKey) {
861
872
  return function didHook(hookName) {
862
873
  const hooksStore = hooks[storeKey];
@@ -868,8 +879,28 @@ function createDidHook(hooks, storeKey) {
868
879
  }
869
880
  var createDidHook_default = createDidHook;
870
881
 
871
- // ../../../node_modules/.pnpm/@wordpress+hooks@4.32.0/node_modules/@wordpress/hooks/build-module/createHooks.js
882
+ // ../../../node_modules/.pnpm/@wordpress+hooks@4.33.0/node_modules/@wordpress/hooks/build-module/createHooks.js
872
883
  var _Hooks = class {
884
+ actions;
885
+ filters;
886
+ addAction;
887
+ addFilter;
888
+ removeAction;
889
+ removeFilter;
890
+ hasAction;
891
+ hasFilter;
892
+ removeAllActions;
893
+ removeAllFilters;
894
+ doAction;
895
+ doActionAsync;
896
+ applyFilters;
897
+ applyFiltersAsync;
898
+ currentAction;
899
+ currentFilter;
900
+ doingAction;
901
+ doingFilter;
902
+ didAction;
903
+ didFilter;
873
904
  constructor() {
874
905
  this.actions = /* @__PURE__ */ Object.create(null);
875
906
  this.actions.__current = /* @__PURE__ */ new Set();
@@ -900,7 +931,7 @@ function createHooks() {
900
931
  }
901
932
  var createHooks_default = createHooks;
902
933
 
903
- // ../../../node_modules/.pnpm/@wordpress+hooks@4.32.0/node_modules/@wordpress/hooks/build-module/index.js
934
+ // ../../../node_modules/.pnpm/@wordpress+hooks@4.33.0/node_modules/@wordpress/hooks/build-module/index.js
904
935
  var defaultHooks = createHooks_default();
905
936
  var {
906
937
  addAction,
@@ -925,17 +956,10 @@ var {
925
956
  filters
926
957
  } = defaultHooks;
927
958
 
928
- // ../../../node_modules/.pnpm/@wordpress+deprecated@4.32.0/node_modules/@wordpress/deprecated/build-module/index.js
959
+ // ../../../node_modules/.pnpm/@wordpress+deprecated@4.33.0/node_modules/@wordpress/deprecated/build-module/index.js
929
960
  var logged = /* @__PURE__ */ Object.create(null);
930
961
  function deprecated(feature, options = {}) {
931
- const {
932
- since,
933
- version,
934
- alternative,
935
- plugin,
936
- link,
937
- hint
938
- } = options;
962
+ const { since, version, alternative, plugin, link, hint } = options;
939
963
  const pluginMessage = plugin ? ` from ${plugin}` : "";
940
964
  const sinceMessage = since ? ` since version ${since}` : "";
941
965
  const versionMessage = version ? ` and will be removed${pluginMessage} in version ${version}` : "";
@@ -955,10 +979,10 @@ function deprecated(feature, options = {}) {
955
979
  import deepmerge from "deepmerge";
956
980
  import fastDeepEqual from "fast-deep-equal/es6";
957
981
 
958
- // ../../../node_modules/.pnpm/@wordpress+warning@3.32.0/node_modules/@wordpress/warning/build-module/utils.js
982
+ // ../../../node_modules/.pnpm/@wordpress+warning@3.33.0/node_modules/@wordpress/warning/build-module/utils.js
959
983
  var logged2 = /* @__PURE__ */ new Set();
960
984
 
961
- // ../../../node_modules/.pnpm/@wordpress+warning@3.32.0/node_modules/@wordpress/warning/build-module/index.js
985
+ // ../../../node_modules/.pnpm/@wordpress+warning@3.33.0/node_modules/@wordpress/warning/build-module/index.js
962
986
  function isDev() {
963
987
  return globalThis.SCRIPT_DEBUG === true;
964
988
  }
@@ -4233,7 +4257,9 @@ var BarWithLabel = ({
4233
4257
  withComparison,
4234
4258
  withOverlayLabel,
4235
4259
  primaryColor,
4236
- secondaryColor
4260
+ secondaryColor,
4261
+ isPrimaryVisible = true,
4262
+ isComparisonVisible = true
4237
4263
  }) => /* @__PURE__ */ jsxs(
4238
4264
  "div",
4239
4265
  {
@@ -4242,7 +4268,7 @@ var BarWithLabel = ({
4242
4268
  }),
4243
4269
  children: [
4244
4270
  /* @__PURE__ */ jsx3(BarLabel, { label: entry.label }),
4245
- /* @__PURE__ */ jsx3(
4271
+ isPrimaryVisible && /* @__PURE__ */ jsx3(
4246
4272
  "div",
4247
4273
  {
4248
4274
  className: leaderboard_chart_module_default.bar,
@@ -4252,7 +4278,7 @@ var BarWithLabel = ({
4252
4278
  }
4253
4279
  }
4254
4280
  ),
4255
- withComparison && !withOverlayLabel && /* @__PURE__ */ jsx3(
4281
+ withComparison && !withOverlayLabel && isComparisonVisible && /* @__PURE__ */ jsx3(
4256
4282
  "div",
4257
4283
  {
4258
4284
  className: leaderboard_chart_module_default.bar,
@@ -4283,6 +4309,7 @@ var LeaderboardChartInternal = ({
4283
4309
  legendShapeWidth = 8,
4284
4310
  legendShapeHeight = 8,
4285
4311
  legendLabels,
4312
+ legendInteractive = false,
4286
4313
  className,
4287
4314
  style,
4288
4315
  children
@@ -4298,7 +4325,7 @@ var LeaderboardChartInternal = ({
4298
4325
  secondaryColor: settingsSecondaryColor,
4299
4326
  deltaColors
4300
4327
  } = leaderboardChartSettings;
4301
- const { getElementStyles } = useGlobalChartsContext();
4328
+ const { getElementStyles, isSeriesVisible } = useGlobalChartsContext();
4302
4329
  const { color: resolvedPrimaryColor } = getElementStyles({
4303
4330
  index: 0,
4304
4331
  overrideColor: primaryColor || settingsPrimaryColor
@@ -4315,6 +4342,31 @@ var LeaderboardChartInternal = ({
4315
4342
  withOverlayLabel,
4316
4343
  legendLabels
4317
4344
  });
4345
+ const isPrimaryVisible = useMemo3(() => {
4346
+ if (!chartId || !legendInteractive || legendItems.length === 0) {
4347
+ return true;
4348
+ }
4349
+ return isSeriesVisible(chartId, legendItems[0].label);
4350
+ }, [chartId, legendInteractive, legendItems, isSeriesVisible]);
4351
+ const isComparisonVisible = useMemo3(() => {
4352
+ if (!chartId || !legendInteractive || legendItems.length < 2) {
4353
+ return true;
4354
+ }
4355
+ return isSeriesVisible(chartId, legendItems[1].label);
4356
+ }, [chartId, legendInteractive, legendItems, isSeriesVisible]);
4357
+ const allSeriesHidden = useMemo3(() => {
4358
+ if (!legendInteractive) return false;
4359
+ if (withComparison && !withOverlayLabel) {
4360
+ return !isPrimaryVisible && !isComparisonVisible;
4361
+ }
4362
+ return !isPrimaryVisible;
4363
+ }, [
4364
+ legendInteractive,
4365
+ isPrimaryVisible,
4366
+ isComparisonVisible,
4367
+ withComparison,
4368
+ withOverlayLabel
4369
+ ]);
4318
4370
  const isDataValid = Boolean(data && data.length > 0);
4319
4371
  const chartMetadata = useMemo3(
4320
4372
  () => ({
@@ -4374,7 +4426,7 @@ var LeaderboardChartInternal = ({
4374
4426
  gap: showLegend ? "16px" : "0"
4375
4427
  },
4376
4428
  children: [
4377
- /* @__PURE__ */ jsx3(component_default6, { templateColumns: "minmax(0, 1fr) auto", rowGap, columnGap, children: data.map((entry) => {
4429
+ allSeriesHidden ? /* @__PURE__ */ jsx3("div", { className: leaderboard_chart_module_default.emptyState, children: __2("All series are hidden. Click legend items to show data.", "jetpack-charts") }) : /* @__PURE__ */ jsx3(component_default6, { templateColumns: "minmax(0, 1fr) auto", rowGap, columnGap, children: data.map((entry) => {
4378
4430
  const colorIndex = Math.sign(entry.delta) + 1;
4379
4431
  const deltaColor = deltaColors[colorIndex];
4380
4432
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -4385,7 +4437,9 @@ var LeaderboardChartInternal = ({
4385
4437
  withComparison,
4386
4438
  withOverlayLabel,
4387
4439
  primaryColor: resolvedPrimaryColor,
4388
- secondaryColor: resolvedSecondaryColor
4440
+ secondaryColor: resolvedSecondaryColor,
4441
+ isPrimaryVisible,
4442
+ isComparisonVisible
4389
4443
  }
4390
4444
  ) }),
4391
4445
  /* @__PURE__ */ jsxs(
@@ -4395,8 +4449,8 @@ var LeaderboardChartInternal = ({
4395
4449
  [leaderboard_chart_module_default.overlayLabel]: withOverlayLabel
4396
4450
  }),
4397
4451
  children: [
4398
- /* @__PURE__ */ jsx3(component_default4, { children: valueFormatter(entry.currentValue) }),
4399
- withComparison && /* @__PURE__ */ jsx3(component_default4, { style: { color: deltaColor }, children: deltaFormatter(entry.delta) })
4452
+ isPrimaryVisible && /* @__PURE__ */ jsx3(component_default4, { children: valueFormatter(entry.currentValue) }),
4453
+ withComparison && isComparisonVisible && /* @__PURE__ */ jsx3(component_default4, { style: { color: deltaColor }, children: deltaFormatter(entry.delta) })
4400
4454
  ]
4401
4455
  }
4402
4456
  )
@@ -4411,7 +4465,8 @@ var LeaderboardChartInternal = ({
4411
4465
  shape: legendShape,
4412
4466
  shapeWidth: legendShapeWidth,
4413
4467
  shapeHeight: legendShapeHeight,
4414
- chartId
4468
+ chartId,
4469
+ interactive: legendInteractive
4415
4470
  }
4416
4471
  ),
4417
4472
  otherChildren
@@ -4474,4 +4529,4 @@ is-plain-object/dist/is-plain-object.mjs:
4474
4529
  * Released under the MIT License.
4475
4530
  *)
4476
4531
  */
4477
- //# sourceMappingURL=chunk-2HB55BRH.js.map
4532
+ //# sourceMappingURL=chunk-4H3J2HCD.js.map