@automattic/charts 0.16.2 → 0.18.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 (330) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/_virtual/index.js +2 -0
  3. package/dist/cjs/_virtual/index.js.map +1 -0
  4. package/dist/cjs/_virtual/react-is.development.js +2 -0
  5. package/dist/cjs/_virtual/react-is.development.js.map +1 -0
  6. package/dist/cjs/_virtual/react-is.production.min.js +2 -0
  7. package/dist/cjs/_virtual/react-is.production.min.js.map +1 -0
  8. package/dist/cjs/_virtual/sprintf.js +2 -0
  9. package/dist/cjs/_virtual/sprintf.js.map +1 -0
  10. package/dist/cjs/components/bar-chart/bar-chart.js +1 -1
  11. package/dist/cjs/components/bar-chart/bar-chart.js.map +1 -1
  12. package/dist/cjs/components/bar-chart/use-bar-chart-options.js +1 -1
  13. package/dist/cjs/components/bar-chart/use-bar-chart-options.js.map +1 -1
  14. package/dist/cjs/components/bar-list-chart/bar-list-chart.js +1 -1
  15. package/dist/cjs/components/bar-list-chart/bar-list-chart.js.map +1 -1
  16. package/dist/cjs/components/leaderboard-chart/leaderboard-chart.js +2 -0
  17. package/dist/cjs/components/leaderboard-chart/leaderboard-chart.js.map +1 -0
  18. package/dist/cjs/components/leaderboard-chart/leaderboard-chart.module.scss.js +2 -0
  19. package/dist/cjs/components/leaderboard-chart/leaderboard-chart.module.scss.js.map +1 -0
  20. package/dist/cjs/components/legend/base-legend.js +1 -1
  21. package/dist/cjs/components/legend/base-legend.js.map +1 -1
  22. package/dist/cjs/components/line-chart/line-chart-annotation-label-popover.js +2 -0
  23. package/dist/cjs/components/line-chart/line-chart-annotation-label-popover.js.map +1 -0
  24. package/dist/cjs/components/line-chart/line-chart-annotation.js +1 -1
  25. package/dist/cjs/components/line-chart/line-chart-annotation.js.map +1 -1
  26. package/dist/cjs/components/line-chart/line-chart-annotations-overlay.js +2 -0
  27. package/dist/cjs/components/line-chart/line-chart-annotations-overlay.js.map +1 -0
  28. package/dist/cjs/components/line-chart/line-chart-context.js +2 -0
  29. package/dist/cjs/components/line-chart/line-chart-context.js.map +1 -0
  30. package/dist/cjs/components/line-chart/line-chart.js +1 -1
  31. package/dist/cjs/components/line-chart/line-chart.js.map +1 -1
  32. package/dist/cjs/components/line-chart/line-chart.module.scss.js +1 -1
  33. package/dist/cjs/components/pie-chart/pie-chart.js +1 -1
  34. package/dist/cjs/components/pie-chart/pie-chart.js.map +1 -1
  35. package/dist/cjs/components/pie-semi-circle-chart/pie-semi-circle-chart.js +1 -1
  36. package/dist/cjs/components/pie-semi-circle-chart/pie-semi-circle-chart.js.map +1 -1
  37. package/dist/cjs/components/shared/format-metric-value.js +2 -0
  38. package/dist/cjs/components/shared/format-metric-value.js.map +1 -0
  39. package/dist/cjs/components/shared/use-chart-data-transform.js +1 -1
  40. package/dist/cjs/components/shared/use-chart-data-transform.js.map +1 -1
  41. package/dist/cjs/components/shared/use-chart-margin.js +1 -1
  42. package/dist/cjs/components/shared/use-chart-margin.js.map +1 -1
  43. package/dist/cjs/components/shared/use-element-height.js +1 -1
  44. package/dist/cjs/components/shared/use-element-height.js.map +1 -1
  45. package/dist/cjs/components/shared/utils.js +1 -1
  46. package/dist/cjs/components/shared/utils.js.map +1 -1
  47. package/dist/cjs/components/tooltip/accessible-tooltip.js +2 -0
  48. package/dist/cjs/components/tooltip/accessible-tooltip.js.map +1 -0
  49. package/dist/cjs/hooks/use-chart-mouse-handler.js +1 -1
  50. package/dist/cjs/hooks/use-chart-mouse-handler.js.map +1 -1
  51. package/dist/cjs/index.js +1 -1
  52. package/dist/cjs/node_modules/.pnpm/@emotion_cache@11.14.0/node_modules/@emotion/cache/dist/emotion-cache.esm.js +2 -0
  53. package/dist/cjs/node_modules/.pnpm/@emotion_cache@11.14.0/node_modules/@emotion/cache/dist/emotion-cache.esm.js.map +1 -0
  54. package/dist/cjs/node_modules/.pnpm/@emotion_hash@0.9.2/node_modules/@emotion/hash/dist/emotion-hash.esm.js +2 -0
  55. package/dist/cjs/node_modules/.pnpm/@emotion_hash@0.9.2/node_modules/@emotion/hash/dist/emotion-hash.esm.js.map +1 -0
  56. package/dist/cjs/node_modules/.pnpm/@emotion_is-prop-valid@1.3.1/node_modules/@emotion/is-prop-valid/dist/emotion-is-prop-valid.esm.js +2 -0
  57. package/dist/cjs/node_modules/.pnpm/@emotion_is-prop-valid@1.3.1/node_modules/@emotion/is-prop-valid/dist/emotion-is-prop-valid.esm.js.map +1 -0
  58. package/dist/cjs/node_modules/.pnpm/@emotion_memoize@0.9.0/node_modules/@emotion/memoize/dist/emotion-memoize.esm.js +2 -0
  59. package/dist/cjs/node_modules/.pnpm/@emotion_memoize@0.9.0/node_modules/@emotion/memoize/dist/emotion-memoize.esm.js.map +1 -0
  60. package/dist/cjs/node_modules/.pnpm/@emotion_react@11.14.0_@types_react@18.3.23_react@18.3.1/node_modules/@emotion/react/dist/emotion-element-d59e098f.esm.js +2 -0
  61. package/dist/cjs/node_modules/.pnpm/@emotion_react@11.14.0_@types_react@18.3.23_react@18.3.1/node_modules/@emotion/react/dist/emotion-element-d59e098f.esm.js.map +1 -0
  62. package/dist/cjs/node_modules/.pnpm/@emotion_react@11.14.0_@types_react@18.3.23_react@18.3.1/node_modules/@emotion/react/dist/emotion-react.esm.js +2 -0
  63. package/dist/cjs/node_modules/.pnpm/@emotion_react@11.14.0_@types_react@18.3.23_react@18.3.1/node_modules/@emotion/react/dist/emotion-react.esm.js.map +1 -0
  64. package/dist/cjs/node_modules/.pnpm/@emotion_serialize@1.3.3/node_modules/@emotion/serialize/dist/emotion-serialize.esm.js +2 -0
  65. package/dist/cjs/node_modules/.pnpm/@emotion_serialize@1.3.3/node_modules/@emotion/serialize/dist/emotion-serialize.esm.js.map +1 -0
  66. package/dist/cjs/node_modules/.pnpm/@emotion_sheet@1.4.0/node_modules/@emotion/sheet/dist/emotion-sheet.esm.js +2 -0
  67. package/dist/cjs/node_modules/.pnpm/@emotion_sheet@1.4.0/node_modules/@emotion/sheet/dist/emotion-sheet.esm.js.map +1 -0
  68. package/dist/cjs/node_modules/.pnpm/@emotion_styled@11.14.0_@emotion_react@11.14.0_@types_react@18.3.23_react@18.3.1__@types_react@18.3.23_react@18.3.1/node_modules/@emotion/styled/base/dist/emotion-styled-base.esm.js +2 -0
  69. package/dist/cjs/node_modules/.pnpm/@emotion_styled@11.14.0_@emotion_react@11.14.0_@types_react@18.3.23_react@18.3.1__@types_react@18.3.23_react@18.3.1/node_modules/@emotion/styled/base/dist/emotion-styled-base.esm.js.map +1 -0
  70. package/dist/cjs/node_modules/.pnpm/@emotion_unitless@0.10.0/node_modules/@emotion/unitless/dist/emotion-unitless.esm.js +2 -0
  71. package/dist/cjs/node_modules/.pnpm/@emotion_unitless@0.10.0/node_modules/@emotion/unitless/dist/emotion-unitless.esm.js.map +1 -0
  72. package/dist/cjs/node_modules/.pnpm/@emotion_use-insertion-effect-with-fallbacks@1.2.0_react@18.3.1/node_modules/@emotion/use-insertion-effect-with-fallbacks/dist/emotion-use-insertion-effect-with-fallbacks.esm.js +2 -0
  73. package/dist/cjs/node_modules/.pnpm/@emotion_use-insertion-effect-with-fallbacks@1.2.0_react@18.3.1/node_modules/@emotion/use-insertion-effect-with-fallbacks/dist/emotion-use-insertion-effect-with-fallbacks.esm.js.map +1 -0
  74. package/dist/cjs/node_modules/.pnpm/@emotion_utils@1.4.2/node_modules/@emotion/utils/dist/emotion-utils.esm.js +2 -0
  75. package/dist/cjs/node_modules/.pnpm/@emotion_utils@1.4.2/node_modules/@emotion/utils/dist/emotion-utils.esm.js.map +1 -0
  76. package/dist/cjs/node_modules/.pnpm/@emotion_weak-memoize@0.4.0/node_modules/@emotion/weak-memoize/dist/emotion-weak-memoize.esm.js +2 -0
  77. package/dist/cjs/node_modules/.pnpm/@emotion_weak-memoize@0.4.0/node_modules/@emotion/weak-memoize/dist/emotion-weak-memoize.esm.js.map +1 -0
  78. package/dist/cjs/node_modules/.pnpm/@tannin_compile@1.1.0/node_modules/@tannin/compile/index.js +2 -0
  79. package/dist/cjs/node_modules/.pnpm/@tannin_compile@1.1.0/node_modules/@tannin/compile/index.js.map +1 -0
  80. package/dist/cjs/node_modules/.pnpm/@tannin_evaluate@1.2.0/node_modules/@tannin/evaluate/index.js +2 -0
  81. package/dist/cjs/node_modules/.pnpm/@tannin_evaluate@1.2.0/node_modules/@tannin/evaluate/index.js.map +1 -0
  82. package/dist/cjs/node_modules/.pnpm/@tannin_plural-forms@1.1.0/node_modules/@tannin/plural-forms/index.js +2 -0
  83. package/dist/cjs/node_modules/.pnpm/@tannin_plural-forms@1.1.0/node_modules/@tannin/plural-forms/index.js.map +1 -0
  84. package/dist/cjs/node_modules/.pnpm/@tannin_postfix@1.1.0/node_modules/@tannin/postfix/index.js +2 -0
  85. package/dist/cjs/node_modules/.pnpm/@tannin_postfix@1.1.0/node_modules/@tannin/postfix/index.js.map +1 -0
  86. package/dist/cjs/node_modules/.pnpm/@wordpress_components@29.12.0_@types_react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/progress-bar/index.js +2 -0
  87. package/dist/cjs/node_modules/.pnpm/@wordpress_components@29.12.0_@types_react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/progress-bar/index.js.map +1 -0
  88. package/dist/cjs/node_modules/.pnpm/@wordpress_components@29.12.0_@types_react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/progress-bar/styles.js +2 -0
  89. package/dist/cjs/node_modules/.pnpm/@wordpress_components@29.12.0_@types_react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/progress-bar/styles.js.map +1 -0
  90. package/dist/cjs/node_modules/.pnpm/@wordpress_components@29.12.0_@types_react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/colors-values.js +2 -0
  91. package/dist/cjs/node_modules/.pnpm/@wordpress_components@29.12.0_@types_react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/colors-values.js.map +1 -0
  92. package/dist/cjs/node_modules/.pnpm/@wordpress_components@29.12.0_@types_react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/config-values.js +2 -0
  93. package/dist/cjs/node_modules/.pnpm/@wordpress_components@29.12.0_@types_react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/config-values.js.map +1 -0
  94. package/dist/cjs/node_modules/.pnpm/@wordpress_components@29.12.0_@types_react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/space.js +2 -0
  95. package/dist/cjs/node_modules/.pnpm/@wordpress_components@29.12.0_@types_react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/space.js.map +1 -0
  96. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createAddHook.js +2 -0
  97. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createAddHook.js.map +1 -0
  98. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createCurrentHook.js +2 -0
  99. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createCurrentHook.js.map +1 -0
  100. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createDidHook.js +2 -0
  101. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createDidHook.js.map +1 -0
  102. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createDoingHook.js +2 -0
  103. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createDoingHook.js.map +1 -0
  104. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createHasHook.js +2 -0
  105. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createHasHook.js.map +1 -0
  106. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createHooks.js +2 -0
  107. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createHooks.js.map +1 -0
  108. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createRemoveHook.js +2 -0
  109. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createRemoveHook.js.map +1 -0
  110. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createRunHook.js +2 -0
  111. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createRunHook.js.map +1 -0
  112. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/index.js +2 -0
  113. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/index.js.map +1 -0
  114. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/validateHookName.js +2 -0
  115. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/validateHookName.js.map +1 -0
  116. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/validateNamespace.js +2 -0
  117. package/dist/cjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/validateNamespace.js.map +1 -0
  118. package/dist/cjs/node_modules/.pnpm/@wordpress_i18n@5.26.0/node_modules/@wordpress/i18n/build-module/create-i18n.js +2 -0
  119. package/dist/cjs/node_modules/.pnpm/@wordpress_i18n@5.26.0/node_modules/@wordpress/i18n/build-module/create-i18n.js.map +1 -0
  120. package/dist/cjs/node_modules/.pnpm/@wordpress_i18n@5.26.0/node_modules/@wordpress/i18n/build-module/default-i18n.js +2 -0
  121. package/dist/cjs/node_modules/.pnpm/@wordpress_i18n@5.26.0/node_modules/@wordpress/i18n/build-module/default-i18n.js.map +1 -0
  122. package/dist/cjs/node_modules/.pnpm/hoist-non-react-statics@3.3.2/node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js +2 -0
  123. package/dist/cjs/node_modules/.pnpm/hoist-non-react-statics@3.3.2/node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js.map +1 -0
  124. package/dist/cjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js +10 -0
  125. package/dist/cjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js.map +1 -0
  126. package/dist/cjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.production.min.js +10 -0
  127. package/dist/cjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.production.min.js.map +1 -0
  128. package/dist/cjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/index.js +2 -0
  129. package/dist/cjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/index.js.map +1 -0
  130. package/dist/cjs/node_modules/.pnpm/sprintf-js@1.1.3/node_modules/sprintf-js/src/sprintf.js +2 -0
  131. package/dist/cjs/node_modules/.pnpm/sprintf-js@1.1.3/node_modules/sprintf-js/src/sprintf.js.map +1 -0
  132. package/dist/cjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Enum.js +2 -0
  133. package/dist/cjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Enum.js.map +1 -0
  134. package/dist/cjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Middleware.js +2 -0
  135. package/dist/cjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Middleware.js.map +1 -0
  136. package/dist/cjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Parser.js +2 -0
  137. package/dist/cjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Parser.js.map +1 -0
  138. package/dist/cjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Serializer.js +2 -0
  139. package/dist/cjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Serializer.js.map +1 -0
  140. package/dist/cjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Tokenizer.js +2 -0
  141. package/dist/cjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Tokenizer.js.map +1 -0
  142. package/dist/cjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Utility.js +2 -0
  143. package/dist/cjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Utility.js.map +1 -0
  144. package/dist/cjs/node_modules/.pnpm/tannin@1.2.0/node_modules/tannin/index.js +2 -0
  145. package/dist/cjs/node_modules/.pnpm/tannin@1.2.0/node_modules/tannin/index.js.map +1 -0
  146. package/dist/cjs/providers/chart-context/chart-context.js +2 -0
  147. package/dist/cjs/providers/chart-context/chart-context.js.map +1 -0
  148. package/dist/cjs/providers/chart-context/utils.js +2 -0
  149. package/dist/cjs/providers/chart-context/utils.js.map +1 -0
  150. package/dist/cjs/providers/theme/theme-provider.js +1 -1
  151. package/dist/cjs/providers/theme/theme-provider.js.map +1 -1
  152. package/dist/cjs/style.css +1 -1
  153. package/dist/index.d.ts +151 -20
  154. package/dist/mjs/_virtual/index.js +2 -0
  155. package/dist/mjs/_virtual/index.js.map +1 -0
  156. package/dist/mjs/_virtual/react-is.development.js +2 -0
  157. package/dist/mjs/_virtual/react-is.development.js.map +1 -0
  158. package/dist/mjs/_virtual/react-is.production.min.js +2 -0
  159. package/dist/mjs/_virtual/react-is.production.min.js.map +1 -0
  160. package/dist/mjs/_virtual/sprintf.js +2 -0
  161. package/dist/mjs/_virtual/sprintf.js.map +1 -0
  162. package/dist/mjs/components/bar-chart/bar-chart.js +1 -1
  163. package/dist/mjs/components/bar-chart/bar-chart.js.map +1 -1
  164. package/dist/mjs/components/bar-chart/use-bar-chart-options.js +1 -1
  165. package/dist/mjs/components/bar-chart/use-bar-chart-options.js.map +1 -1
  166. package/dist/mjs/components/bar-list-chart/bar-list-chart.js +1 -1
  167. package/dist/mjs/components/bar-list-chart/bar-list-chart.js.map +1 -1
  168. package/dist/mjs/components/leaderboard-chart/leaderboard-chart.js +2 -0
  169. package/dist/mjs/components/leaderboard-chart/leaderboard-chart.js.map +1 -0
  170. package/dist/mjs/components/leaderboard-chart/leaderboard-chart.module.scss.js +2 -0
  171. package/dist/mjs/components/leaderboard-chart/leaderboard-chart.module.scss.js.map +1 -0
  172. package/dist/mjs/components/legend/base-legend.js +1 -1
  173. package/dist/mjs/components/legend/base-legend.js.map +1 -1
  174. package/dist/mjs/components/line-chart/line-chart-annotation-label-popover.js +2 -0
  175. package/dist/mjs/components/line-chart/line-chart-annotation-label-popover.js.map +1 -0
  176. package/dist/mjs/components/line-chart/line-chart-annotation.js +1 -1
  177. package/dist/mjs/components/line-chart/line-chart-annotation.js.map +1 -1
  178. package/dist/mjs/components/line-chart/line-chart-annotations-overlay.js +2 -0
  179. package/dist/mjs/components/line-chart/line-chart-annotations-overlay.js.map +1 -0
  180. package/dist/mjs/components/line-chart/line-chart-context.js +2 -0
  181. package/dist/mjs/components/line-chart/line-chart-context.js.map +1 -0
  182. package/dist/mjs/components/line-chart/line-chart.js +1 -1
  183. package/dist/mjs/components/line-chart/line-chart.js.map +1 -1
  184. package/dist/mjs/components/line-chart/line-chart.module.scss.js +1 -1
  185. package/dist/mjs/components/pie-chart/pie-chart.js +1 -1
  186. package/dist/mjs/components/pie-chart/pie-chart.js.map +1 -1
  187. package/dist/mjs/components/pie-semi-circle-chart/pie-semi-circle-chart.js +1 -1
  188. package/dist/mjs/components/pie-semi-circle-chart/pie-semi-circle-chart.js.map +1 -1
  189. package/dist/mjs/components/shared/format-metric-value.js +2 -0
  190. package/dist/mjs/components/shared/format-metric-value.js.map +1 -0
  191. package/dist/mjs/components/shared/use-chart-data-transform.js +1 -1
  192. package/dist/mjs/components/shared/use-chart-data-transform.js.map +1 -1
  193. package/dist/mjs/components/shared/use-chart-margin.js +1 -1
  194. package/dist/mjs/components/shared/use-chart-margin.js.map +1 -1
  195. package/dist/mjs/components/shared/use-element-height.js +1 -1
  196. package/dist/mjs/components/shared/use-element-height.js.map +1 -1
  197. package/dist/mjs/components/shared/utils.js +1 -1
  198. package/dist/mjs/components/shared/utils.js.map +1 -1
  199. package/dist/mjs/components/tooltip/accessible-tooltip.js +2 -0
  200. package/dist/mjs/components/tooltip/accessible-tooltip.js.map +1 -0
  201. package/dist/mjs/hooks/use-chart-mouse-handler.js +1 -1
  202. package/dist/mjs/hooks/use-chart-mouse-handler.js.map +1 -1
  203. package/dist/mjs/index.js +1 -1
  204. package/dist/mjs/node_modules/.pnpm/@emotion_cache@11.14.0/node_modules/@emotion/cache/dist/emotion-cache.esm.js +2 -0
  205. package/dist/mjs/node_modules/.pnpm/@emotion_cache@11.14.0/node_modules/@emotion/cache/dist/emotion-cache.esm.js.map +1 -0
  206. package/dist/mjs/node_modules/.pnpm/@emotion_hash@0.9.2/node_modules/@emotion/hash/dist/emotion-hash.esm.js +2 -0
  207. package/dist/mjs/node_modules/.pnpm/@emotion_hash@0.9.2/node_modules/@emotion/hash/dist/emotion-hash.esm.js.map +1 -0
  208. package/dist/mjs/node_modules/.pnpm/@emotion_is-prop-valid@1.3.1/node_modules/@emotion/is-prop-valid/dist/emotion-is-prop-valid.esm.js +2 -0
  209. package/dist/mjs/node_modules/.pnpm/@emotion_is-prop-valid@1.3.1/node_modules/@emotion/is-prop-valid/dist/emotion-is-prop-valid.esm.js.map +1 -0
  210. package/dist/mjs/node_modules/.pnpm/@emotion_memoize@0.9.0/node_modules/@emotion/memoize/dist/emotion-memoize.esm.js +2 -0
  211. package/dist/mjs/node_modules/.pnpm/@emotion_memoize@0.9.0/node_modules/@emotion/memoize/dist/emotion-memoize.esm.js.map +1 -0
  212. package/dist/mjs/node_modules/.pnpm/@emotion_react@11.14.0_@types_react@18.3.23_react@18.3.1/node_modules/@emotion/react/dist/emotion-element-d59e098f.esm.js +2 -0
  213. package/dist/mjs/node_modules/.pnpm/@emotion_react@11.14.0_@types_react@18.3.23_react@18.3.1/node_modules/@emotion/react/dist/emotion-element-d59e098f.esm.js.map +1 -0
  214. package/dist/mjs/node_modules/.pnpm/@emotion_react@11.14.0_@types_react@18.3.23_react@18.3.1/node_modules/@emotion/react/dist/emotion-react.esm.js +2 -0
  215. package/dist/mjs/node_modules/.pnpm/@emotion_react@11.14.0_@types_react@18.3.23_react@18.3.1/node_modules/@emotion/react/dist/emotion-react.esm.js.map +1 -0
  216. package/dist/mjs/node_modules/.pnpm/@emotion_serialize@1.3.3/node_modules/@emotion/serialize/dist/emotion-serialize.esm.js +2 -0
  217. package/dist/mjs/node_modules/.pnpm/@emotion_serialize@1.3.3/node_modules/@emotion/serialize/dist/emotion-serialize.esm.js.map +1 -0
  218. package/dist/mjs/node_modules/.pnpm/@emotion_sheet@1.4.0/node_modules/@emotion/sheet/dist/emotion-sheet.esm.js +2 -0
  219. package/dist/mjs/node_modules/.pnpm/@emotion_sheet@1.4.0/node_modules/@emotion/sheet/dist/emotion-sheet.esm.js.map +1 -0
  220. package/dist/mjs/node_modules/.pnpm/@emotion_styled@11.14.0_@emotion_react@11.14.0_@types_react@18.3.23_react@18.3.1__@types_react@18.3.23_react@18.3.1/node_modules/@emotion/styled/base/dist/emotion-styled-base.esm.js +2 -0
  221. package/dist/mjs/node_modules/.pnpm/@emotion_styled@11.14.0_@emotion_react@11.14.0_@types_react@18.3.23_react@18.3.1__@types_react@18.3.23_react@18.3.1/node_modules/@emotion/styled/base/dist/emotion-styled-base.esm.js.map +1 -0
  222. package/dist/mjs/node_modules/.pnpm/@emotion_unitless@0.10.0/node_modules/@emotion/unitless/dist/emotion-unitless.esm.js +2 -0
  223. package/dist/mjs/node_modules/.pnpm/@emotion_unitless@0.10.0/node_modules/@emotion/unitless/dist/emotion-unitless.esm.js.map +1 -0
  224. package/dist/mjs/node_modules/.pnpm/@emotion_use-insertion-effect-with-fallbacks@1.2.0_react@18.3.1/node_modules/@emotion/use-insertion-effect-with-fallbacks/dist/emotion-use-insertion-effect-with-fallbacks.esm.js +2 -0
  225. package/dist/mjs/node_modules/.pnpm/@emotion_use-insertion-effect-with-fallbacks@1.2.0_react@18.3.1/node_modules/@emotion/use-insertion-effect-with-fallbacks/dist/emotion-use-insertion-effect-with-fallbacks.esm.js.map +1 -0
  226. package/dist/mjs/node_modules/.pnpm/@emotion_utils@1.4.2/node_modules/@emotion/utils/dist/emotion-utils.esm.js +2 -0
  227. package/dist/mjs/node_modules/.pnpm/@emotion_utils@1.4.2/node_modules/@emotion/utils/dist/emotion-utils.esm.js.map +1 -0
  228. package/dist/mjs/node_modules/.pnpm/@emotion_weak-memoize@0.4.0/node_modules/@emotion/weak-memoize/dist/emotion-weak-memoize.esm.js +2 -0
  229. package/dist/mjs/node_modules/.pnpm/@emotion_weak-memoize@0.4.0/node_modules/@emotion/weak-memoize/dist/emotion-weak-memoize.esm.js.map +1 -0
  230. package/dist/mjs/node_modules/.pnpm/@tannin_compile@1.1.0/node_modules/@tannin/compile/index.js +2 -0
  231. package/dist/mjs/node_modules/.pnpm/@tannin_compile@1.1.0/node_modules/@tannin/compile/index.js.map +1 -0
  232. package/dist/mjs/node_modules/.pnpm/@tannin_evaluate@1.2.0/node_modules/@tannin/evaluate/index.js +2 -0
  233. package/dist/mjs/node_modules/.pnpm/@tannin_evaluate@1.2.0/node_modules/@tannin/evaluate/index.js.map +1 -0
  234. package/dist/mjs/node_modules/.pnpm/@tannin_plural-forms@1.1.0/node_modules/@tannin/plural-forms/index.js +2 -0
  235. package/dist/mjs/node_modules/.pnpm/@tannin_plural-forms@1.1.0/node_modules/@tannin/plural-forms/index.js.map +1 -0
  236. package/dist/mjs/node_modules/.pnpm/@tannin_postfix@1.1.0/node_modules/@tannin/postfix/index.js +2 -0
  237. package/dist/mjs/node_modules/.pnpm/@tannin_postfix@1.1.0/node_modules/@tannin/postfix/index.js.map +1 -0
  238. package/dist/mjs/node_modules/.pnpm/@wordpress_components@29.12.0_@types_react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/progress-bar/index.js +2 -0
  239. package/dist/mjs/node_modules/.pnpm/@wordpress_components@29.12.0_@types_react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/progress-bar/index.js.map +1 -0
  240. package/dist/mjs/node_modules/.pnpm/@wordpress_components@29.12.0_@types_react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/progress-bar/styles.js +2 -0
  241. package/dist/mjs/node_modules/.pnpm/@wordpress_components@29.12.0_@types_react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/progress-bar/styles.js.map +1 -0
  242. package/dist/mjs/node_modules/.pnpm/@wordpress_components@29.12.0_@types_react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/colors-values.js +2 -0
  243. package/dist/mjs/node_modules/.pnpm/@wordpress_components@29.12.0_@types_react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/colors-values.js.map +1 -0
  244. package/dist/mjs/node_modules/.pnpm/@wordpress_components@29.12.0_@types_react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/config-values.js +2 -0
  245. package/dist/mjs/node_modules/.pnpm/@wordpress_components@29.12.0_@types_react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/config-values.js.map +1 -0
  246. package/dist/mjs/node_modules/.pnpm/@wordpress_components@29.12.0_@types_react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/space.js +2 -0
  247. package/dist/mjs/node_modules/.pnpm/@wordpress_components@29.12.0_@types_react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/space.js.map +1 -0
  248. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createAddHook.js +2 -0
  249. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createAddHook.js.map +1 -0
  250. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createCurrentHook.js +2 -0
  251. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createCurrentHook.js.map +1 -0
  252. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createDidHook.js +2 -0
  253. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createDidHook.js.map +1 -0
  254. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createDoingHook.js +2 -0
  255. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createDoingHook.js.map +1 -0
  256. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createHasHook.js +2 -0
  257. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createHasHook.js.map +1 -0
  258. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createHooks.js +2 -0
  259. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createHooks.js.map +1 -0
  260. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createRemoveHook.js +2 -0
  261. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createRemoveHook.js.map +1 -0
  262. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createRunHook.js +2 -0
  263. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/createRunHook.js.map +1 -0
  264. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/index.js +2 -0
  265. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/index.js.map +1 -0
  266. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/validateHookName.js +2 -0
  267. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/validateHookName.js.map +1 -0
  268. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/validateNamespace.js +2 -0
  269. package/dist/mjs/node_modules/.pnpm/@wordpress_hooks@4.26.0/node_modules/@wordpress/hooks/build-module/validateNamespace.js.map +1 -0
  270. package/dist/mjs/node_modules/.pnpm/@wordpress_i18n@5.26.0/node_modules/@wordpress/i18n/build-module/create-i18n.js +2 -0
  271. package/dist/mjs/node_modules/.pnpm/@wordpress_i18n@5.26.0/node_modules/@wordpress/i18n/build-module/create-i18n.js.map +1 -0
  272. package/dist/mjs/node_modules/.pnpm/@wordpress_i18n@5.26.0/node_modules/@wordpress/i18n/build-module/default-i18n.js +2 -0
  273. package/dist/mjs/node_modules/.pnpm/@wordpress_i18n@5.26.0/node_modules/@wordpress/i18n/build-module/default-i18n.js.map +1 -0
  274. package/dist/mjs/node_modules/.pnpm/hoist-non-react-statics@3.3.2/node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js +2 -0
  275. package/dist/mjs/node_modules/.pnpm/hoist-non-react-statics@3.3.2/node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js.map +1 -0
  276. package/dist/mjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js +10 -0
  277. package/dist/mjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js.map +1 -0
  278. package/dist/mjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.production.min.js +10 -0
  279. package/dist/mjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.production.min.js.map +1 -0
  280. package/dist/mjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/index.js +2 -0
  281. package/dist/mjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/index.js.map +1 -0
  282. package/dist/mjs/node_modules/.pnpm/sprintf-js@1.1.3/node_modules/sprintf-js/src/sprintf.js +2 -0
  283. package/dist/mjs/node_modules/.pnpm/sprintf-js@1.1.3/node_modules/sprintf-js/src/sprintf.js.map +1 -0
  284. package/dist/mjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Enum.js +2 -0
  285. package/dist/mjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Enum.js.map +1 -0
  286. package/dist/mjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Middleware.js +2 -0
  287. package/dist/mjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Middleware.js.map +1 -0
  288. package/dist/mjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Parser.js +2 -0
  289. package/dist/mjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Parser.js.map +1 -0
  290. package/dist/mjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Serializer.js +2 -0
  291. package/dist/mjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Serializer.js.map +1 -0
  292. package/dist/mjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Tokenizer.js +2 -0
  293. package/dist/mjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Tokenizer.js.map +1 -0
  294. package/dist/mjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Utility.js +2 -0
  295. package/dist/mjs/node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Utility.js.map +1 -0
  296. package/dist/mjs/node_modules/.pnpm/tannin@1.2.0/node_modules/tannin/index.js +2 -0
  297. package/dist/mjs/node_modules/.pnpm/tannin@1.2.0/node_modules/tannin/index.js.map +1 -0
  298. package/dist/mjs/providers/chart-context/chart-context.js +2 -0
  299. package/dist/mjs/providers/chart-context/chart-context.js.map +1 -0
  300. package/dist/mjs/providers/chart-context/utils.js +2 -0
  301. package/dist/mjs/providers/chart-context/utils.js.map +1 -0
  302. package/dist/mjs/providers/theme/theme-provider.js +1 -1
  303. package/dist/mjs/providers/theme/theme-provider.js.map +1 -1
  304. package/dist/mjs/style.css +1 -1
  305. package/package.json +11 -9
  306. package/src/components/bar-chart/bar-chart.tsx +115 -22
  307. package/src/components/grid-control/grid-control.module.scss +6 -6
  308. package/src/components/leaderboard-chart/README.md +199 -0
  309. package/src/components/leaderboard-chart/index.tsx +4 -0
  310. package/src/components/leaderboard-chart/leaderboard-chart.module.scss +93 -0
  311. package/src/components/leaderboard-chart/leaderboard-chart.tsx +214 -0
  312. package/src/components/line-chart/line-chart-annotation-label-popover.tsx +110 -0
  313. package/src/components/line-chart/line-chart-annotation.tsx +123 -22
  314. package/src/components/line-chart/line-chart-annotations-overlay.tsx +135 -0
  315. package/src/components/line-chart/line-chart-context.tsx +28 -0
  316. package/src/components/line-chart/line-chart.module.scss +69 -1
  317. package/src/components/line-chart/line-chart.tsx +357 -361
  318. package/src/components/pie-chart/pie-chart.tsx +29 -8
  319. package/src/components/pie-semi-circle-chart/pie-semi-circle-chart.tsx +44 -21
  320. package/src/components/shared/format-metric-value.ts +92 -0
  321. package/src/components/shared/utils.ts +7 -0
  322. package/src/components/tooltip/accessible-tooltip.tsx +245 -0
  323. package/src/components/tooltip/base-tooltip.module.scss +9 -9
  324. package/src/index.ts +11 -0
  325. package/src/providers/chart-context/chart-context.test.tsx +230 -0
  326. package/src/providers/chart-context/chart-context.tsx +45 -0
  327. package/src/providers/chart-context/index.ts +3 -0
  328. package/src/providers/chart-context/types.ts +16 -0
  329. package/src/providers/chart-context/utils.ts +48 -0
  330. package/src/types.ts +29 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/charts",
