@automattic/charts 0.56.5 → 0.56.7

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 (179) hide show
  1. package/AGENTS.md +135 -0
  2. package/CHANGELOG.md +17 -0
  3. package/README.md +2 -1
  4. package/dist/charts/bar-chart/index.cjs +6 -6
  5. package/dist/charts/bar-chart/index.css +1 -4
  6. package/dist/charts/bar-chart/index.css.map +1 -1
  7. package/dist/charts/bar-chart/index.d.cts +2 -8
  8. package/dist/charts/bar-chart/index.d.ts +2 -8
  9. package/dist/charts/bar-chart/index.js +5 -5
  10. package/dist/charts/bar-list-chart/index.cjs +7 -7
  11. package/dist/charts/bar-list-chart/index.css +1 -4
  12. package/dist/charts/bar-list-chart/index.css.map +1 -1
  13. package/dist/charts/bar-list-chart/index.d.cts +2 -2
  14. package/dist/charts/bar-list-chart/index.d.ts +2 -2
  15. package/dist/charts/bar-list-chart/index.js +6 -6
  16. package/dist/charts/conversion-funnel-chart/index.cjs +5 -5
  17. package/dist/charts/conversion-funnel-chart/index.css +1 -4
  18. package/dist/charts/conversion-funnel-chart/index.css.map +1 -1
  19. package/dist/charts/conversion-funnel-chart/index.d.cts +2 -1
  20. package/dist/charts/conversion-funnel-chart/index.d.ts +2 -1
  21. package/dist/charts/conversion-funnel-chart/index.js +4 -4
  22. package/dist/charts/geo-chart/index.cjs +4 -4
  23. package/dist/charts/geo-chart/index.css +1 -4
  24. package/dist/charts/geo-chart/index.css.map +1 -1
  25. package/dist/charts/geo-chart/index.d.cts +2 -1
  26. package/dist/charts/geo-chart/index.d.ts +2 -1
  27. package/dist/charts/geo-chart/index.js +3 -3
  28. package/dist/charts/leaderboard-chart/index.cjs +5 -5
  29. package/dist/charts/leaderboard-chart/index.css +1 -4
  30. package/dist/charts/leaderboard-chart/index.css.map +1 -1
  31. package/dist/charts/leaderboard-chart/index.d.cts +3 -2
  32. package/dist/charts/leaderboard-chart/index.d.ts +3 -2
  33. package/dist/charts/leaderboard-chart/index.js +4 -4
  34. package/dist/charts/line-chart/index.cjs +6 -6
  35. package/dist/charts/line-chart/index.css +1 -4
  36. package/dist/charts/line-chart/index.css.map +1 -1
  37. package/dist/charts/line-chart/index.d.cts +2 -8
  38. package/dist/charts/line-chart/index.d.ts +2 -8
  39. package/dist/charts/line-chart/index.js +5 -5
  40. package/dist/charts/pie-chart/index.cjs +6 -4
  41. package/dist/charts/pie-chart/index.cjs.map +1 -1
  42. package/dist/charts/pie-chart/index.css +13 -7
  43. package/dist/charts/pie-chart/index.css.map +1 -1
  44. package/dist/charts/pie-chart/index.d.cts +2 -1
  45. package/dist/charts/pie-chart/index.d.ts +2 -1
  46. package/dist/charts/pie-chart/index.js +5 -3
  47. package/dist/charts/pie-semi-circle-chart/index.cjs +6 -4
  48. package/dist/charts/pie-semi-circle-chart/index.cjs.map +1 -1
  49. package/dist/charts/pie-semi-circle-chart/index.css +12 -13
  50. package/dist/charts/pie-semi-circle-chart/index.css.map +1 -1
  51. package/dist/charts/pie-semi-circle-chart/index.d.cts +5 -2
  52. package/dist/charts/pie-semi-circle-chart/index.d.ts +5 -2
  53. package/dist/charts/pie-semi-circle-chart/index.js +5 -3
  54. package/dist/charts/sparkline/index.cjs +7 -7
  55. package/dist/charts/sparkline/index.css +1 -4
  56. package/dist/charts/sparkline/index.css.map +1 -1
  57. package/dist/charts/sparkline/index.js +6 -6
  58. package/dist/{chunk-NGHXTIUE.cjs → chunk-3EXJP67N.cjs} +7 -7
  59. package/dist/{chunk-NGHXTIUE.cjs.map → chunk-3EXJP67N.cjs.map} +1 -1
  60. package/dist/{chunk-FIFSYVN6.cjs → chunk-55ZCOYDF.cjs} +117 -132
  61. package/dist/chunk-55ZCOYDF.cjs.map +1 -0
  62. package/dist/{chunk-LT4YOIMM.js → chunk-7FDQGBY7.js} +145 -119
  63. package/dist/chunk-7FDQGBY7.js.map +1 -0
  64. package/dist/{chunk-7QDEU3KN.cjs → chunk-ASLARV7L.cjs} +6 -6
  65. package/dist/chunk-ASLARV7L.cjs.map +1 -0
  66. package/dist/chunk-BXFD7JIG.cjs +401 -0
  67. package/dist/chunk-BXFD7JIG.cjs.map +1 -0
  68. package/dist/{chunk-XCXAWMJQ.cjs → chunk-CAFJRZPZ.cjs} +12 -12
  69. package/dist/{chunk-XCXAWMJQ.cjs.map → chunk-CAFJRZPZ.cjs.map} +1 -1
  70. package/dist/{chunk-KHRPRH4V.js → chunk-E62LCBGD.js} +4 -4
  71. package/dist/{chunk-PCOI2GT5.js → chunk-GWBS65VC.js} +3 -3
  72. package/dist/{chunk-MEIVKY4K.js → chunk-IS5YYLTV.js} +18 -18
  73. package/dist/{chunk-MEIVKY4K.js.map → chunk-IS5YYLTV.js.map} +1 -1
  74. package/dist/{chunk-Q6G3BGCL.cjs → chunk-K6TGILHX.cjs} +8 -8
  75. package/dist/{chunk-Q6G3BGCL.cjs.map → chunk-K6TGILHX.cjs.map} +1 -1
  76. package/dist/{chunk-X6GX4QUJ.js → chunk-KHQPN77E.js} +3 -3
  77. package/dist/{chunk-SEKPIG5K.js → chunk-KNIMXN6Z.js} +2 -2
  78. package/dist/{chunk-SEKPIG5K.js.map → chunk-KNIMXN6Z.js.map} +1 -1
  79. package/dist/{chunk-AFWQR3SM.js → chunk-MDRCAGKZ.js} +4 -4
  80. package/dist/{chunk-TKPK4RFS.cjs → chunk-NQJE2CC7.cjs} +120 -98
  81. package/dist/chunk-NQJE2CC7.cjs.map +1 -0
  82. package/dist/{chunk-FY325WQ4.cjs → chunk-O2JIANHK.cjs} +25 -25
  83. package/dist/chunk-O2JIANHK.cjs.map +1 -0
  84. package/dist/{chunk-DLSUC7RN.js → chunk-OMS5QIJN.js} +6 -6
  85. package/dist/chunk-OMS5QIJN.js.map +1 -0
  86. package/dist/{chunk-TYIH5LMV.js → chunk-OP6PHB2U.js} +6 -6
  87. package/dist/chunk-OP6PHB2U.js.map +1 -0
  88. package/dist/{chunk-32ESS4MV.js → chunk-RFSHE3HL.js} +17 -7
  89. package/dist/chunk-RFSHE3HL.js.map +1 -0
  90. package/dist/{chunk-KXSLMOW5.js → chunk-SSFFCBCF.js} +6 -6
  91. package/dist/chunk-SSFFCBCF.js.map +1 -0
  92. package/dist/{chunk-I5467ZJ5.cjs → chunk-SUDERBUA.cjs} +2 -2
  93. package/dist/{chunk-I5467ZJ5.cjs.map → chunk-SUDERBUA.cjs.map} +1 -1
  94. package/dist/{chunk-SH32YSZO.cjs → chunk-UFRBUT2D.cjs} +19 -19
  95. package/dist/{chunk-SH32YSZO.cjs.map → chunk-UFRBUT2D.cjs.map} +1 -1
  96. package/dist/{chunk-7TQSPLIN.js → chunk-VPAEBI2F.js} +109 -87
  97. package/dist/chunk-VPAEBI2F.js.map +1 -0
  98. package/dist/{chunk-IHESL7H5.cjs → chunk-X7JL2NYJ.cjs} +24 -24
  99. package/dist/chunk-X7JL2NYJ.cjs.map +1 -0
  100. package/dist/{chunk-DBY6C4O2.js → chunk-XD2HV7M5.js} +77 -92
  101. package/dist/chunk-XD2HV7M5.js.map +1 -0
  102. package/dist/{chunk-LTPJPIDP.cjs → chunk-YAXY5L7I.cjs} +7 -7
  103. package/dist/{chunk-LTPJPIDP.cjs.map → chunk-YAXY5L7I.cjs.map} +1 -1
  104. package/dist/{chunk-EJJO2QNB.cjs → chunk-YDVHT7GS.cjs} +17 -7
  105. package/dist/chunk-YDVHT7GS.cjs.map +1 -0
  106. package/dist/components/legend/index.cjs +2 -2
  107. package/dist/components/legend/index.css +1 -4
  108. package/dist/components/legend/index.css.map +1 -1
  109. package/dist/components/legend/index.d.cts +2 -1
  110. package/dist/components/legend/index.d.ts +2 -1
  111. package/dist/components/legend/index.js +1 -1
  112. package/dist/components/tooltip/index.d.cts +2 -1
  113. package/dist/components/tooltip/index.d.ts +2 -1
  114. package/dist/hooks/index.cjs +2 -2
  115. package/dist/hooks/index.cjs.map +1 -1
  116. package/dist/hooks/index.css +1 -4
  117. package/dist/hooks/index.css.map +1 -1
  118. package/dist/hooks/index.d.cts +10 -7
  119. package/dist/hooks/index.d.ts +10 -7
  120. package/dist/hooks/index.js +3 -3
  121. package/dist/index.cjs +14 -14
  122. package/dist/index.css +24 -16
  123. package/dist/index.css.map +1 -1
  124. package/dist/index.d.cts +4 -4
  125. package/dist/index.d.ts +4 -4
  126. package/dist/index.js +13 -13
  127. package/dist/{leaderboard-chart-B5gWcqe7.d.ts → leaderboard-chart-BSgEw_Um.d.ts} +1 -1
  128. package/dist/{leaderboard-chart-C_6QDcqj.d.cts → leaderboard-chart-COtgamhe.d.cts} +1 -1
  129. package/dist/providers/index.cjs +2 -2
  130. package/dist/providers/index.css +1 -4
  131. package/dist/providers/index.css.map +1 -1
  132. package/dist/providers/index.d.cts +3 -2
  133. package/dist/providers/index.d.ts +3 -2
  134. package/dist/providers/index.js +1 -1
  135. package/dist/{themes-BDVaIfBz.d.cts → themes-CVR5rmIs.d.cts} +1 -1
  136. package/dist/{themes-mcS8QNkQ.d.ts → themes-DQzmaSze.d.ts} +1 -1
  137. package/dist/{types-BCFQlzTM.d.ts → types-CzdN7rUe.d.cts} +12 -3
  138. package/dist/{types-BCFQlzTM.d.cts → types-CzdN7rUe.d.ts} +12 -3
  139. package/dist/utils/index.d.cts +2 -1
  140. package/dist/utils/index.d.ts +2 -1
  141. package/package.json +9 -9
  142. package/src/charts/bar-chart/bar-chart.tsx +2 -9
  143. package/src/charts/bar-chart/test/bar-chart.test.tsx +3 -3
  144. package/src/charts/line-chart/line-chart.tsx +2 -2
  145. package/src/charts/line-chart/test/line-chart.test.tsx +3 -3
  146. package/src/charts/line-chart/types.ts +0 -7
  147. package/src/charts/pie-chart/pie-chart.module.scss +14 -3
  148. package/src/charts/pie-chart/pie-chart.tsx +172 -148
  149. package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.module.scss +17 -11
  150. package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.tsx +147 -119
  151. package/src/charts/pie-semi-circle-chart/test/pie-semi-circle-chart.test.tsx +46 -6
  152. package/src/charts/private/with-responsive/test/with-responsive.test.tsx +5 -5
  153. package/src/charts/private/with-responsive/with-responsive.tsx +8 -7
  154. package/src/hooks/index.ts +1 -1
  155. package/src/hooks/test/{use-element-height.test.tsx → use-element-size.test.tsx} +45 -36
  156. package/src/hooks/use-element-size.ts +43 -0
  157. package/src/hooks/use-tooltip-portal-relocator.module.scss +1 -4
  158. package/src/hooks/use-tooltip-portal-relocator.ts +11 -0
  159. package/src/types.ts +13 -3
  160. package/dist/chunk-32ESS4MV.js.map +0 -1
  161. package/dist/chunk-7QDEU3KN.cjs.map +0 -1
  162. package/dist/chunk-7TQSPLIN.js.map +0 -1
  163. package/dist/chunk-DBY6C4O2.js.map +0 -1
  164. package/dist/chunk-DLSUC7RN.js.map +0 -1
  165. package/dist/chunk-EJJO2QNB.cjs.map +0 -1
  166. package/dist/chunk-FIFSYVN6.cjs.map +0 -1
  167. package/dist/chunk-FY325WQ4.cjs.map +0 -1
  168. package/dist/chunk-IHESL7H5.cjs.map +0 -1
  169. package/dist/chunk-JL4ZKKZU.cjs +0 -375
  170. package/dist/chunk-JL4ZKKZU.cjs.map +0 -1
  171. package/dist/chunk-KXSLMOW5.js.map +0 -1
  172. package/dist/chunk-LT4YOIMM.js.map +0 -1
  173. package/dist/chunk-TKPK4RFS.cjs.map +0 -1
  174. package/dist/chunk-TYIH5LMV.js.map +0 -1
  175. package/src/hooks/use-element-height.ts +0 -37
  176. /package/dist/{chunk-KHRPRH4V.js.map → chunk-E62LCBGD.js.map} +0 -0
  177. /package/dist/{chunk-PCOI2GT5.js.map → chunk-GWBS65VC.js.map} +0 -0
  178. /package/dist/{chunk-X6GX4QUJ.js.map → chunk-KHQPN77E.js.map} +0 -0
  179. /package/dist/{chunk-AFWQR3SM.js.map → chunk-MDRCAGKZ.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, CSSProperties, FC } from 'react';
