@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.
- package/AGENTS.md +135 -0
- package/CHANGELOG.md +17 -0
- package/README.md +2 -1
- package/dist/charts/bar-chart/index.cjs +6 -6
- package/dist/charts/bar-chart/index.css +1 -4
- package/dist/charts/bar-chart/index.css.map +1 -1
- package/dist/charts/bar-chart/index.d.cts +2 -8
- package/dist/charts/bar-chart/index.d.ts +2 -8
- package/dist/charts/bar-chart/index.js +5 -5
- package/dist/charts/bar-list-chart/index.cjs +7 -7
- package/dist/charts/bar-list-chart/index.css +1 -4
- package/dist/charts/bar-list-chart/index.css.map +1 -1
- package/dist/charts/bar-list-chart/index.d.cts +2 -2
- package/dist/charts/bar-list-chart/index.d.ts +2 -2
- package/dist/charts/bar-list-chart/index.js +6 -6
- package/dist/charts/conversion-funnel-chart/index.cjs +5 -5
- package/dist/charts/conversion-funnel-chart/index.css +1 -4
- package/dist/charts/conversion-funnel-chart/index.css.map +1 -1
- package/dist/charts/conversion-funnel-chart/index.d.cts +2 -1
- package/dist/charts/conversion-funnel-chart/index.d.ts +2 -1
- package/dist/charts/conversion-funnel-chart/index.js +4 -4
- package/dist/charts/geo-chart/index.cjs +4 -4
- package/dist/charts/geo-chart/index.css +1 -4
- package/dist/charts/geo-chart/index.css.map +1 -1
- package/dist/charts/geo-chart/index.d.cts +2 -1
- package/dist/charts/geo-chart/index.d.ts +2 -1
- package/dist/charts/geo-chart/index.js +3 -3
- package/dist/charts/leaderboard-chart/index.cjs +5 -5
- package/dist/charts/leaderboard-chart/index.css +1 -4
- package/dist/charts/leaderboard-chart/index.css.map +1 -1
- package/dist/charts/leaderboard-chart/index.d.cts +3 -2
- package/dist/charts/leaderboard-chart/index.d.ts +3 -2
- package/dist/charts/leaderboard-chart/index.js +4 -4
- package/dist/charts/line-chart/index.cjs +6 -6
- package/dist/charts/line-chart/index.css +1 -4
- package/dist/charts/line-chart/index.css.map +1 -1
- package/dist/charts/line-chart/index.d.cts +2 -8
- package/dist/charts/line-chart/index.d.ts +2 -8
- package/dist/charts/line-chart/index.js +5 -5
- package/dist/charts/pie-chart/index.cjs +6 -4
- package/dist/charts/pie-chart/index.cjs.map +1 -1
- package/dist/charts/pie-chart/index.css +13 -7
- package/dist/charts/pie-chart/index.css.map +1 -1
- package/dist/charts/pie-chart/index.d.cts +2 -1
- package/dist/charts/pie-chart/index.d.ts +2 -1
- package/dist/charts/pie-chart/index.js +5 -3
- package/dist/charts/pie-semi-circle-chart/index.cjs +6 -4
- package/dist/charts/pie-semi-circle-chart/index.cjs.map +1 -1
- package/dist/charts/pie-semi-circle-chart/index.css +12 -13
- package/dist/charts/pie-semi-circle-chart/index.css.map +1 -1
- package/dist/charts/pie-semi-circle-chart/index.d.cts +5 -2
- package/dist/charts/pie-semi-circle-chart/index.d.ts +5 -2
- package/dist/charts/pie-semi-circle-chart/index.js +5 -3
- package/dist/charts/sparkline/index.cjs +7 -7
- package/dist/charts/sparkline/index.css +1 -4
- package/dist/charts/sparkline/index.css.map +1 -1
- package/dist/charts/sparkline/index.js +6 -6
- package/dist/{chunk-NGHXTIUE.cjs → chunk-3EXJP67N.cjs} +7 -7
- package/dist/{chunk-NGHXTIUE.cjs.map → chunk-3EXJP67N.cjs.map} +1 -1
- package/dist/{chunk-FIFSYVN6.cjs → chunk-55ZCOYDF.cjs} +117 -132
- package/dist/chunk-55ZCOYDF.cjs.map +1 -0
- package/dist/{chunk-LT4YOIMM.js → chunk-7FDQGBY7.js} +145 -119
- package/dist/chunk-7FDQGBY7.js.map +1 -0
- package/dist/{chunk-7QDEU3KN.cjs → chunk-ASLARV7L.cjs} +6 -6
- package/dist/chunk-ASLARV7L.cjs.map +1 -0
- package/dist/chunk-BXFD7JIG.cjs +401 -0
- package/dist/chunk-BXFD7JIG.cjs.map +1 -0
- package/dist/{chunk-XCXAWMJQ.cjs → chunk-CAFJRZPZ.cjs} +12 -12
- package/dist/{chunk-XCXAWMJQ.cjs.map → chunk-CAFJRZPZ.cjs.map} +1 -1
- package/dist/{chunk-KHRPRH4V.js → chunk-E62LCBGD.js} +4 -4
- package/dist/{chunk-PCOI2GT5.js → chunk-GWBS65VC.js} +3 -3
- package/dist/{chunk-MEIVKY4K.js → chunk-IS5YYLTV.js} +18 -18
- package/dist/{chunk-MEIVKY4K.js.map → chunk-IS5YYLTV.js.map} +1 -1
- package/dist/{chunk-Q6G3BGCL.cjs → chunk-K6TGILHX.cjs} +8 -8
- package/dist/{chunk-Q6G3BGCL.cjs.map → chunk-K6TGILHX.cjs.map} +1 -1
- package/dist/{chunk-X6GX4QUJ.js → chunk-KHQPN77E.js} +3 -3
- package/dist/{chunk-SEKPIG5K.js → chunk-KNIMXN6Z.js} +2 -2
- package/dist/{chunk-SEKPIG5K.js.map → chunk-KNIMXN6Z.js.map} +1 -1
- package/dist/{chunk-AFWQR3SM.js → chunk-MDRCAGKZ.js} +4 -4
- package/dist/{chunk-TKPK4RFS.cjs → chunk-NQJE2CC7.cjs} +120 -98
- package/dist/chunk-NQJE2CC7.cjs.map +1 -0
- package/dist/{chunk-FY325WQ4.cjs → chunk-O2JIANHK.cjs} +25 -25
- package/dist/chunk-O2JIANHK.cjs.map +1 -0
- package/dist/{chunk-DLSUC7RN.js → chunk-OMS5QIJN.js} +6 -6
- package/dist/chunk-OMS5QIJN.js.map +1 -0
- package/dist/{chunk-TYIH5LMV.js → chunk-OP6PHB2U.js} +6 -6
- package/dist/chunk-OP6PHB2U.js.map +1 -0
- package/dist/{chunk-32ESS4MV.js → chunk-RFSHE3HL.js} +17 -7
- package/dist/chunk-RFSHE3HL.js.map +1 -0
- package/dist/{chunk-KXSLMOW5.js → chunk-SSFFCBCF.js} +6 -6
- package/dist/chunk-SSFFCBCF.js.map +1 -0
- package/dist/{chunk-I5467ZJ5.cjs → chunk-SUDERBUA.cjs} +2 -2
- package/dist/{chunk-I5467ZJ5.cjs.map → chunk-SUDERBUA.cjs.map} +1 -1
- package/dist/{chunk-SH32YSZO.cjs → chunk-UFRBUT2D.cjs} +19 -19
- package/dist/{chunk-SH32YSZO.cjs.map → chunk-UFRBUT2D.cjs.map} +1 -1
- package/dist/{chunk-7TQSPLIN.js → chunk-VPAEBI2F.js} +109 -87
- package/dist/chunk-VPAEBI2F.js.map +1 -0
- package/dist/{chunk-IHESL7H5.cjs → chunk-X7JL2NYJ.cjs} +24 -24
- package/dist/chunk-X7JL2NYJ.cjs.map +1 -0
- package/dist/{chunk-DBY6C4O2.js → chunk-XD2HV7M5.js} +77 -92
- package/dist/chunk-XD2HV7M5.js.map +1 -0
- package/dist/{chunk-LTPJPIDP.cjs → chunk-YAXY5L7I.cjs} +7 -7
- package/dist/{chunk-LTPJPIDP.cjs.map → chunk-YAXY5L7I.cjs.map} +1 -1
- package/dist/{chunk-EJJO2QNB.cjs → chunk-YDVHT7GS.cjs} +17 -7
- package/dist/chunk-YDVHT7GS.cjs.map +1 -0
- package/dist/components/legend/index.cjs +2 -2
- package/dist/components/legend/index.css +1 -4
- package/dist/components/legend/index.css.map +1 -1
- package/dist/components/legend/index.d.cts +2 -1
- package/dist/components/legend/index.d.ts +2 -1
- package/dist/components/legend/index.js +1 -1
- package/dist/components/tooltip/index.d.cts +2 -1
- package/dist/components/tooltip/index.d.ts +2 -1
- package/dist/hooks/index.cjs +2 -2
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.css +1 -4
- package/dist/hooks/index.css.map +1 -1
- package/dist/hooks/index.d.cts +10 -7
- package/dist/hooks/index.d.ts +10 -7
- package/dist/hooks/index.js +3 -3
- package/dist/index.cjs +14 -14
- package/dist/index.css +24 -16
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +13 -13
- package/dist/{leaderboard-chart-B5gWcqe7.d.ts → leaderboard-chart-BSgEw_Um.d.ts} +1 -1
- package/dist/{leaderboard-chart-C_6QDcqj.d.cts → leaderboard-chart-COtgamhe.d.cts} +1 -1
- package/dist/providers/index.cjs +2 -2
- package/dist/providers/index.css +1 -4
- package/dist/providers/index.css.map +1 -1
- package/dist/providers/index.d.cts +3 -2
- package/dist/providers/index.d.ts +3 -2
- package/dist/providers/index.js +1 -1
- package/dist/{themes-BDVaIfBz.d.cts → themes-CVR5rmIs.d.cts} +1 -1
- package/dist/{themes-mcS8QNkQ.d.ts → themes-DQzmaSze.d.ts} +1 -1
- package/dist/{types-BCFQlzTM.d.ts → types-CzdN7rUe.d.cts} +12 -3
- package/dist/{types-BCFQlzTM.d.cts → types-CzdN7rUe.d.ts} +12 -3
- package/dist/utils/index.d.cts +2 -1
- package/dist/utils/index.d.ts +2 -1
- package/package.json +9 -9
- package/src/charts/bar-chart/bar-chart.tsx +2 -9
- package/src/charts/bar-chart/test/bar-chart.test.tsx +3 -3
- package/src/charts/line-chart/line-chart.tsx +2 -2
- package/src/charts/line-chart/test/line-chart.test.tsx +3 -3
- package/src/charts/line-chart/types.ts +0 -7
- package/src/charts/pie-chart/pie-chart.module.scss +14 -3
- package/src/charts/pie-chart/pie-chart.tsx +172 -148
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.module.scss +17 -11
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.tsx +147 -119
- package/src/charts/pie-semi-circle-chart/test/pie-semi-circle-chart.test.tsx +46 -6
- package/src/charts/private/with-responsive/test/with-responsive.test.tsx +5 -5
- package/src/charts/private/with-responsive/with-responsive.tsx +8 -7
- package/src/hooks/index.ts +1 -1
- package/src/hooks/test/{use-element-height.test.tsx → use-element-size.test.tsx} +45 -36
- package/src/hooks/use-element-size.ts +43 -0
- package/src/hooks/use-tooltip-portal-relocator.module.scss +1 -4
- package/src/hooks/use-tooltip-portal-relocator.ts +11 -0
- package/src/types.ts +13 -3
- package/dist/chunk-32ESS4MV.js.map +0 -1
- package/dist/chunk-7QDEU3KN.cjs.map +0 -1
- package/dist/chunk-7TQSPLIN.js.map +0 -1
- package/dist/chunk-DBY6C4O2.js.map +0 -1
- package/dist/chunk-DLSUC7RN.js.map +0 -1
- package/dist/chunk-EJJO2QNB.cjs.map +0 -1
- package/dist/chunk-FIFSYVN6.cjs.map +0 -1
- package/dist/chunk-FY325WQ4.cjs.map +0 -1
- package/dist/chunk-IHESL7H5.cjs.map +0 -1
- package/dist/chunk-JL4ZKKZU.cjs +0 -375
- package/dist/chunk-JL4ZKKZU.cjs.map +0 -1
- package/dist/chunk-KXSLMOW5.js.map +0 -1
- package/dist/chunk-LT4YOIMM.js.map +0 -1
- package/dist/chunk-TKPK4RFS.cjs.map +0 -1
- package/dist/chunk-TYIH5LMV.js.map +0 -1
- package/src/hooks/use-element-height.ts +0 -37
- /package/dist/{chunk-KHRPRH4V.js.map → chunk-E62LCBGD.js.map} +0 -0
- /package/dist/{chunk-PCOI2GT5.js.map → chunk-GWBS65VC.js.map} +0 -0
- /package/dist/{chunk-X6GX4QUJ.js.map → chunk-KHQPN77E.js.map} +0 -0
- /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-
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
*/
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -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-
|
|
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
|
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -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-
|
|
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.
|
|
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.
|
|
204
|
-
"@wordpress/ui": "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.
|
|
219
|
-
"@storybook/react": "10.2.
|
|
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.
|
|
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.
|
|
229
|
-
"@wordpress/element": "6.
|
|
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.
|
|
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
|
-
|
|
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 ] =
|
|
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
|
|
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-
|
|
9
|
-
|
|
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
|
-
|
|
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 ] =
|
|
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
|
|
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-
|
|
14
|
-
|
|
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
|
-
|
|
9
|
-
|
|
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
|
}
|