3
- "version": "0.16.2",
3
+ "version": "0.18.0",
4
4
  "description": "Display charts within Automattic products.",
5
5
  "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/charts/#readme",
6
6
  "bugs": {
@@ -47,7 +47,8 @@
47
47
  "./style.css": "./dist/mjs/style.css"
48
48
  },
49
49
  "dependencies": {
50
- "@automattic/number-formatters": "^1.0.8",
50
+ "@automattic/jetpack-components": "^1.1.14",
51
+ "@automattic/number-formatters": "^1.0.9",
51
52
  "@babel/runtime": "7.27.6",
52
53
  "@react-spring/web": "9.7.5",
53
54
  "@visx/annotation": "^3.12.0",
@@ -67,15 +68,15 @@
67
68
  "@visx/xychart": "^3.12.0",
68
69
  "clsx": "2.1.1",
69
70
  "date-fns": "^4.1.0",
70
- "lodash": "^4.17.21",
71
+ "deepmerge": "4.3.1",
71
72
  "tslib": "2.5.0"
72
73
  },
73
74
  "devDependencies": {
74
75
  "@automattic/jetpack-webpack-config": "workspace:*",
75
- "@babel/core": "7.27.7",
76
+ "@babel/core": "7.28.0",
76
77
  "@babel/plugin-transform-react-jsx": "7.27.1",
77
- "@babel/plugin-transform-runtime": "7.27.4",
78
- "@babel/preset-env": "7.27.2",
78
+ "@babel/plugin-transform-runtime": "7.28.0",
79
+ "@babel/preset-env": "7.28.0",
79
80
  "@babel/preset-react": "7.27.1",
80
81
  "@babel/preset-typescript": "7.27.1",
81
82
  "@rollup/plugin-commonjs": "26.0.1",
@@ -83,8 +84,8 @@
83
84
  "@rollup/plugin-node-resolve": "15.3.0",
84
85
  "@rollup/plugin-terser": "0.4.3",
85
86
  "@rollup/plugin-typescript": "12.1.0",
86
- "@storybook/blocks": "8.6.7",
87
- "@storybook/react": "8.6.7",
87
+ "@storybook/addon-docs": "9.0.15",
88
+ "@storybook/react": "9.0.15",
88
89
  "@testing-library/dom": "^10.0.0",
89
90
  "@testing-library/jest-dom": "^6.0.0",
90
91
  "@testing-library/react": "^16.0.0",
@@ -93,6 +94,7 @@
93
94
  "@types/react": "18.3.23",
94
95
  "@types/react-dom": "18.3.7",
95
96
  "@visx/glyph": "3.12.0",
97
+ "@wordpress/components": "29.12.0",
96
98
  "@wordpress/element": "6.26.0",
97
99
  "babel-jest": "30.0.0",
98
100
  "babel-loader": "9.1.2",
@@ -114,7 +116,7 @@
114
116
  "sass": "npm:sass-embedded@1.87.0",
115
117
  "sass-embedded": "1.87.0",
116
118
  "sass-loader": "^16.0.0",
117
- "storybook": "8.6.7",
119
+ "storybook": "9.0.15",
118
120
  "tsconfig-paths-webpack-plugin": "4.2.0",
119
121
  "typescript": "5.8.3",
120
122
  "webpack": "^5.88.0",
@@ -1,13 +1,15 @@
1
1
  import { PatternLines, PatternCircles, PatternWaves, PatternHexagons } from '@visx/pattern';
2
- import { Axis, BarSeries, BarGroup, Grid, Tooltip, XYChart } from '@visx/xychart';
2
+ import { Axis, BarSeries, BarGroup, Grid, XYChart } from '@visx/xychart';
3
3
  import clsx from 'clsx';
4
- import { useCallback, useId } from 'react';
5
- import { useXYChartTheme } from '../../providers/theme';
4
+ import { useCallback, useId, useState, useRef, useMemo } from 'react';
5
+ import { ChartProvider, useChartId, useChartRegistration } from '../../providers/chart-context';
6
+ import { useChartTheme, useXYChartTheme } from '../../providers/theme';
6
7
  import { Legend } from '../legend';
7
8
  import { useChartDataTransform } from '../shared/use-chart-data-transform';
8
9
  import { useChartMargin } from '../shared/use-chart-margin';
9
10
  import { useElementHeight } from '../shared/use-element-height';
10
11
  import { withResponsive } from '../shared/with-responsive';
12
+ import { AccessibleTooltip, useKeyboardNavigation } from '../tooltip/accessible-tooltip';
11
13
  import styles from './bar-chart.module.scss';
12
14
  import { useBarChartOptions } from './use-bar-chart-options';
13
15
  import type { BaseChartProps, DataPointDate, SeriesData } from '../../types';
@@ -41,8 +43,9 @@ const validateData = ( data: SeriesData[] ) => {
41
43
 
42
44
  const getPatternId = ( chartId: string, index: number ) => `bar-pattern-${ chartId }-${ index }`;
43
45
 
44
- const BarChart: FC< BarChartProps > = ( {
46
+ const BarChartInternal: FC< BarChartProps > = ( {
45
47
  data,
48
+ chartId: providedChartId,
46
49
  width,
47
50
  height = 400,
48
51
  className,
@@ -61,7 +64,8 @@ const BarChart: FC< BarChartProps > = ( {
61
64
  } ) => {
62
65
  const horizontal = orientation === 'horizontal';
63
66
  // Generate a unique chart ID to avoid pattern conflicts with multiple charts
64
- const chartId = useId();
67
+ const internalChartId = useId();
68
+ const chartId = useChartId( providedChartId );
65
69
  const theme = useXYChartTheme( data );
66
70
 
67
71
  const dataSorted = useChartDataTransform( data );
@@ -69,6 +73,22 @@ const BarChart: FC< BarChartProps > = ( {
69
73
  const chartOptions = useBarChartOptions( dataSorted, horizontal, options );
70
74
  const defaultMargin = useChartMargin( height, chartOptions, dataSorted, theme, horizontal );
71
75
  const [ legendRef, legendHeight ] = useElementHeight< HTMLDivElement >();
76
+ const chartRef = useRef< HTMLDivElement >( null );
77
+ const [ selectedIndex, setSelectedIndex ] = useState< number | undefined >( undefined );
78
+ const [ isNavigating, setIsNavigating ] = useState( false );
79
+
80
+ const totalPoints =
81
+ Math.max( 0, ...data.map( series => series.data?.length || 0 ) ) * data.length;
82
+
83
+ // Use the keyboard navigation hook
84
+ const { tooltipRef, onChartFocus, onChartBlur, onChartKeyDown } = useKeyboardNavigation( {
85
+ selectedIndex,
86
+ setSelectedIndex,
87
+ isNavigating,
88
+ setIsNavigating,
89
+ chartRef,
90
+ totalPoints,
91
+ } );
72
92
 
73
93
  const getColor = useCallback(
74
94
  ( seriesData: SeriesData, index: number ) =>
@@ -79,9 +99,9 @@ const BarChart: FC< BarChartProps > = ( {
79
99
  const getBarBackground = useCallback(
80
100
  ( index: number ) => () =>
81
101
  withPatterns
82
- ? `url(#${ getPatternId( chartId, index ) })`
102
+ ? `url(#${ getPatternId( internalChartId, index ) })`
83
103
  : getColor( dataSorted[ index ], index ),
84
- [ withPatterns, getColor, dataSorted, chartId ]
104
+ [ withPatterns, getColor, dataSorted, internalChartId ]
85
105
  );
86
106
 
87
107
  const renderDefaultTooltip = useCallback(
@@ -114,7 +134,7 @@ const BarChart: FC< BarChartProps > = ( {
114
134
  const renderPattern = useCallback(
115
135
  ( index: number, color: string ) => {
116
136
  const patternType = index % 4;
117
- const id = getPatternId( chartId, index );
137
+ const id = getPatternId( internalChartId, index );
118
138
  const commonProps = {
119
139
  id,
120
140
  stroke: 'white',
@@ -144,12 +164,12 @@ const BarChart: FC< BarChartProps > = ( {
144
164
  return <PatternHexagons key={ id } { ...commonProps } size={ 8 } height={ 3 } />;
145
165
  }
146
166
  },
147
- [ chartId ]
167
+ [ internalChartId ]
148
168
  );
149
169
 
150
170
  const createPatternBorderStyle = useCallback(
151
171
  ( index: number, color: string ) => {
152
- const patternId = getPatternId( chartId, index );
172
+ const patternId = getPatternId( internalChartId, index );
153
173
  return `
154
174
  .visx-bar[fill="url(#${ patternId })"] {
155
175
  stroke: ${ color };
@@ -157,30 +177,82 @@ const BarChart: FC< BarChartProps > = ( {
157
177
  }
158
178
  `;
159
179
  },
160
- [ chartId ]
180
+ [ internalChartId ]
161
181
  );
162
182
 
163
- // Validate data using the same pattern as LineChart
183
+ const createKeyboardHighlightStyle = useCallback( () => {
184
+ if ( selectedIndex === undefined ) return '';
185
+
186
+ // Calculate which bar should be highlighted based on selectedIndex
187
+ // Pattern: [series1[0], series2[0], series3[0], series1[1], series2[1], series3[1], ...]
188
+ const maxDataPoints = Math.max( ...data.map( s => s.data.length ) );
189
+ const dataPointIndex = Math.floor( selectedIndex / data.length );
190
+ const seriesIndex = selectedIndex % data.length;
191
+
192
+ // Only highlight if we're within valid bounds
193
+ if ( dataPointIndex >= maxDataPoints || seriesIndex >= data.length ) {
194
+ return '';
195
+ }
196
+
197
+ const seriesData = data[ seriesIndex ];
198
+ if ( dataPointIndex >= seriesData.data.length ) {
199
+ return '';
200
+ }
201
+
202
+ // Based on the DOM structure analysis:
203
+ // - All bars are in a single .visx-bar-group
204
+ // - Bars are ordered as: [series1[0], series1[1], series2[0], series2[1], ...]
205
+ // - So we need to calculate the actual bar index in the DOM
206
+ const actualBarIndex = seriesIndex * maxDataPoints + dataPointIndex;
207
+
208
+ // Use a CSS class selector instead of ID since useId() generates invalid CSS ID characters
209
+ const generatedStyles = `
210
+ .bar-chart[data-chart-id="bar-chart-${ chartId }"] .visx-bar-group .visx-bar:nth-child(${
211
+ actualBarIndex + 1
212
+ }) {
213
+ stroke: #005fcc;
214
+ stroke-width: 2px;
215
+ }
216
+ `;
217
+
218
+ return generatedStyles;
219
+ }, [ selectedIndex, data, chartId ] );
220
+
221
+ // Validate data first
164
222
  const error = validateData( dataSorted );
223
+ const isDataValid = ! error;
224
+
225
+ // Create legend items (hooks must be called in same order every render)
226
+ const legendItems = useMemo(
227
+ () =>
228
+ dataSorted.map( ( group, index ) => ( {
229
+ label: group.label, // Label for each unique group
230
+ value: '', // Empty string since we don't want to show a specific value
231
+ color: getColor( group, index ),
232
+ shapeStyle: group?.options?.legendShapeStyle,
233
+ } ) ),
234
+ [ dataSorted, getColor ]
235
+ );
236
+
237
+ // Register chart with context only if data is valid
238
+ const providerTheme = useChartTheme();
239
+ useChartRegistration( chartId, legendItems, providerTheme, 'bar', isDataValid, {
240
+ orientation,
241
+ withPatterns,
242
+ } );
243
+
165
244
  if ( error ) {
166
245
  return <div className={ clsx( 'bar-chart', styles[ 'bar-chart' ] ) }>{ error }</div>;
167
246
  }
168
247
 
169
- // Create legend items from group labels, this iterates over groups rather than data points
170
- const legendItems = dataSorted.map( ( group, index ) => ( {
171
- label: group.label, // Label for each unique group
172
- value: '', // Empty string since we don't want to show a specific value
173
- color: getColor( group, index ),
174
- shapeStyle: group?.options?.legendShapeStyle,
175
- } ) );
176
-
177
248
  const gridVisibility = gridVisibilityProp ?? chartOptions.gridVisibility;
249
+ const highlightedBarStyle = createKeyboardHighlightStyle();
178
250
 
179
251
  return (
180
252
  <div
181
253
  className={ clsx( 'bar-chart', styles[ 'bar-chart' ], className ) }
182
254
  data-testid="bar-chart"
183
- role="img"
255
+ role="grid"
184
256
  aria-label="bar chart"
185
257
  style={ {
186
258
  width,
@@ -189,6 +261,12 @@ const BarChart: FC< BarChartProps > = ( {
189
261
  flexDirection:
190
262
  showLegend && legendAlignmentVertical === 'top' ? 'column-reverse' : 'column',
191
263
  } }
264
+ tabIndex={ 0 }
265
+ onKeyDown={ onChartKeyDown }
266
+ onFocus={ onChartFocus }
267
+ onBlur={ onChartBlur }
268
+ ref={ chartRef }
269
+ data-chart-id={ `bar-chart-${ chartId }` } // Unique ID for the chart
192
270
  >
193
271
  <XYChart
194
272
  theme={ theme }
@@ -227,6 +305,8 @@ const BarChart: FC< BarChartProps > = ( {
227
305
  </>
228
306
  ) }
229
307
 
308
+ { highlightedBarStyle && <style>{ highlightedBarStyle }</style> }
309
+
230
310
  <BarGroup padding={ chartOptions.barGroup.padding }>
231
311
  { dataSorted.map( ( seriesData, index ) => (
232
312
  <BarSeries
@@ -244,11 +324,16 @@ const BarChart: FC< BarChartProps > = ( {
244
324
  <Axis { ...chartOptions.axis.y } />
245
325
 
246
326
  { withTooltips && (
247
- <Tooltip
327
+ <AccessibleTooltip
248
328
  detectBounds
249
329
  snapTooltipToDatumX
250
330
  snapTooltipToDatumY
251
331
  renderTooltip={ renderTooltip || renderDefaultTooltip }
332
+ selectedIndex={ selectedIndex }
333
+ tooltipRef={ tooltipRef }
334
+ keyboardFocusedClassName={ styles[ 'bar-chart__tooltip--keyboard-focused' ] }
335
+ series={ data }
336
+ mode="individual"
252
337
  />
253
338
  ) }
254
339
  </XYChart>
@@ -268,4 +353,12 @@ const BarChart: FC< BarChartProps > = ( {
268
353
  );
269
354
  };
270
355
 
356
+ const BarChart: FC< BarChartProps > = props => (
357
+ <ChartProvider>
358
+ <BarChartInternal { ...props } />
359
+ </ChartProvider>
360
+ );
361
+
362
+ BarChart.displayName = 'BarChart';
363
+
271
364
  export default withResponsive< BarChartProps >( BarChart );
@@ -3,9 +3,9 @@ $grid-line-color: #d7d6d6;
3
3
 
4
4
  .grid-control {
5
5
 
6
- :global(.visx-line) {
7
- stroke: $grid-line-color;
8
- stroke-width: 1px;
9
- shape-rendering: crispEdges;
10
- }
11
- }
6
+ :global(.visx-line) {
7
+ stroke: $grid-line-color;
8
+ stroke-width: 1px;
9
+ shape-rendering: crispEdges;
10
+ }
11
+ }
@@ -0,0 +1,199 @@
1
+ # LeaderboardChart Component
2
+
3
+ A flexible and accessible leaderboard chart component for displaying ranked data with WordPress ProgressBar components and optional comparison values.
4
+
5
+ ## Features
6
+
7
+ - 📊 Clean, responsive leaderboard visualization
8
+ - 🎨 Customizable colors and styling
9
+ - 🔄 Optional comparison data support
10
+ - 📱 Mobile-friendly design
11
+ - 🎯 TypeScript support with full type definitions
12
+ - ♿ Accessible design
13
+ - 🧪 Comprehensive test coverage
14
+ - 📖 Storybook documentation
15
+
16
+ ## Usage
17
+
18
+ ### Basic Usage
19
+
20
+ ```typescript
21
+ import { LeaderboardChart } from '@automattic/charts';
22
+
23
+ const data = [
24
+ {
25
+ id: 'direct',
26
+ label: 'Direct',
27
+ currentValue: 12500,
28
+ previousValue: 10000,
29
+ currentShare: 100,
30
+ previousShare: 80,
31
+ delta: 25,
32
+ },
33
+ // ... more entries
34
+ ];
35
+
36
+ function MyComponent() {
37
+ return (
38
+ <LeaderboardChart
39
+ data={data}
40
+ withComparison={true}
41
+ primaryColor="#3858E9"
42
+ secondaryColor="#66BDFF"
43
+ />
44
+ );
45
+ }
46
+ ```
47
+
48
+ ### With Custom Formatters
49
+
50
+ ```typescript
51
+ import { LeaderboardChart } from '@automattic/charts';
52
+
53
+ function CustomFormattedChart() {
54
+ return (
55
+ <LeaderboardChart
56
+ data={data}
57
+ withComparison={true}
58
+ valueFormatter={(value) => `$${(value / 1000).toFixed(1)}k`}
59
+ deltaFormatter={(value) => `${value > 0 ? '+' : ''}${value}%`}
60
+ />
61
+ );
62
+ }
63
+ ```
64
+
65
+ ### Preparing Your Data
66
+
67
+ The LeaderboardChart expects pre-processed data. You'll need to transform your raw data into the required format:
68
+
69
+ ```typescript
70
+ import { LeaderboardChart } from '@automattic/charts';
71
+
72
+ // Transform your raw data into LeaderboardEntry format
73
+ function transformRawData(rawData) {
74
+ const maxValue = Math.max(...rawData.map(item => item.current_period.value));
75
+
76
+ return rawData.map(item => ({
77
+ id: item.id,
78
+ label: item.name,
79
+ currentValue: item.current_period.value,
80
+ previousValue: item.previous_period.value,
81
+ currentShare: (item.current_period.value / maxValue) * 100,
82
+ previousShare: (item.previous_period.value / maxValue) * 100,
83
+ delta: ((item.current_period.value - item.previous_period.value) / item.previous_period.value) * 100,
84
+ }));
85
+ }
86
+
87
+ function ProcessedDataChart() {
88
+ const processedData = transformRawData(rawData);
89
+
90
+ return (
91
+ <LeaderboardChart
92
+ data={processedData}
93
+ withComparison={true}
94
+ />
95
+ );
96
+ }
97
+ ```
98
+
99
+ ## API Reference
100
+
101
+ ### LeaderboardChart Props
102
+
103
+ | Prop | Type | Default | Description |
104
+ |------|------|---------|-------------|
105
+ | `data` | `LeaderboardEntry[]` | **required** | Array of leaderboard entries to display |
106
+ | `withComparison` | `boolean` | `false` | Whether to show comparison data |
107
+ | `loading` | `boolean` | `false` | Whether the chart is in loading state |
108
+ | `primaryColor` | `string` | `#3858E9` | Primary color for current period bars |
109
+ | `secondaryColor` | `string` | `#66BDFF` | Secondary color for comparison period bars |
110
+ | `valueFormatter` | `(value: number) => string` | *compact formatter* | Custom formatter for values |
111
+ | `deltaFormatter` | `(value: number) => string` | *percentage formatter* | Custom formatter for delta values |
112
+ | `className` | `string` | `undefined` | Additional CSS class name |
113
+ | `style` | `React.CSSProperties` | `undefined` | Custom styling for the chart container |
114
+
115
+ ### LeaderboardEntry Interface
116
+
117
+ ```typescript
118
+ interface LeaderboardEntry {
119
+ id: string; // Unique identifier
120
+ label: string; // Display name
121
+ currentValue: number; // Current period value
122
+ previousValue: number; // Previous period value
123
+ currentShare: number; // Current bar width (0-100)
124
+ previousShare: number; // Previous bar width (0-100)
125
+ delta: number; // Percentage change
126
+ }
127
+ ```
128
+
129
+ ## Data Transformation
130
+
131
+ Since the LeaderboardChart expects pre-processed data, you'll need to handle data transformation in your application. This gives you full control over how your specific data structures are converted and allows for custom business logic.
132
+
133
+ ## Styling
134
+
135
+ The component uses CSS Modules for styling. You can customize colors using CSS custom properties:
136
+
137
+ ```css
138
+ .myCustomChart {
139
+ --primary-color: #ff6b6b;
140
+ --secondary-color: #4ecdc4;
141
+ }
142
+ ```
143
+
144
+ ## Accessibility
145
+
146
+ The component includes:
147
+ - Semantic HTML structure
148
+ - Proper color contrast ratios
149
+ - Keyboard navigation support
150
+ - Screen reader compatible markup
151
+
152
+ ## Examples
153
+
154
+ ### E-commerce Sales Channels
155
+
156
+ ```typescript
157
+ const salesData = [
158
+ { id: 'organic', label: 'Organic Search', currentValue: 45000, previousValue: 38000, currentShare: 100, previousShare: 84, delta: 18 },
159
+ { id: 'paid', label: 'Paid Advertising', currentValue: 32000, previousValue: 35000, currentShare: 71, previousShare: 78, delta: -9 },
160
+ { id: 'social', label: 'Social Media', currentValue: 18000, previousValue: 15000, currentShare: 40, previousShare: 33, delta: 20 },
161
+ { id: 'email', label: 'Email Marketing', currentValue: 12000, previousValue: 11000, currentShare: 27, previousShare: 24, delta: 9 },
162
+ ];
163
+
164
+ <LeaderboardChart data={salesData} withComparison={true} />
165
+ ```
166
+
167
+ ### Traffic Sources
168
+
169
+ ```typescript
170
+ const trafficData = [
171
+ { id: 'direct', label: 'Direct', currentValue: 15420, previousValue: 13200, currentShare: 100, previousShare: 86, delta: 17 },
172
+ { id: 'search', label: 'Search Engines', currentValue: 12350, previousValue: 11800, currentShare: 80, previousShare: 77, delta: 5 },
173
+ { id: 'social', label: 'Social Networks', currentValue: 8760, previousValue: 9200, currentShare: 57, previousShare: 60, delta: -5 },
174
+ ];
175
+
176
+ <LeaderboardChart data={trafficData} withComparison={true} />
177
+ ```
178
+
179
+ ## Testing
180
+
181
+ The component includes comprehensive tests covering:
182
+ - Component rendering
183
+ - Data formatting
184
+ - Comparison functionality
185
+ - Custom formatters
186
+ - Loading states
187
+ - Empty data handling
188
+
189
+ Run tests with:
190
+ ```bash
191
+ pnpm test
192
+ ```
193
+
194
+ ## Storybook
195
+
196
+ Interactive examples and documentation are available in Storybook:
197
+ ```bash
198
+ pnpm storybook
199
+ ```
@@ -0,0 +1,4 @@
1
+ export { default as LeaderboardChart } from './leaderboard-chart';
2
+ export type { LeaderboardChartProps, LeaderboardEntry } from './leaderboard-chart';
3
+ export { formatMetricValue } from '../shared/format-metric-value';
4
+ export type { MetricValueType } from '../shared/format-metric-value';
@@ -0,0 +1,93 @@
1
+ .leaderboardChart {
2
+ width: 100%;
3
+ max-width: 400px;
4
+ display: flex;
5
+ flex-direction: column;
6
+ gap: 12px;
7
+
8
+ transition: opacity 0.3s ease-in-out;
9
+
10
+ &.loading {
11
+ opacity: 0.5;
12
+ }
13
+ }
14
+
15
+ .entryContainer {
16
+ display: grid;
17
+ grid-template-columns: minmax(0, 1fr) auto;
18
+ column-gap: 4px;
19
+ align-items: start;
20
+ }
21
+
22
+ .labelContainer {
23
+ display: flex;
24
+ flex-direction: column;
25
+ gap: 6px;
26
+ min-width: 0;
27
+ }
28
+
29
+ .entryLabel {
30
+ font-size: 14px;
31
+ line-height: 1.4;
32
+ color: #1e1e1e;
33
+ font-weight: 400;
34
+ overflow: hidden;
35
+ text-overflow: ellipsis;
36
+ white-space: nowrap;
37
+ }
38
+
39
+ .progressContainer {
40
+ display: flex;
41
+ flex-direction: column;
42
+ gap: 6px;
43
+
44
+ .progressBar {
45
+ width: 100%;
46
+ height: 6px;
47
+ border-radius: 2px;
48
+ background-color: transparent;
49
+ overflow: hidden;
50
+ transition: width 0.3s ease-in-out;
51
+
52
+ > div {
53
+ background-color: var(--progress-color, #3858e9);
54
+ }
55
+ }
56
+
57
+ .primaryBar {
58
+ --progress-color: var(--primary-color, #3858e9);
59
+ }
60
+
61
+ .secondaryBar {
62
+ --progress-color: var(--secondary-color, #66bdff);
63
+ }
64
+ }
65
+
66
+ .valueContainer {
67
+ display: flex;
68
+ flex-direction: row;
69
+ gap: 4px;
70
+ align-items: flex-start;
71
+ text-align: right;
72
+ }
73
+
74
+ .currentValue {
75
+ font-size: 14px;
76
+ line-height: 1.4;
77
+ font-weight: 500;
78
+ color: #1e1e1e;
79
+ }
80
+
81
+ .deltaValue {
82
+ font-size: 13px;
83
+ line-height: 1.4;
84
+ font-weight: 400;
85
+ }
86
+
87
+ .emptyState {
88
+ padding: 32px 16px;
89
+ text-align: center;
90
+ color: #666;
91
+ font-size: 14px;
92
+ font-style: italic;
93
+ }