3
- import { b as CompleteChartTheme, j as SeriesData, d as DataPointPercentage, C as ChartTheme } from './types-BCFQlzTM.js';
3
+ import { b as CompleteChartTheme, j as SeriesData, d as DataPointPercentage, C as ChartTheme } from './types-CzdN7rUe.js';
4
4
  import { B as BaseLegendItem } from './types-C05PdDJa.js';
5
5
  import { LegendShape } from '@visx/legend/lib/types';
6
6
  import { LineStyles, GlyphProps } from '@visx/xychart';
@@ -7,6 +7,7 @@ import { LegendShape } from '@visx/legend/lib/types';
7
7
  import { ScaleType, ScaleInput } from '@visx/scale';
8
8
  import { TextProps } from '@visx/text/lib/Text';
9
9
  import { EventHandlerParams, LineStyles, GridStyles, GlyphProps } from '@visx/xychart';
10
+ import { GapSize } from '@wordpress/theme';
10
11
  import { PointerEvent, ReactNode, CSSProperties } from 'react';
11
12
  import { GoogleDataTableColumn, GoogleDataTableRow } from 'react-google-charts';
12
13
 
@@ -334,15 +335,17 @@ type BaseChartProps<T = DataPoint | DataPointDate | LeaderboardEntry> = {
334
335
  */
335
336
  className?: string;
336
337
  /**
337
- * Width of the chart in pixels
338
+ * Width of the chart container in pixels. When omitted, the chart fills its parent's width.
338
339
  */
339
340
  width?: number;
340
341
  /**
341
- * Height of the chart in pixels
342
+ * Height of the chart container in pixels. When omitted, the chart fills its parent's height.
342
343
  */
343
344
  height?: number;
344
345
  /**
345
- * Size of the chart in pixels for pie and donut charts
346
+ * Maximum diameter of the pie in pixels (pie and donut charts only).
347
+ * The pie will shrink if the container is smaller than this value.
348
+ * When omitted, the pie fills the available space.
346
349
  */
347
350
  size?: number;
348
351
  /**
@@ -426,6 +429,12 @@ type BaseChartProps<T = DataPoint | DataPointDate | LeaderboardEntry> = {
426
429
  * Whether to show chart animation on initial render or not
427
430
  */
428
431
  animation?: boolean;
432
+ /**
433
+ * Gap between chart elements (SVG, legend, children).
434
+ * Uses WordPress design system tokens.
435
+ * @default 'md'
436
+ */
437
+ gap?: GapSize;
429
438
  /**
430
439
  * More options for the chart.
431
440
  */
@@ -7,6 +7,7 @@ import { LegendShape } from '@visx/legend/lib/types';
7
7
  import { ScaleType, ScaleInput } from '@visx/scale';
8
8
  import { TextProps } from '@visx/text/lib/Text';
9
9
  import { EventHandlerParams, LineStyles, GridStyles, GlyphProps } from '@visx/xychart';
10
+ import { GapSize } from '@wordpress/theme';
10
11
  import { PointerEvent, ReactNode, CSSProperties } from 'react';
11
12
  import { GoogleDataTableColumn, GoogleDataTableRow } from 'react-google-charts';
12
13
 
@@ -334,15 +335,17 @@ type BaseChartProps<T = DataPoint | DataPointDate | LeaderboardEntry> = {
334
335
  */
335
336
  className?: string;
336
337
  /**
337
- * Width of the chart in pixels
338
+ * Width of the chart container in pixels. When omitted, the chart fills its parent's width.
338
339
  */
339
340
  width?: number;
340
341
  /**
341
- * Height of the chart in pixels
342
+ * Height of the chart container in pixels. When omitted, the chart fills its parent's height.
342
343
  */
343
344
  height?: number;
344
345
  /**
345
- * Size of the chart in pixels for pie and donut charts
346
+ * Maximum diameter of the pie in pixels (pie and donut charts only).
347
+ * The pie will shrink if the container is smaller than this value.
348
+ * When omitted, the pie fills the available space.
346
349
  */
347
350
  size?: number;
348
351
  /**
@@ -426,6 +429,12 @@ type BaseChartProps<T = DataPoint | DataPointDate | LeaderboardEntry> = {
426
429
  * Whether to show chart animation on initial render or not
427
430
  */
428
431
  animation?: boolean;
432
+ /**
433
+ * Gap between chart elements (SVG, legend, children).
434
+ * Uses WordPress design system tokens.
435
+ * @default 'md'
436
+ */
437
+ gap?: GapSize;
429
438
  /**
430
439
  * More options for the chart.
431
440
  */
@@ -1,7 +1,7 @@
1
1
  export { M as MetricValueType, f as formatMetricValue } from '../format-metric-value-MXm5DtQ_.cjs';
2
2
  import { TickFormatter } from '@visx/axis';
3
3
  import { AnyD3Scale, ScaleInput } from '@visx/scale';
4
- import { j as SeriesData, C as ChartTheme, b as CompleteChartTheme } from '../types-BCFQlzTM.cjs';
4
+ import { j as SeriesData, C as ChartTheme, b as CompleteChartTheme } from '../types-CzdN7rUe.cjs';
5
5
  import { LegendShape } from '@visx/legend/lib/types';
6
6
  import { LineStyles } from '@visx/xychart';
7
7
  import '@visx/annotation/lib/components/CircleSubject';
@@ -9,6 +9,7 @@ import '@visx/annotation/lib/components/Connector';
9
9
  import '@visx/annotation/lib/components/Label';
10
10
  import '@visx/annotation/lib/components/LineSubject';
11
11
  import '@visx/text/lib/Text';
12
+ import '@wordpress/theme';
12
13
  import 'react';
13
14
  import 'react-google-charts';
14
15
 
@@ -1,7 +1,7 @@
1
1
  export { M as MetricValueType, f as formatMetricValue } from '../format-metric-value-MXm5DtQ_.js';
2
2
  import { TickFormatter } from '@visx/axis';
3
3
  import { AnyD3Scale, ScaleInput } from '@visx/scale';
4
- import { j as SeriesData, C as ChartTheme, b as CompleteChartTheme } from '../types-BCFQlzTM.js';
4
+ import { j as SeriesData, C as ChartTheme, b as CompleteChartTheme } from '../types-CzdN7rUe.js';
5
5
  import { LegendShape } from '@visx/legend/lib/types';
6
6
  import { LineStyles } from '@visx/xychart';
7
7
  import '@visx/annotation/lib/components/CircleSubject';
@@ -9,6 +9,7 @@ import '@visx/annotation/lib/components/Connector';
9
9
  import '@visx/annotation/lib/components/Label';
10
10
  import '@visx/annotation/lib/components/LineSubject';
11
11
  import '@visx/text/lib/Text';
12
+ import '@wordpress/theme';
12
13
  import 'react';
13
14
  import 'react-google-charts';
14
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/charts",
3
- "version": "0.56.5",
3
+ "version": "0.56.7",
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": {
@@ -200,8 +200,8 @@
200
200
  "@visx/vendor": "^3.12.0",
201
201
  "@visx/xychart": "^3.12.0",
202
202
  "@wordpress/i18n": "^6.0.0",
203
- "@wordpress/theme": "0.6.0",
204
- "@wordpress/ui": "0.6.0",
203
+ "@wordpress/theme": "0.7.0",
204
+ "@wordpress/ui": "0.7.0",
205
205
  "clsx": "2.1.1",
206
206
  "date-fns": "^4.1.0",
207
207
  "deepmerge": "4.3.1",
@@ -215,18 +215,18 @@
215
215
  "@babel/core": "7.29.0",
216
216
  "@babel/preset-react": "7.28.5",
217
217
  "@babel/preset-typescript": "7.28.5",
218
- "@storybook/addon-docs": "10.2.3",
219
- "@storybook/react": "10.2.3",
218
+ "@storybook/addon-docs": "10.2.11",
219
+ "@storybook/react": "10.2.11",
220
220
  "@testing-library/dom": "^10.0.0",
221
221
  "@testing-library/jest-dom": "^6.0.0",
222
222
  "@testing-library/react": "^16.0.0",
223
223
  "@testing-library/user-event": "^14.4.3",
224
224
  "@types/jest": "^30.0.0",
225
- "@types/react": "18.3.26",
225
+ "@types/react": "18.3.28",
226
226
  "@types/react-dom": "18.3.7",
227
227
  "@visx/glyph": "3.12.0",
228
- "@wordpress/components": "32.1.0",
229
- "@wordpress/element": "6.39.0",
228
+ "@wordpress/components": "32.2.0",
229
+ "@wordpress/element": "6.40.0",
230
230
  "babel-jest": "30.2.0",
231
231
  "babel-plugin-react-remove-properties": "^0.3.1",
232
232
  "esbuild": "0.25.9",
@@ -239,7 +239,7 @@
239
239
  "react": "18.3.1",
240
240
  "react-dom": "18.3.1",
241
241
  "sass-embedded": "1.97.2",
242
- "storybook": "10.2.3",
242
+ "storybook": "10.2.11",
243
243
  "tsup": "8.5.1",
244
244
  "typescript": "5.9.3"
245
245
  },
@@ -12,7 +12,7 @@ import {
12
12
  useChartDataTransform,
13
13
  useZeroValueDisplay,
14
14
  useChartMargin,
15
- useElementHeight,
15
+ useElementSize,
16
16
  useHasLegendChild,
17
17
  usePrefersReducedMotion,
18
18
  } from '../../hooks';
@@ -32,7 +32,6 @@ import { useBarChartOptions } from './private';
32
32
  import type { BaseChartProps, DataPointDate, SeriesData, Optional } from '../../types';
33
33
  import type { ResponsiveConfig } from '../private/with-responsive';
34
34
  import type { RenderTooltipParams } from '@visx/xychart/lib/components/Tooltip';
35
- import type { GapSize } from '@wordpress/theme';
36
35
  import type { FC, ReactNode, ComponentType } from 'react';
37
36
 
38
37
  export interface BarChartProps extends BaseChartProps< SeriesData[] > {
@@ -42,12 +41,6 @@ export interface BarChartProps extends BaseChartProps< SeriesData[] > {
42
41
  showZeroValues?: boolean;
43
42
  legendInteractive?: boolean;
44
43
  children?: ReactNode;
45
- /**
46
- * Gap between chart elements (SVG, legend, children).
47
- * Uses WordPress design system tokens.
48
- * @default 'md'
49
- */
50
- gap?: GapSize;
51
44
  }
52
45
 
53
46
  // Base props type with optional responsive properties
@@ -125,7 +118,7 @@ const BarChartInternal: FC< BarChartProps > = ( {
125
118
  const legendItems = useChartLegendItems( dataSorted );
126
119
  const chartOptions = useBarChartOptions( dataWithVisibleZeros, horizontal, options );
127
120
  const defaultMargin = useChartMargin( height, chartOptions, dataSorted, theme, horizontal );
128
- const [ svgWrapperRef, svgWrapperHeight ] = useElementHeight< HTMLDivElement >();
121
+ const [ svgWrapperRef, , svgWrapperHeight ] = useElementSize< HTMLDivElement >();
129
122
  const chartRef = useRef< HTMLDivElement >( null );
130
123
 
131
124
  // Check if children contain a Legend component (composition pattern)
@@ -3,10 +3,10 @@ import userEvent from '@testing-library/user-event';
3
3
  import { GlobalChartsProvider } from '../../../providers';
4
4
  import BarChart from '../bar-chart';
5
5
 
6
- // Mock useElementHeight to return a non-zero height in jsdom so charts render
6
+ // Mock useElementSize to return non-zero dimensions in jsdom so charts render
7
7
  const mockRefCallback = jest.fn();
8
- jest.mock( '../../../hooks/use-element-height', () => ( {
9
- useElementHeight: () => [ mockRefCallback, 300 ], // Return test height to allow chart rendering
8
+ jest.mock( '../../../hooks/use-element-size', () => ( {
9
+ useElementSize: () => [ mockRefCallback, 500, 300 ],
10
10
  } ) );
11
11
 
12
12
  describe( 'BarChart', () => {
@@ -14,7 +14,7 @@ import {
14
14
  useXYChartTheme,
15
15
  useChartDataTransform,
16
16
  useChartMargin,
17
- useElementHeight,
17
+ useElementSize,
18
18
  useHasLegendChild,
19
19
  usePrefersReducedMotion,
20
20
  } from '../../hooks';
@@ -288,7 +288,7 @@ const LineChartInternal = forwardRef< SingleChartRef, LineChartProps >(
288
288
  const providerTheme = useGlobalChartsTheme();
289
289
  const theme = useXYChartTheme( data );
290
290
  const chartId = useChartId( providedChartId );
291
- const [ svgWrapperRef, svgWrapperHeight ] = useElementHeight< HTMLDivElement >();
291
+ const [ svgWrapperRef, , svgWrapperHeight ] = useElementSize< HTMLDivElement >();
292
292
  const chartRef = useRef< HTMLDivElement >( null );
293
293
  const [ selectedIndex, setSelectedIndex ] = useState< number | undefined >( undefined );
294
294
  const [ isNavigating, setIsNavigating ] = useState( false );
@@ -8,10 +8,10 @@ import { GlobalChartsProvider, defaultTheme } from '../../../providers';
8
8
  import LineChart, { LineChartUnresponsive } from '../line-chart';
9
9
  import type { SingleChartRef } from '../../private/single-chart-context';
10
10
 
11
- // Mock useElementHeight to return a non-zero height in jsdom so charts render
11
+ // Mock useElementSize to return non-zero dimensions in jsdom so charts render
12
12
  const mockRefCallback = jest.fn();
13
- jest.mock( '../../../hooks/use-element-height', () => ( {
14
- useElementHeight: () => [ mockRefCallback, 300 ], // Return test height to allow chart rendering
13
+ jest.mock( '../../../hooks/use-element-size', () => ( {
14
+ useElementSize: () => [ mockRefCallback, 500, 300 ],
15
15
  } ) );
16
16
 
17
17
  const customTheme = {
@@ -7,7 +7,6 @@ import type {
7
7
  } from '../../types';
8
8
  import type { GlyphProps } from '@visx/xychart';
9
9
  import type { RenderTooltipParams } from '@visx/xychart/lib/components/Tooltip';
10
- import type { GapSize } from '@wordpress/theme';
11
10
  import type { ReactNode, SVGProps, FC } from 'react';
12
11
 
13
12
  export type LineChartAnnotationProps = {
@@ -44,12 +43,6 @@ export interface LineChartProps extends BaseChartProps< SeriesData[] > {
44
43
  };
45
44
  legendInteractive?: boolean;
46
45
  children?: ReactNode;
47
- /**
48
- * Gap between chart elements (SVG, legend, children).
49
- * Uses WordPress design system tokens.
50
- * @default 'md'
51
- */
52
- gap?: GapSize;
53
46
  }
54
47
 
55
48
  export type TooltipDatum = {
@@ -3,9 +3,20 @@
3
3
  flex-direction: column;
4
4
  overflow: hidden;
5
5
  align-items: center;
6
- gap: 20px;
7
6
 
8
- &--legend-top {
9
- flex-direction: column-reverse;
7
+ // Fill parent when no explicit width/height provided
8
+ &--responsive {
9
+ height: 100%;
10
+ width: 100%;
11
+ }
12
+
13
+ &__svg-wrapper {
14
+ flex: 1;
15
+ min-height: 0; // Required for flex shrinking
16
+ min-width: 0; // Required for flex shrinking
17
+ width: 100%;
18
+ display: flex;
19
+ align-items: center;
20
+ justify-content: center;
10
21
  }
11
22
  }