@automattic/charts 0.58.0 → 0.59.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.
- package/CHANGELOG.md +20 -0
- package/README.md +7 -54
- package/dist/index.cjs +9606 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +20 -25
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +1612 -33
- package/dist/index.d.ts +1612 -33
- package/dist/index.js +9640 -56
- package/dist/index.js.map +1 -1
- package/package.json +8 -125
- package/src/charts/bar-chart/bar-chart.module.scss +0 -5
- package/src/charts/bar-chart/bar-chart.tsx +131 -137
- package/src/charts/leaderboard-chart/leaderboard-chart.tsx +23 -40
- package/src/charts/line-chart/line-chart.module.scss +0 -5
- package/src/charts/line-chart/line-chart.tsx +190 -183
- package/src/charts/line-chart/private/line-chart-annotations-overlay.tsx +1 -2
- package/src/charts/pie-chart/pie-chart.module.scss +2 -10
- package/src/charts/pie-chart/pie-chart.tsx +198 -199
- package/src/charts/pie-chart/test/composition-api.test.tsx +3 -3
- package/src/charts/pie-chart/test/pie-chart.test.tsx +42 -35
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.module.scss +2 -8
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.tsx +155 -155
- package/src/charts/pie-semi-circle-chart/test/pie-semi-circle-chart.test.tsx +25 -25
- package/src/charts/private/chart-layout/chart-layout.module.scss +7 -0
- package/src/charts/private/chart-layout/chart-layout.tsx +106 -0
- package/src/charts/private/chart-layout/index.ts +2 -0
- package/src/charts/private/chart-layout/test/chart-layout.test.tsx +167 -0
- package/src/charts/private/single-chart-context/single-chart-context.tsx +2 -2
- package/src/charts/private/svg-empty-state/index.ts +1 -0
- package/src/charts/private/svg-empty-state/svg-empty-state.module.scss +7 -0
- package/src/charts/private/svg-empty-state/svg-empty-state.tsx +40 -0
- package/src/components/legend/hooks/test/use-chart-legend-items.test.tsx +12 -8
- package/src/components/legend/hooks/use-chart-legend-items.ts +12 -13
- package/src/components/legend/legend.tsx +33 -8
- package/src/components/legend/test/legend.test.tsx +93 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-data-with-percentages.ts +24 -0
- package/src/hooks/use-interactive-legend-data.ts +18 -15
- package/src/index.ts +65 -2
- package/src/providers/chart-context/global-charts-provider.tsx +7 -1
- package/src/providers/chart-context/hooks/use-chart-registration.ts +2 -1
- package/src/providers/chart-context/types.ts +2 -2
- package/src/types.ts +27 -7
- package/src/utils/test/resolve-css-var.test.ts +2 -0
- package/dist/base-tooltip-DOq93wjU.d.cts +0 -38
- package/dist/base-tooltip-DOq93wjU.d.ts +0 -38
- package/dist/charts/bar-chart/index.cjs +0 -17
- package/dist/charts/bar-chart/index.cjs.map +0 -1
- package/dist/charts/bar-chart/index.css +0 -141
- package/dist/charts/bar-chart/index.css.map +0 -1
- package/dist/charts/bar-chart/index.d.cts +0 -36
- package/dist/charts/bar-chart/index.d.ts +0 -36
- package/dist/charts/bar-chart/index.js +0 -17
- package/dist/charts/bar-chart/index.js.map +0 -1
- package/dist/charts/bar-list-chart/index.cjs +0 -18
- package/dist/charts/bar-list-chart/index.cjs.map +0 -1
- package/dist/charts/bar-list-chart/index.css +0 -141
- package/dist/charts/bar-list-chart/index.css.map +0 -1
- package/dist/charts/bar-list-chart/index.d.cts +0 -92
- package/dist/charts/bar-list-chart/index.d.ts +0 -92
- package/dist/charts/bar-list-chart/index.js +0 -18
- package/dist/charts/bar-list-chart/index.js.map +0 -1
- package/dist/charts/conversion-funnel-chart/index.cjs +0 -11
- package/dist/charts/conversion-funnel-chart/index.cjs.map +0 -1
- package/dist/charts/conversion-funnel-chart/index.css +0 -157
- package/dist/charts/conversion-funnel-chart/index.css.map +0 -1
- package/dist/charts/conversion-funnel-chart/index.d.cts +0 -97
- package/dist/charts/conversion-funnel-chart/index.d.ts +0 -97
- package/dist/charts/conversion-funnel-chart/index.js +0 -11
- package/dist/charts/conversion-funnel-chart/index.js.map +0 -1
- package/dist/charts/geo-chart/index.cjs +0 -13
- package/dist/charts/geo-chart/index.cjs.map +0 -1
- package/dist/charts/geo-chart/index.css +0 -23
- package/dist/charts/geo-chart/index.css.map +0 -1
- package/dist/charts/geo-chart/index.d.cts +0 -67
- package/dist/charts/geo-chart/index.d.ts +0 -67
- package/dist/charts/geo-chart/index.js +0 -13
- package/dist/charts/geo-chart/index.js.map +0 -1
- package/dist/charts/leaderboard-chart/index.cjs +0 -21
- package/dist/charts/leaderboard-chart/index.cjs.map +0 -1
- package/dist/charts/leaderboard-chart/index.css +0 -160
- package/dist/charts/leaderboard-chart/index.css.map +0 -1
- package/dist/charts/leaderboard-chart/index.d.cts +0 -46
- package/dist/charts/leaderboard-chart/index.d.ts +0 -46
- package/dist/charts/leaderboard-chart/index.js +0 -21
- package/dist/charts/leaderboard-chart/index.js.map +0 -1
- package/dist/charts/line-chart/index.cjs +0 -17
- package/dist/charts/line-chart/index.cjs.map +0 -1
- package/dist/charts/line-chart/index.css +0 -213
- package/dist/charts/line-chart/index.css.map +0 -1
- package/dist/charts/line-chart/index.d.cts +0 -98
- package/dist/charts/line-chart/index.d.ts +0 -98
- package/dist/charts/line-chart/index.js +0 -17
- package/dist/charts/line-chart/index.js.map +0 -1
- package/dist/charts/pie-chart/index.cjs +0 -19
- package/dist/charts/pie-chart/index.cjs.map +0 -1
- package/dist/charts/pie-chart/index.css +0 -131
- package/dist/charts/pie-chart/index.css.map +0 -1
- package/dist/charts/pie-chart/index.d.cts +0 -91
- package/dist/charts/pie-chart/index.d.ts +0 -91
- package/dist/charts/pie-chart/index.js +0 -19
- package/dist/charts/pie-chart/index.js.map +0 -1
- package/dist/charts/pie-semi-circle-chart/index.cjs +0 -18
- package/dist/charts/pie-semi-circle-chart/index.cjs.map +0 -1
- package/dist/charts/pie-semi-circle-chart/index.css +0 -132
- package/dist/charts/pie-semi-circle-chart/index.css.map +0 -1
- package/dist/charts/pie-semi-circle-chart/index.d.cts +0 -88
- package/dist/charts/pie-semi-circle-chart/index.d.ts +0 -88
- package/dist/charts/pie-semi-circle-chart/index.js +0 -18
- package/dist/charts/pie-semi-circle-chart/index.js.map +0 -1
- package/dist/charts/sparkline/index.cjs +0 -18
- package/dist/charts/sparkline/index.cjs.map +0 -1
- package/dist/charts/sparkline/index.css +0 -230
- package/dist/charts/sparkline/index.css.map +0 -1
- package/dist/charts/sparkline/index.d.cts +0 -113
- package/dist/charts/sparkline/index.d.ts +0 -113
- package/dist/charts/sparkline/index.js +0 -18
- package/dist/charts/sparkline/index.js.map +0 -1
- package/dist/chunk-2A34OA5O.cjs +0 -51
- package/dist/chunk-2A34OA5O.cjs.map +0 -1
- package/dist/chunk-2I67QUIV.js +0 -895
- package/dist/chunk-2I67QUIV.js.map +0 -1
- package/dist/chunk-2ICEEQOC.js +0 -1071
- package/dist/chunk-2ICEEQOC.js.map +0 -1
- package/dist/chunk-4B7BL2DD.js +0 -120
- package/dist/chunk-4B7BL2DD.js.map +0 -1
- package/dist/chunk-4OXMTKAL.js +0 -401
- package/dist/chunk-4OXMTKAL.js.map +0 -1
- package/dist/chunk-ASLARV7L.cjs +0 -81
- package/dist/chunk-ASLARV7L.cjs.map +0 -1
- package/dist/chunk-B6NLZFRW.js +0 -617
- package/dist/chunk-B6NLZFRW.js.map +0 -1
- package/dist/chunk-BBAUQOW6.cjs +0 -120
- package/dist/chunk-BBAUQOW6.cjs.map +0 -1
- package/dist/chunk-BPYKWMI7.js +0 -194
- package/dist/chunk-BPYKWMI7.js.map +0 -1
- package/dist/chunk-CMMHCTBX.cjs +0 -373
- package/dist/chunk-CMMHCTBX.cjs.map +0 -1
- package/dist/chunk-CPPXJATQ.cjs +0 -1071
- package/dist/chunk-CPPXJATQ.cjs.map +0 -1
- package/dist/chunk-DKU775VC.js +0 -219
- package/dist/chunk-DKU775VC.js.map +0 -1
- package/dist/chunk-GRA7Y2ZG.cjs +0 -401
- package/dist/chunk-GRA7Y2ZG.cjs.map +0 -1
- package/dist/chunk-I2276W3I.cjs +0 -66
- package/dist/chunk-I2276W3I.cjs.map +0 -1
- package/dist/chunk-JJIMABHT.js +0 -351
- package/dist/chunk-JJIMABHT.js.map +0 -1
- package/dist/chunk-KJHWXOCZ.js +0 -421
- package/dist/chunk-KJHWXOCZ.js.map +0 -1
- package/dist/chunk-KRWGSOJ2.js +0 -91
- package/dist/chunk-KRWGSOJ2.js.map +0 -1
- package/dist/chunk-KXRWNFQJ.js +0 -51
- package/dist/chunk-KXRWNFQJ.js.map +0 -1
- package/dist/chunk-LTFH7SEG.js +0 -373
- package/dist/chunk-LTFH7SEG.js.map +0 -1
- package/dist/chunk-MUNOKLLE.js +0 -165
- package/dist/chunk-MUNOKLLE.js.map +0 -1
- package/dist/chunk-MXGLYWVP.cjs +0 -351
- package/dist/chunk-MXGLYWVP.cjs.map +0 -1
- package/dist/chunk-OP6PHB2U.js +0 -81
- package/dist/chunk-OP6PHB2U.js.map +0 -1
- package/dist/chunk-OYC34VTO.cjs +0 -3957
- package/dist/chunk-OYC34VTO.cjs.map +0 -1
- package/dist/chunk-PQL5I3F6.cjs +0 -421
- package/dist/chunk-PQL5I3F6.cjs.map +0 -1
- package/dist/chunk-REZTQ4PH.cjs +0 -488
- package/dist/chunk-REZTQ4PH.cjs.map +0 -1
- package/dist/chunk-TZRUHQOH.cjs +0 -91
- package/dist/chunk-TZRUHQOH.cjs.map +0 -1
- package/dist/chunk-UTYVIOWZ.js +0 -3957
- package/dist/chunk-UTYVIOWZ.js.map +0 -1
- package/dist/chunk-W2LDIX26.cjs +0 -165
- package/dist/chunk-W2LDIX26.cjs.map +0 -1
- package/dist/chunk-WSG64BVN.cjs +0 -219
- package/dist/chunk-WSG64BVN.cjs.map +0 -1
- package/dist/chunk-WTQYGUNF.js +0 -400
- package/dist/chunk-WTQYGUNF.js.map +0 -1
- package/dist/chunk-WYK7EL5R.cjs +0 -895
- package/dist/chunk-WYK7EL5R.cjs.map +0 -1
- package/dist/chunk-XC4KHJYX.cjs +0 -617
- package/dist/chunk-XC4KHJYX.cjs.map +0 -1
- package/dist/chunk-XVBH5XHE.cjs +0 -400
- package/dist/chunk-XVBH5XHE.cjs.map +0 -1
- package/dist/chunk-XWYZIFZW.js +0 -66
- package/dist/chunk-XWYZIFZW.js.map +0 -1
- package/dist/chunk-Y3NNQMAX.cjs +0 -194
- package/dist/chunk-Y3NNQMAX.cjs.map +0 -1
- package/dist/chunk-YAFQVVDI.js +0 -488
- package/dist/chunk-YAFQVVDI.js.map +0 -1
- package/dist/components/legend/index.cjs +0 -12
- package/dist/components/legend/index.cjs.map +0 -1
- package/dist/components/legend/index.css +0 -91
- package/dist/components/legend/index.css.map +0 -1
- package/dist/components/legend/index.d.cts +0 -37
- package/dist/components/legend/index.d.ts +0 -37
- package/dist/components/legend/index.js +0 -12
- package/dist/components/legend/index.js.map +0 -1
- package/dist/components/tooltip/index.cjs +0 -12
- package/dist/components/tooltip/index.cjs.map +0 -1
- package/dist/components/tooltip/index.css +0 -13
- package/dist/components/tooltip/index.css.map +0 -1
- package/dist/components/tooltip/index.d.cts +0 -71
- package/dist/components/tooltip/index.d.ts +0 -71
- package/dist/components/tooltip/index.js +0 -12
- package/dist/components/tooltip/index.js.map +0 -1
- package/dist/components/trend-indicator/index.cjs +0 -8
- package/dist/components/trend-indicator/index.cjs.map +0 -1
- package/dist/components/trend-indicator/index.css +0 -27
- package/dist/components/trend-indicator/index.css.map +0 -1
- package/dist/components/trend-indicator/index.d.cts +0 -44
- package/dist/components/trend-indicator/index.d.ts +0 -44
- package/dist/components/trend-indicator/index.js +0 -8
- package/dist/components/trend-indicator/index.js.map +0 -1
- package/dist/format-metric-value-MXm5DtQ_.d.cts +0 -24
- package/dist/format-metric-value-MXm5DtQ_.d.ts +0 -24
- package/dist/hooks/index.cjs +0 -29
- package/dist/hooks/index.cjs.map +0 -1
- package/dist/hooks/index.css +0 -9
- package/dist/hooks/index.css.map +0 -1
- package/dist/hooks/index.d.cts +0 -264
- package/dist/hooks/index.d.ts +0 -264
- package/dist/hooks/index.js +0 -29
- package/dist/hooks/index.js.map +0 -1
- package/dist/leaderboard-chart-BSbg0ufV.d.cts +0 -79
- package/dist/leaderboard-chart-odEYxxEC.d.ts +0 -79
- package/dist/legend-DFkosEvC.d.cts +0 -9
- package/dist/legend-DLswHhOk.d.ts +0 -9
- package/dist/providers/index.cjs +0 -21
- package/dist/providers/index.cjs.map +0 -1
- package/dist/providers/index.css +0 -9
- package/dist/providers/index.css.map +0 -1
- package/dist/providers/index.d.cts +0 -28
- package/dist/providers/index.d.ts +0 -28
- package/dist/providers/index.js +0 -21
- package/dist/providers/index.js.map +0 -1
- package/dist/themes-D0qc5JaW.d.cts +0 -67
- package/dist/themes-itO4Ht5g.d.ts +0 -67
- package/dist/types-B5f6XQ7Q.d.cts +0 -19
- package/dist/types-BsHooDbM.d.ts +0 -19
- package/dist/types-BuSrRM4p.d.ts +0 -49
- package/dist/types-ChOUI9-N.d.cts +0 -545
- package/dist/types-ChOUI9-N.d.ts +0 -545
- package/dist/types-Dfw9VOKI.d.cts +0 -49
- package/dist/utils/index.cjs +0 -44
- package/dist/utils/index.cjs.map +0 -1
- package/dist/utils/index.d.cts +0 -226
- package/dist/utils/index.d.ts +0 -226
- package/dist/utils/index.js +0 -44
- package/dist/utils/index.js.map +0 -1
- package/dist/with-responsive-CNfhzAUu.d.cts +0 -18
- package/dist/with-responsive-CNfhzAUu.d.ts +0 -18
package/dist/chunk-4OXMTKAL.js
DELETED
|
@@ -1,401 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getStringWidth
|
|
3
|
-
} from "./chunk-NFRB2POF.js";
|
|
4
|
-
import {
|
|
5
|
-
radial_wipe_animation_default
|
|
6
|
-
} from "./chunk-KXRWNFQJ.js";
|
|
7
|
-
import {
|
|
8
|
-
ChartHTML,
|
|
9
|
-
ChartSVG,
|
|
10
|
-
renderLegendSlot,
|
|
11
|
-
useChartChildren
|
|
12
|
-
} from "./chunk-KRWGSOJ2.js";
|
|
13
|
-
import {
|
|
14
|
-
Legend,
|
|
15
|
-
SingleChartContext,
|
|
16
|
-
useChartLegendItems
|
|
17
|
-
} from "./chunk-WTQYGUNF.js";
|
|
18
|
-
import {
|
|
19
|
-
BaseTooltip
|
|
20
|
-
} from "./chunk-BPYKWMI7.js";
|
|
21
|
-
import {
|
|
22
|
-
Stack
|
|
23
|
-
} from "./chunk-YAFQVVDI.js";
|
|
24
|
-
import {
|
|
25
|
-
withResponsive
|
|
26
|
-
} from "./chunk-OP6PHB2U.js";
|
|
27
|
-
import {
|
|
28
|
-
GlobalChartsContext,
|
|
29
|
-
GlobalChartsProvider,
|
|
30
|
-
useChartId,
|
|
31
|
-
useChartRegistration,
|
|
32
|
-
useElementSize,
|
|
33
|
-
useGlobalChartsContext,
|
|
34
|
-
useGlobalChartsTheme,
|
|
35
|
-
useInteractiveLegendData,
|
|
36
|
-
usePrefersReducedMotion
|
|
37
|
-
} from "./chunk-2I67QUIV.js";
|
|
38
|
-
import {
|
|
39
|
-
attachSubComponents
|
|
40
|
-
} from "./chunk-JJIMABHT.js";
|
|
41
|
-
|
|
42
|
-
// src/charts/pie-chart/pie-chart.tsx
|
|
43
|
-
import { Group } from "@visx/group";
|
|
44
|
-
import { Pie } from "@visx/shape";
|
|
45
|
-
import { useTooltip, useTooltipInPortal } from "@visx/tooltip";
|
|
46
|
-
import { __ } from "@wordpress/i18n";
|
|
47
|
-
import clsx from "clsx";
|
|
48
|
-
import { useCallback, useContext, useMemo } from "react";
|
|
49
|
-
|
|
50
|
-
// src/charts/pie-chart/pie-chart.module.scss
|
|
51
|
-
var pie_chart_module_default = {
|
|
52
|
-
"pie-chart": "a8ccharts-C-n-Gu",
|
|
53
|
-
"pie-chart--responsive": "a8ccharts-IQVR6j",
|
|
54
|
-
"pie-chart__svg-wrapper": "a8ccharts-iQ1Rki"
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
// src/charts/pie-chart/pie-chart.tsx
|
|
58
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
59
|
-
var renderDefaultPieTooltip = ({
|
|
60
|
-
tooltipData
|
|
61
|
-
}) => {
|
|
62
|
-
return /* @__PURE__ */ _jsx(BaseTooltip, {
|
|
63
|
-
data: tooltipData,
|
|
64
|
-
top: 0,
|
|
65
|
-
left: 0,
|
|
66
|
-
renderContainer: false
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
var validateData = (data) => {
|
|
70
|
-
if (!data.length) {
|
|
71
|
-
return {
|
|
72
|
-
isValid: false,
|
|
73
|
-
message: "No data available"
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
const hasNegativeValues = data.some((item) => item.percentage < 0 || item.value < 0);
|
|
77
|
-
if (hasNegativeValues) {
|
|
78
|
-
return {
|
|
79
|
-
isValid: false,
|
|
80
|
-
message: "Invalid data: Negative values are not allowed"
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
const totalPercentage = data.reduce((sum, item) => sum + item.percentage, 0);
|
|
84
|
-
if (Math.abs(totalPercentage - 100) > 0.01) {
|
|
85
|
-
return {
|
|
86
|
-
isValid: false,
|
|
87
|
-
message: "Invalid percentage total: Must equal 100"
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
return {
|
|
91
|
-
isValid: true,
|
|
92
|
-
message: ""
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
var PieChartInternal = ({
|
|
96
|
-
data,
|
|
97
|
-
chartId: providedChartId,
|
|
98
|
-
withTooltips = false,
|
|
99
|
-
className,
|
|
100
|
-
showLegend = false,
|
|
101
|
-
legend = {},
|
|
102
|
-
width: propWidth,
|
|
103
|
-
height: propHeight,
|
|
104
|
-
size,
|
|
105
|
-
animation,
|
|
106
|
-
thickness = 1,
|
|
107
|
-
padding = 0,
|
|
108
|
-
gapScale = 0,
|
|
109
|
-
cornerScale = 0,
|
|
110
|
-
showLabels = true,
|
|
111
|
-
legendValueDisplay = "percentage",
|
|
112
|
-
children = null,
|
|
113
|
-
tooltipOffsetX = 0,
|
|
114
|
-
tooltipOffsetY = -15,
|
|
115
|
-
renderTooltip = renderDefaultPieTooltip,
|
|
116
|
-
gap = "md"
|
|
117
|
-
}) => {
|
|
118
|
-
const legendInteractive = legend.interactive ?? false;
|
|
119
|
-
const legendPosition = legend.position ?? "bottom";
|
|
120
|
-
const providerTheme = useGlobalChartsTheme();
|
|
121
|
-
const chartId = useChartId(providedChartId);
|
|
122
|
-
const [svgWrapperRef, svgWrapperWidth, svgWrapperHeight] = useElementSize();
|
|
123
|
-
const {
|
|
124
|
-
tooltipOpen,
|
|
125
|
-
tooltipLeft,
|
|
126
|
-
tooltipTop,
|
|
127
|
-
tooltipData,
|
|
128
|
-
hideTooltip,
|
|
129
|
-
showTooltip
|
|
130
|
-
} = useTooltip();
|
|
131
|
-
const {
|
|
132
|
-
containerRef,
|
|
133
|
-
TooltipInPortal,
|
|
134
|
-
containerBounds
|
|
135
|
-
} = useTooltipInPortal({
|
|
136
|
-
detectBounds: true,
|
|
137
|
-
scroll: true,
|
|
138
|
-
debounce: 0
|
|
139
|
-
});
|
|
140
|
-
const onMouseLeave = useCallback(() => {
|
|
141
|
-
if (!withTooltips) {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
hideTooltip();
|
|
145
|
-
}, [withTooltips, hideTooltip]);
|
|
146
|
-
const {
|
|
147
|
-
getElementStyles,
|
|
148
|
-
isSeriesVisible
|
|
149
|
-
} = useGlobalChartsContext();
|
|
150
|
-
const {
|
|
151
|
-
visibleData,
|
|
152
|
-
allSegmentsHidden,
|
|
153
|
-
legendData
|
|
154
|
-
} = useInteractiveLegendData({
|
|
155
|
-
data,
|
|
156
|
-
chartId,
|
|
157
|
-
legendInteractive,
|
|
158
|
-
isSeriesVisible
|
|
159
|
-
});
|
|
160
|
-
const legendOptions = useMemo(() => ({
|
|
161
|
-
showValues: true,
|
|
162
|
-
legendValueDisplay
|
|
163
|
-
}), [legendValueDisplay]);
|
|
164
|
-
const legendItems = useChartLegendItems(legendData, legendOptions);
|
|
165
|
-
const {
|
|
166
|
-
isValid,
|
|
167
|
-
message
|
|
168
|
-
} = validateData(data);
|
|
169
|
-
const {
|
|
170
|
-
svgChildren,
|
|
171
|
-
htmlChildren,
|
|
172
|
-
legendChildren,
|
|
173
|
-
otherChildren
|
|
174
|
-
} = useChartChildren(children, "PieChart");
|
|
175
|
-
const chartMetadata = useMemo(() => ({
|
|
176
|
-
thickness,
|
|
177
|
-
gapScale,
|
|
178
|
-
cornerScale
|
|
179
|
-
}), [thickness, gapScale, cornerScale]);
|
|
180
|
-
useChartRegistration({
|
|
181
|
-
chartId,
|
|
182
|
-
legendItems,
|
|
183
|
-
chartType: "pie",
|
|
184
|
-
isDataValid: isValid,
|
|
185
|
-
metadata: chartMetadata
|
|
186
|
-
});
|
|
187
|
-
const prefersReducedMotion = usePrefersReducedMotion();
|
|
188
|
-
if (!isValid) {
|
|
189
|
-
return /* @__PURE__ */ _jsx("div", {
|
|
190
|
-
className: clsx("pie-chart", pie_chart_module_default["pie-chart"], className),
|
|
191
|
-
children: /* @__PURE__ */ _jsx("div", {
|
|
192
|
-
className: pie_chart_module_default["error-message"],
|
|
193
|
-
children: message
|
|
194
|
-
})
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
const availableWidth = svgWrapperWidth > 0 ? svgWrapperWidth : 300;
|
|
198
|
-
const availableHeight = svgWrapperHeight > 0 ? svgWrapperHeight : 300;
|
|
199
|
-
const availableSize = Math.min(availableWidth, availableHeight);
|
|
200
|
-
const actualSize = size ? Math.min(size, availableSize) : availableSize;
|
|
201
|
-
const width = actualSize;
|
|
202
|
-
const height = actualSize;
|
|
203
|
-
const radius = Math.min(width, height) / 2;
|
|
204
|
-
const centerX = width / 2;
|
|
205
|
-
const centerY = height / 2;
|
|
206
|
-
const padAngle = gapScale * (2 * Math.PI / data.length);
|
|
207
|
-
const outerRadius = radius - padding;
|
|
208
|
-
const innerRadius = thickness === 0 ? 0 : outerRadius * (1 - thickness);
|
|
209
|
-
const maxCornerRadius = (outerRadius - innerRadius) / 2;
|
|
210
|
-
const cornerRadius = cornerScale ? Math.min(cornerScale * outerRadius, maxCornerRadius) : 0;
|
|
211
|
-
const dataWithIndex = visibleData.map((d) => {
|
|
212
|
-
const originalIndex = data.findIndex((item) => item.label === d.label);
|
|
213
|
-
return {
|
|
214
|
-
...d,
|
|
215
|
-
index: originalIndex >= 0 ? originalIndex : 0
|
|
216
|
-
};
|
|
217
|
-
});
|
|
218
|
-
const accessors = {
|
|
219
|
-
value: (d) => d.value,
|
|
220
|
-
fill: (d) => {
|
|
221
|
-
return getElementStyles({
|
|
222
|
-
data: d,
|
|
223
|
-
index: d.index
|
|
224
|
-
}).color;
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
const legendElement = showLegend && /* @__PURE__ */ _jsx(Legend, {
|
|
228
|
-
orientation: legend.orientation ?? "horizontal",
|
|
229
|
-
position: legendPosition,
|
|
230
|
-
alignment: legend.alignment ?? "center",
|
|
231
|
-
labelStyles: legend.labelStyles,
|
|
232
|
-
itemClassName: legend.itemClassName,
|
|
233
|
-
itemStyles: legend.itemStyles,
|
|
234
|
-
shapeStyles: legend.shapeStyles,
|
|
235
|
-
shape: legend.shape ?? "circle",
|
|
236
|
-
chartId,
|
|
237
|
-
interactive: legendInteractive
|
|
238
|
-
});
|
|
239
|
-
return /* @__PURE__ */ _jsx(SingleChartContext.Provider, {
|
|
240
|
-
value: {
|
|
241
|
-
chartId,
|
|
242
|
-
chartWidth: width,
|
|
243
|
-
chartHeight: height
|
|
244
|
-
},
|
|
245
|
-
children: /* @__PURE__ */ _jsxs(Stack, {
|
|
246
|
-
ref: containerRef,
|
|
247
|
-
direction: "column",
|
|
248
|
-
gap,
|
|
249
|
-
className: clsx(
|
|
250
|
-
"pie-chart",
|
|
251
|
-
pie_chart_module_default["pie-chart"],
|
|
252
|
-
// Fill parent when no explicit dimensions provided
|
|
253
|
-
{
|
|
254
|
-
[pie_chart_module_default["pie-chart--responsive"]]: !propWidth && !propHeight
|
|
255
|
-
},
|
|
256
|
-
className
|
|
257
|
-
),
|
|
258
|
-
style: {
|
|
259
|
-
width: propWidth || void 0,
|
|
260
|
-
height: propHeight || void 0
|
|
261
|
-
},
|
|
262
|
-
children: [legendPosition === "top" && legendElement, renderLegendSlot(legendChildren, "top"), /* @__PURE__ */ _jsx("div", {
|
|
263
|
-
className: pie_chart_module_default["pie-chart__svg-wrapper"],
|
|
264
|
-
ref: svgWrapperRef,
|
|
265
|
-
children: /* @__PURE__ */ _jsxs("svg", {
|
|
266
|
-
viewBox: `0 0 ${width} ${height}`,
|
|
267
|
-
preserveAspectRatio: "xMidYMid meet",
|
|
268
|
-
width,
|
|
269
|
-
height,
|
|
270
|
-
children: [/* @__PURE__ */ _jsx("defs", {
|
|
271
|
-
children: /* @__PURE__ */ _jsx(radial_wipe_animation_default, {
|
|
272
|
-
id: `radial-wipe-${chartId}`,
|
|
273
|
-
radius: outerRadius,
|
|
274
|
-
innerRadius
|
|
275
|
-
})
|
|
276
|
-
}), /* @__PURE__ */ _jsxs(Group, {
|
|
277
|
-
top: centerY,
|
|
278
|
-
left: centerX,
|
|
279
|
-
mask: animation && !prefersReducedMotion ? `url(#radial-wipe-${chartId})` : null,
|
|
280
|
-
children: [allSegmentsHidden ? /* @__PURE__ */ _jsx("text", {
|
|
281
|
-
textAnchor: "middle",
|
|
282
|
-
dy: ".33em",
|
|
283
|
-
fill: providerTheme.gridColor || "#ccc",
|
|
284
|
-
fontSize: "14",
|
|
285
|
-
fontFamily: "-apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,sans-serif",
|
|
286
|
-
children: __("All segments are hidden. Click legend items to show data.", "jetpack-charts")
|
|
287
|
-
}) : /* @__PURE__ */ _jsx(Pie, {
|
|
288
|
-
data: dataWithIndex,
|
|
289
|
-
pieValue: accessors.value,
|
|
290
|
-
outerRadius,
|
|
291
|
-
innerRadius,
|
|
292
|
-
padAngle,
|
|
293
|
-
cornerRadius,
|
|
294
|
-
children: (pie) => {
|
|
295
|
-
return pie.arcs.map((arc, index) => {
|
|
296
|
-
const [centroidX, centroidY] = pie.path.centroid(arc);
|
|
297
|
-
const hasSpaceForLabel = arc.endAngle - arc.startAngle >= 0.25;
|
|
298
|
-
const handleMouseMove = (event) => {
|
|
299
|
-
if (!withTooltips) {
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
if (containerBounds.width === 0 || containerBounds.height === 0) {
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
showTooltip({
|
|
306
|
-
tooltipData: arc.data,
|
|
307
|
-
tooltipLeft: event.clientX - containerBounds.left + tooltipOffsetX,
|
|
308
|
-
tooltipTop: event.clientY - containerBounds.top + tooltipOffsetY
|
|
309
|
-
});
|
|
310
|
-
};
|
|
311
|
-
const pathProps = {
|
|
312
|
-
d: pie.path(arc) || "",
|
|
313
|
-
fill: accessors.fill(arc.data),
|
|
314
|
-
"data-testid": "pie-segment"
|
|
315
|
-
};
|
|
316
|
-
const groupProps = {};
|
|
317
|
-
if (withTooltips) {
|
|
318
|
-
groupProps.onMouseMove = handleMouseMove;
|
|
319
|
-
groupProps.onMouseLeave = onMouseLeave;
|
|
320
|
-
}
|
|
321
|
-
const fontSize = 12;
|
|
322
|
-
const estimatedTextWidth = getStringWidth(arc.data.label, {
|
|
323
|
-
fontSize
|
|
324
|
-
});
|
|
325
|
-
const labelPadding = 6;
|
|
326
|
-
const backgroundWidth = estimatedTextWidth + labelPadding * 2;
|
|
327
|
-
const backgroundHeight = fontSize + labelPadding * 2;
|
|
328
|
-
return /* @__PURE__ */ _jsxs("g", {
|
|
329
|
-
...groupProps,
|
|
330
|
-
children: [/* @__PURE__ */ _jsx("path", {
|
|
331
|
-
...pathProps
|
|
332
|
-
}), showLabels && hasSpaceForLabel && /* @__PURE__ */ _jsxs("g", {
|
|
333
|
-
children: [providerTheme.labelBackgroundColor && /* @__PURE__ */ _jsx("rect", {
|
|
334
|
-
x: centroidX - backgroundWidth / 2,
|
|
335
|
-
y: centroidY - backgroundHeight / 2,
|
|
336
|
-
width: backgroundWidth,
|
|
337
|
-
height: backgroundHeight,
|
|
338
|
-
fill: providerTheme.labelBackgroundColor,
|
|
339
|
-
rx: 4,
|
|
340
|
-
ry: 4,
|
|
341
|
-
pointerEvents: "none"
|
|
342
|
-
}), /* @__PURE__ */ _jsx("text", {
|
|
343
|
-
x: centroidX,
|
|
344
|
-
y: centroidY,
|
|
345
|
-
dy: ".33em",
|
|
346
|
-
fill: providerTheme.labelTextColor || "#333",
|
|
347
|
-
fontSize,
|
|
348
|
-
textAnchor: "middle",
|
|
349
|
-
pointerEvents: "none",
|
|
350
|
-
children: arc.data.label
|
|
351
|
-
})]
|
|
352
|
-
})]
|
|
353
|
-
}, `arc-${index}`);
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
}), !allSegmentsHidden && svgChildren]
|
|
357
|
-
})]
|
|
358
|
-
})
|
|
359
|
-
}), legendPosition === "bottom" && legendElement, renderLegendSlot(legendChildren, "bottom"), withTooltips && tooltipOpen && tooltipData && /* @__PURE__ */ _jsx(TooltipInPortal, {
|
|
360
|
-
top: tooltipTop || 0,
|
|
361
|
-
left: tooltipLeft || 0,
|
|
362
|
-
children: /* @__PURE__ */ _jsx("div", {
|
|
363
|
-
role: "tooltip",
|
|
364
|
-
children: renderTooltip({
|
|
365
|
-
tooltipData
|
|
366
|
-
})
|
|
367
|
-
})
|
|
368
|
-
}), htmlChildren, otherChildren]
|
|
369
|
-
})
|
|
370
|
-
});
|
|
371
|
-
};
|
|
372
|
-
var PieChartWithProvider = (props) => {
|
|
373
|
-
const existingContext = useContext(GlobalChartsContext);
|
|
374
|
-
if (existingContext) {
|
|
375
|
-
return /* @__PURE__ */ _jsx(PieChartInternal, {
|
|
376
|
-
...props
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
|
-
return /* @__PURE__ */ _jsx(GlobalChartsProvider, {
|
|
380
|
-
children: /* @__PURE__ */ _jsx(PieChartInternal, {
|
|
381
|
-
...props
|
|
382
|
-
})
|
|
383
|
-
});
|
|
384
|
-
};
|
|
385
|
-
PieChartWithProvider.displayName = "PieChart";
|
|
386
|
-
var PieChart = attachSubComponents(PieChartWithProvider, {
|
|
387
|
-
Legend,
|
|
388
|
-
SVG: ChartSVG,
|
|
389
|
-
HTML: ChartHTML
|
|
390
|
-
});
|
|
391
|
-
var PieChartResponsive = attachSubComponents(withResponsive(PieChartWithProvider), {
|
|
392
|
-
Legend,
|
|
393
|
-
SVG: ChartSVG,
|
|
394
|
-
HTML: ChartHTML
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
export {
|
|
398
|
-
PieChart,
|
|
399
|
-
PieChartResponsive
|
|
400
|
-
};
|
|
401
|
-
//# sourceMappingURL=chunk-4OXMTKAL.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/charts/pie-chart/pie-chart.tsx","../src/charts/pie-chart/pie-chart.module.scss"],"sourcesContent":["import { Group } from '@visx/group';\nimport { Pie } from '@visx/shape';\nimport { useTooltip, useTooltipInPortal } from '@visx/tooltip';\nimport { __ } from '@wordpress/i18n';\nimport { Stack } from '@wordpress/ui';\nimport clsx from 'clsx';\nimport { useCallback, useContext, useMemo } from 'react';\nimport { Legend, useChartLegendItems } from '../../components/legend';\nimport { BaseTooltip } from '../../components/tooltip';\nimport { useElementSize, useInteractiveLegendData, usePrefersReducedMotion } from '../../hooks';\nimport { GlobalChartsProvider, useChartId, useChartRegistration, useGlobalChartsContext, useGlobalChartsTheme, GlobalChartsContext } from '../../providers';\nimport { attachSubComponents } from '../../utils';\nimport { getStringWidth } from '../../visx/text';\nimport { ChartSVG, ChartHTML, useChartChildren, renderLegendSlot } from '../private/chart-composition';\nimport { RadialWipeAnimation } from '../private/radial-wipe-animation/';\nimport { SingleChartContext } from '../private/single-chart-context';\nimport { withResponsive } from '../private/with-responsive';\nimport styles from './pie-chart.module.scss';\n\n/**\n * Parameters passed to the renderTooltip function for pie charts.\n */\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\n/**\n * Default tooltip renderer for pie charts.\n * Renders a BaseTooltip with the hovered segment's data.\n *\n * @param {PieChartRenderTooltipParams} params - The tooltip parameters containing the hovered data point\n * @return {ReactNode} The rendered tooltip content\n */\nconst renderDefaultPieTooltip = ({\n tooltipData\n}) => {\n return /*#__PURE__*/_jsx(BaseTooltip, {\n data: tooltipData,\n top: 0,\n left: 0,\n renderContainer: false\n });\n};\n\n// Base props type with optional responsive properties\n\n// Composition API types\n\n/**\n * Validates the pie chart data\n * @param data - The data to validate\n * @return Object containing validation result and error message\n */\nconst validateData = data => {\n if (!data.length) {\n return {\n isValid: false,\n message: 'No data available'\n };\n }\n\n // Check for negative values\n const hasNegativeValues = data.some(item => item.percentage < 0 || item.value < 0);\n if (hasNegativeValues) {\n return {\n isValid: false,\n message: 'Invalid data: Negative values are not allowed'\n };\n }\n\n // Validate total percentage\n const totalPercentage = data.reduce((sum, item) => sum + item.percentage, 0);\n if (Math.abs(totalPercentage - 100) > 0.01) {\n // Using small epsilon for floating point comparison\n return {\n isValid: false,\n message: 'Invalid percentage total: Must equal 100'\n };\n }\n return {\n isValid: true,\n message: ''\n };\n};\n\n/**\n * Renders a pie or donut chart using the provided data.\n *\n * @param {PieChartProps} props - Component props\n * @return {JSX.Element} The rendered chart component\n */\nconst PieChartInternal = ({\n data,\n chartId: providedChartId,\n withTooltips = false,\n className,\n showLegend = false,\n legend = {},\n width: propWidth,\n height: propHeight,\n size,\n animation,\n thickness = 1,\n padding = 0,\n gapScale = 0,\n cornerScale = 0,\n showLabels = true,\n legendValueDisplay = 'percentage',\n children = null,\n tooltipOffsetX = 0,\n tooltipOffsetY = -15,\n renderTooltip = renderDefaultPieTooltip,\n gap = 'md'\n}) => {\n const legendInteractive = legend.interactive ?? false;\n const legendPosition = legend.position ?? 'bottom';\n const providerTheme = useGlobalChartsTheme();\n const chartId = useChartId(providedChartId);\n const [svgWrapperRef, svgWrapperWidth, svgWrapperHeight] = useElementSize();\n const {\n tooltipOpen,\n tooltipLeft,\n tooltipTop,\n tooltipData,\n hideTooltip,\n showTooltip\n } = useTooltip();\n\n // Set up portal tooltip for better z-index handling\n // We get containerBounds to cancel out stale offsets in the position calculation\n const {\n containerRef,\n TooltipInPortal,\n containerBounds\n } = useTooltipInPortal({\n detectBounds: true,\n scroll: true,\n debounce: 0\n });\n const onMouseLeave = useCallback(() => {\n if (!withTooltips) {\n return;\n }\n hideTooltip();\n }, [withTooltips, hideTooltip]);\n const {\n getElementStyles,\n isSeriesVisible\n } = useGlobalChartsContext();\n\n // Filter and recalculate data for interactive legends\n const {\n visibleData,\n allSegmentsHidden,\n legendData\n } = useInteractiveLegendData({\n data,\n chartId,\n legendInteractive,\n isSeriesVisible\n });\n\n // Memoize legend options to prevent unnecessary re-calculations\n const legendOptions = useMemo(() => ({\n showValues: true,\n legendValueDisplay\n }), [legendValueDisplay]);\n\n // Create legend items using legendData (has recalculated percentages for visible items)\n const legendItems = useChartLegendItems(legendData, legendOptions);\n const {\n isValid,\n message\n } = validateData(data);\n\n // Process children to extract compound components\n const {\n svgChildren,\n htmlChildren,\n legendChildren,\n otherChildren\n } = useChartChildren(children, 'PieChart');\n\n // Memoize metadata to prevent unnecessary re-registration\n const chartMetadata = useMemo(() => ({\n thickness,\n gapScale,\n cornerScale\n }), [thickness, gapScale, cornerScale]);\n\n // Register chart with context only if data is valid\n useChartRegistration({\n chartId,\n legendItems,\n chartType: 'pie',\n isDataValid: isValid,\n metadata: chartMetadata\n });\n const prefersReducedMotion = usePrefersReducedMotion();\n if (!isValid) {\n return /*#__PURE__*/_jsx(\"div\", {\n className: clsx('pie-chart', styles['pie-chart'], className),\n children: /*#__PURE__*/_jsx(\"div\", {\n className: styles['error-message'],\n children: message\n })\n });\n }\n\n // Calculate the actual pie size:\n // - Measure available space from the svg-wrapper\n // - If size prop provided: use it as max, but shrink if container is smaller\n // - If no size prop: fill available space\n const availableWidth = svgWrapperWidth > 0 ? svgWrapperWidth : 300;\n const availableHeight = svgWrapperHeight > 0 ? svgWrapperHeight : 300;\n const availableSize = Math.min(availableWidth, availableHeight);\n const actualSize = size ? Math.min(size, availableSize) : availableSize;\n const width = actualSize;\n const height = actualSize;\n\n // Calculate radius based on width/height\n const radius = Math.min(width, height) / 2;\n\n // Center the chart in the available space\n const centerX = width / 2;\n const centerY = height / 2;\n\n // Calculate the angle between each (use original data length for consistent spacing)\n const padAngle = gapScale * (2 * Math.PI / data.length);\n const outerRadius = radius - padding;\n const innerRadius = thickness === 0 ? 0 : outerRadius * (1 - thickness);\n const maxCornerRadius = (outerRadius - innerRadius) / 2;\n const cornerRadius = cornerScale ? Math.min(cornerScale * outerRadius, maxCornerRadius) : 0;\n\n // Map the data to include index for color assignment\n // When interactive, we need to find the original index to maintain consistent colors\n const dataWithIndex = visibleData.map(d => {\n const originalIndex = data.findIndex(item => item.label === d.label);\n return {\n ...d,\n index: originalIndex >= 0 ? originalIndex : 0\n };\n });\n const accessors = {\n value: d => d.value,\n fill: d => {\n return getElementStyles({\n data: d,\n index: d.index\n }).color;\n }\n };\n const legendElement = showLegend && /*#__PURE__*/_jsx(Legend, {\n orientation: legend.orientation ?? 'horizontal',\n position: legendPosition,\n alignment: legend.alignment ?? 'center',\n labelStyles: legend.labelStyles,\n itemClassName: legend.itemClassName,\n itemStyles: legend.itemStyles,\n shapeStyles: legend.shapeStyles,\n shape: legend.shape ?? 'circle',\n chartId: chartId,\n interactive: legendInteractive\n });\n return /*#__PURE__*/_jsx(SingleChartContext.Provider, {\n value: {\n chartId,\n chartWidth: width,\n chartHeight: height\n },\n children: /*#__PURE__*/_jsxs(Stack, {\n ref: containerRef,\n direction: \"column\",\n gap: gap,\n className: clsx('pie-chart', styles['pie-chart'],\n // Fill parent when no explicit dimensions provided\n {\n [styles['pie-chart--responsive']]: !propWidth && !propHeight\n }, className),\n style: {\n width: propWidth || undefined,\n height: propHeight || undefined\n },\n children: [legendPosition === 'top' && legendElement, renderLegendSlot(legendChildren, 'top'), /*#__PURE__*/_jsx(\"div\", {\n className: styles['pie-chart__svg-wrapper'],\n ref: svgWrapperRef,\n children: /*#__PURE__*/_jsxs(\"svg\", {\n viewBox: `0 0 ${width} ${height}`,\n preserveAspectRatio: \"xMidYMid meet\",\n width: width,\n height: height,\n children: [/*#__PURE__*/_jsx(\"defs\", {\n children: /*#__PURE__*/_jsx(RadialWipeAnimation, {\n id: `radial-wipe-${chartId}`,\n radius: outerRadius,\n innerRadius: innerRadius\n })\n }), /*#__PURE__*/_jsxs(Group, {\n top: centerY,\n left: centerX,\n mask: animation && !prefersReducedMotion ? `url(#radial-wipe-${chartId})` : null,\n children: [allSegmentsHidden ? /*#__PURE__*/_jsx(\"text\", {\n textAnchor: \"middle\",\n dy: \".33em\",\n fill: providerTheme.gridColor || '#ccc',\n fontSize: \"14\",\n fontFamily: \"-apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,sans-serif\",\n children: __('All segments are hidden. Click legend items to show data.', 'jetpack-charts')\n }) : /*#__PURE__*/_jsx(Pie, {\n data: dataWithIndex,\n pieValue: accessors.value,\n outerRadius: outerRadius,\n innerRadius: innerRadius,\n padAngle: padAngle,\n cornerRadius: cornerRadius,\n children: pie => {\n return pie.arcs.map((arc, index) => {\n const [centroidX, centroidY] = pie.path.centroid(arc);\n const hasSpaceForLabel = arc.endAngle - arc.startAngle >= 0.25;\n const handleMouseMove = event => {\n if (!withTooltips) {\n return;\n }\n\n // Don't show tooltip until container bounds are measured\n if (containerBounds.width === 0 || containerBounds.height === 0) {\n return;\n }\n\n // Use clientX/Y and subtract containerBounds to cancel out any stale offset.\n // TooltipInPortal calculates: tooltipLeft + containerBounds.left + scrollX\n // By passing (clientX - containerBounds.left), we get:\n // (clientX - containerBounds.left) + containerBounds.left + scrollX = clientX + scrollX\n // This gives correct page coordinates regardless of stale bounds.\n showTooltip({\n tooltipData: arc.data,\n tooltipLeft: event.clientX - containerBounds.left + tooltipOffsetX,\n tooltipTop: event.clientY - containerBounds.top + tooltipOffsetY\n });\n };\n const pathProps = {\n d: pie.path(arc) || '',\n fill: accessors.fill(arc.data),\n 'data-testid': 'pie-segment'\n };\n const groupProps = {};\n if (withTooltips) {\n groupProps.onMouseMove = handleMouseMove;\n groupProps.onMouseLeave = onMouseLeave;\n }\n\n // Estimate text width more accurately for background sizing\n const fontSize = 12;\n const estimatedTextWidth = getStringWidth(arc.data.label, {\n fontSize\n });\n const labelPadding = 6;\n const backgroundWidth = estimatedTextWidth + labelPadding * 2;\n const backgroundHeight = fontSize + labelPadding * 2;\n return /*#__PURE__*/_jsxs(\"g\", {\n ...groupProps,\n children: [/*#__PURE__*/_jsx(\"path\", {\n ...pathProps\n }), showLabels && hasSpaceForLabel && /*#__PURE__*/_jsxs(\"g\", {\n children: [providerTheme.labelBackgroundColor && /*#__PURE__*/_jsx(\"rect\", {\n x: centroidX - backgroundWidth / 2,\n y: centroidY - backgroundHeight / 2,\n width: backgroundWidth,\n height: backgroundHeight,\n fill: providerTheme.labelBackgroundColor,\n rx: 4,\n ry: 4,\n pointerEvents: \"none\"\n }), /*#__PURE__*/_jsx(\"text\", {\n x: centroidX,\n y: centroidY,\n dy: \".33em\",\n fill: providerTheme.labelTextColor || '#333',\n fontSize: fontSize,\n textAnchor: \"middle\",\n pointerEvents: \"none\",\n children: arc.data.label\n })]\n })]\n }, `arc-${index}`);\n });\n }\n }), !allSegmentsHidden && svgChildren]\n })]\n })\n }), legendPosition === 'bottom' && legendElement, renderLegendSlot(legendChildren, 'bottom'), withTooltips && tooltipOpen && tooltipData && /*#__PURE__*/_jsx(TooltipInPortal, {\n top: tooltipTop || 0,\n left: tooltipLeft || 0,\n children: /*#__PURE__*/_jsx(\"div\", {\n role: \"tooltip\",\n children: renderTooltip({\n tooltipData\n })\n })\n }), htmlChildren, otherChildren]\n })\n });\n};\nconst PieChartWithProvider = props => {\n const existingContext = useContext(GlobalChartsContext);\n\n // If we're already in a GlobalChartsProvider context, don't create a new one\n if (existingContext) {\n return /*#__PURE__*/_jsx(PieChartInternal, {\n ...props\n });\n }\n\n // Otherwise, create our own GlobalChartsProvider\n return /*#__PURE__*/_jsx(GlobalChartsProvider, {\n children: /*#__PURE__*/_jsx(PieChartInternal, {\n ...props\n })\n });\n};\nPieChartWithProvider.displayName = 'PieChart';\n\n// Create PieChart with composition API\nconst PieChart = attachSubComponents(PieChartWithProvider, {\n Legend: Legend,\n SVG: ChartSVG,\n HTML: ChartHTML\n});\n\n// Create responsive PieChart with composition API\nconst PieChartResponsive = attachSubComponents(withResponsive(PieChartWithProvider), {\n Legend: Legend,\n SVG: ChartSVG,\n HTML: ChartHTML\n});\nexport { PieChartResponsive as default, PieChart as PieChartUnresponsive };","import 'css-chunk:src/charts/pie-chart/pie-chart.module.scss';export default {\n \"pie-chart\": \"a8ccharts-C-n-Gu\",\n \"pie-chart--responsive\": \"a8ccharts-IQVR6j\",\n \"pie-chart__svg-wrapper\": \"a8ccharts-iQ1Rki\"\n};"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AACtB,SAAS,WAAW;AACpB,SAAS,YAAY,0BAA0B;AAC/C,SAAS,UAAU;AAEnB,OAAO,UAAU;AACjB,SAAS,aAAa,YAAY,eAAe;;;ACNa,IAAO,2BAAQ;AAAA,EAC3E,aAAa;AAAA,EACb,yBAAyB;AAAA,EACzB,0BAA0B;AAC5B;;;ADkBA,SAAS,OAAO,MAAM,QAAQ,aAAa;AAQ3C,IAAM,0BAA0B,CAAC;AAAA,EAC/B;AACF,MAAM;AACJ,SAAoB,qBAAK,aAAa;AAAA,IACpC,MAAM;AAAA,IACN,KAAK;AAAA,IACL,MAAM;AAAA,IACN,iBAAiB;AAAA,EACnB,CAAC;AACH;AAWA,IAAM,eAAe,UAAQ;AAC3B,MAAI,CAAC,KAAK,QAAQ;AAChB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,SAAS;AAAA,IACX;AAAA,EACF;AAGA,QAAM,oBAAoB,KAA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names":[]}
|
package/dist/chunk-ASLARV7L.cjs
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/charts/private/with-responsive/with-responsive.tsx
|
|
2
|
-
var _responsive = require('@visx/responsive');
|
|
3
|
-
|
|
4
|
-
// src/charts/private/with-responsive/with-responsive.module.scss
|
|
5
|
-
var with_responsive_module_default = {
|
|
6
|
-
"container": "a8ccharts-GSKfBD"
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
// src/charts/private/with-responsive/with-responsive.tsx
|
|
10
|
-
var _jsxruntime = require('react/jsx-runtime');
|
|
11
|
-
var useResponsiveDimensions = ({
|
|
12
|
-
resizeDebounceTime = 300,
|
|
13
|
-
maxWidth = 1200,
|
|
14
|
-
aspectRatio
|
|
15
|
-
}) => {
|
|
16
|
-
const {
|
|
17
|
-
parentRef,
|
|
18
|
-
width: parentWidth,
|
|
19
|
-
height: parentHeight
|
|
20
|
-
} = _responsive.useParentSize.call(void 0, {
|
|
21
|
-
debounceTime: resizeDebounceTime,
|
|
22
|
-
enableDebounceLeadingCall: true
|
|
23
|
-
});
|
|
24
|
-
const containerWidth = parentWidth > 0 ? Math.min(parentWidth, maxWidth) : 0;
|
|
25
|
-
const containerHeight = aspectRatio !== void 0 ? containerWidth * aspectRatio : parentHeight;
|
|
26
|
-
return {
|
|
27
|
-
parentRef,
|
|
28
|
-
width: containerWidth,
|
|
29
|
-
height: containerHeight,
|
|
30
|
-
/**
|
|
31
|
-
* Whether an aspectRatio was provided. Used to determine container
|
|
32
|
-
* height styling: 'auto' when true (height derived from width),
|
|
33
|
-
* '100%' when false (fill parent container).
|
|
34
|
-
*/
|
|
35
|
-
hasAspectRatio: aspectRatio !== void 0
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
function withResponsive(WrappedComponent) {
|
|
39
|
-
return function ResponsiveChart({
|
|
40
|
-
resizeDebounceTime = 300,
|
|
41
|
-
maxWidth = 1200,
|
|
42
|
-
aspectRatio,
|
|
43
|
-
size,
|
|
44
|
-
width,
|
|
45
|
-
height,
|
|
46
|
-
...chartProps
|
|
47
|
-
}) {
|
|
48
|
-
const {
|
|
49
|
-
parentRef,
|
|
50
|
-
width: measuredWidth,
|
|
51
|
-
height: measuredHeight,
|
|
52
|
-
hasAspectRatio
|
|
53
|
-
} = useResponsiveDimensions({
|
|
54
|
-
resizeDebounceTime,
|
|
55
|
-
maxWidth,
|
|
56
|
-
aspectRatio
|
|
57
|
-
});
|
|
58
|
-
const effectiveWidth = measuredWidth || width || 0;
|
|
59
|
-
const effectiveHeight = measuredHeight || height || 0;
|
|
60
|
-
const defaultHeight = hasAspectRatio ? "auto" : "100%";
|
|
61
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
62
|
-
ref: parentRef,
|
|
63
|
-
className: with_responsive_module_default.container,
|
|
64
|
-
style: {
|
|
65
|
-
width: _nullishCoalesce(width, () => ( "100%")),
|
|
66
|
-
height: _nullishCoalesce(height, () => ( defaultHeight))
|
|
67
|
-
},
|
|
68
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WrappedComponent, {
|
|
69
|
-
width: effectiveWidth,
|
|
70
|
-
height: effectiveHeight,
|
|
71
|
-
size,
|
|
72
|
-
...chartProps
|
|
73
|
-
})
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
exports.withResponsive = withResponsive;
|
|
81
|
-
//# sourceMappingURL=chunk-ASLARV7L.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/jetpack/jetpack/projects/js-packages/charts/dist/chunk-ASLARV7L.cjs","../src/charts/private/with-responsive/with-responsive.tsx","../src/charts/private/with-responsive/with-responsive.module.scss"],"names":[],"mappings":"AAAA;ACAA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,CAAwB;AAAA,MAC1B,kBAAA;AAAA,MACA,QAAA;AAAA,MACA;AAAA,IACF,CAAC,CAAA;AAKD,IAAA,MAAM,eAAA,EAAiB,cAAA,GAAiB,MAAA,GAAS,CAAA;AACjD,IAAA,MAAM,gBAAA,EAAkB,eAAA,GAAkB,OAAA,GAAU,CAAA;AACpD,IAAA,MAAM,cAAA,EAAgB,eAAA,EAAiB,OAAA,EAAS,MAAA;AAChD,IAAA,uBAAoB,6BAAA,KAAK,EAAO;AAAA,MAC9B,GAAA,EAAK,SAAA;AAAA,MACL,SAAA,EAAW,8BAAA,CAAO,SAAA;AAAA,MAClB,KAAA,EAAO;AAAA,QACL,KAAA,mBAAO,KAAA,UAAS,QAAA;AAAA,QAChB,MAAA,mBAAQ,MAAA,UAAU;AAAA,MACpB,CAAA;AAAA,MACA,QAAA,kBAAuB,6BAAA,gBAAK,EAAkB;AAAA,QAC5C,KAAA,EAAO,cAAA;AAAA,QACP,MAAA,EAAQ,eAAA;AAAA,QACR,IAAA;AAAA,QACA,GAAG;AAAA,MACL,CAAC;AAAA,IACH,CAAC,CAAA;AAAA,EACH,CAAA;AACF;ADNA;AACA;AACE;AACF,wCAAC","file":"/home/runner/work/jetpack/jetpack/projects/js-packages/charts/dist/chunk-ASLARV7L.cjs","sourcesContent":[null,"import { useParentSize } from '@visx/responsive';\nimport styles from './with-responsive.module.scss';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst useResponsiveDimensions = ({\n resizeDebounceTime = 300,\n maxWidth = 1200,\n aspectRatio\n}) => {\n const {\n parentRef,\n width: parentWidth,\n height: parentHeight\n } = useParentSize({\n debounceTime: resizeDebounceTime,\n enableDebounceLeadingCall: true\n });\n const containerWidth = parentWidth > 0 ? Math.min(parentWidth, maxWidth) : 0;\n const containerHeight = aspectRatio !== undefined ? containerWidth * aspectRatio : parentHeight;\n return {\n parentRef,\n width: containerWidth,\n height: containerHeight,\n /**\n * Whether an aspectRatio was provided. Used to determine container\n * height styling: 'auto' when true (height derived from width),\n * '100%' when false (fill parent container).\n */\n hasAspectRatio: aspectRatio !== undefined\n };\n};\n\n/**\n * A higher-order component that provides responsive dimensions\n * to the wrapped chart component using useParentSize from `@visx/responsive`.\n *\n * @param WrappedComponent - The chart component to be wrapped.\n * @return A functional component that renders the wrapped component with responsive dimensions.\n */\nexport function withResponsive(\n// 'options' is excluded so that each chart can define its own options type\nWrappedComponent) {\n return function ResponsiveChart({\n resizeDebounceTime = 300,\n maxWidth = 1200,\n aspectRatio,\n size,\n width,\n height,\n ...chartProps\n }) {\n const {\n parentRef,\n width: measuredWidth,\n height: measuredHeight,\n hasAspectRatio\n } = useResponsiveDimensions({\n resizeDebounceTime,\n maxWidth,\n aspectRatio\n });\n\n // Use measured dimensions, but fall back to explicit width/height props if measurement returns 0\n // (e.g., during initial render or in test environments without DOM measurement).\n // Do not use size here — size controls chart element dimensions (e.g. pie diameter), not container dimensions.\n const effectiveWidth = measuredWidth || width || 0;\n const effectiveHeight = measuredHeight || height || 0;\n const defaultHeight = hasAspectRatio ? 'auto' : '100%';\n return /*#__PURE__*/_jsx(\"div\", {\n ref: parentRef,\n className: styles.container,\n style: {\n width: width ?? '100%',\n height: height ?? defaultHeight\n },\n children: /*#__PURE__*/_jsx(WrappedComponent, {\n width: effectiveWidth,\n height: effectiveHeight,\n size: size,\n ...chartProps\n })\n });\n };\n}","import 'css-chunk:src/charts/private/with-responsive/with-responsive.module.scss';export default {\n \"container\": \"a8ccharts-GSKfBD\"\n};"]}
|