@automattic/charts 0.38.2 → 0.40.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 +21 -0
- package/dist/{base-tooltip-Dlq8KmQA.d.cts → base-tooltip-DOq93wjU.d.cts} +7 -1
- package/dist/{base-tooltip-Dlq8KmQA.d.ts → base-tooltip-DOq93wjU.d.ts} +7 -1
- package/dist/{chunk-XLKUVSWX.js → chunk-2YVSCZ6E.js} +45 -25
- package/dist/chunk-2YVSCZ6E.js.map +1 -0
- package/dist/{chunk-64WB3TV2.js → chunk-663ETEC4.js} +8 -3
- package/dist/chunk-663ETEC4.js.map +1 -0
- package/dist/{chunk-EOYI6JHT.cjs → chunk-66JB3JZA.cjs} +40 -39
- package/dist/chunk-66JB3JZA.cjs.map +1 -0
- package/dist/{chunk-H43FBWWZ.cjs → chunk-6GO5PFYL.cjs} +9 -3
- package/dist/chunk-6GO5PFYL.cjs.map +1 -0
- package/dist/{chunk-JGNNQIBW.cjs → chunk-6UE6HNKC.cjs} +58 -42
- package/dist/chunk-6UE6HNKC.cjs.map +1 -0
- package/dist/{chunk-M4IPOSJU.cjs → chunk-DFMAP23F.cjs} +25 -23
- package/dist/chunk-DFMAP23F.cjs.map +1 -0
- package/dist/{chunk-TOFS2PL4.js → chunk-H4TXX4J4.js} +109 -39
- package/dist/chunk-H4TXX4J4.js.map +1 -0
- package/dist/{chunk-CDC6J372.js → chunk-HE2EODAW.js} +53 -37
- package/dist/chunk-HE2EODAW.js.map +1 -0
- package/dist/{chunk-3WXEHYPV.js → chunk-KACVKFMH.js} +153 -13
- package/dist/chunk-KACVKFMH.js.map +1 -0
- package/dist/{chunk-SEPMBOVD.cjs → chunk-NRVZS2IC.cjs} +13 -8
- package/dist/chunk-NRVZS2IC.cjs.map +1 -0
- package/dist/{chunk-GXTFSTZS.js → chunk-PIL7US3S.js} +6 -4
- package/dist/chunk-PIL7US3S.js.map +1 -0
- package/dist/{chunk-UNF3E7UO.js → chunk-QCZ2UEDG.js} +28 -27
- package/dist/chunk-QCZ2UEDG.js.map +1 -0
- package/dist/{chunk-M4OSG2ES.cjs → chunk-RTUQVBUJ.cjs} +153 -13
- package/dist/chunk-RTUQVBUJ.cjs.map +1 -0
- package/dist/{chunk-ALWJBUKO.cjs → chunk-SUHGE6Y4.cjs} +64 -64
- package/dist/{chunk-ALWJBUKO.cjs.map → chunk-SUHGE6Y4.cjs.map} +1 -1
- package/dist/{chunk-S2IAM3XA.cjs → chunk-TCBONS7E.cjs} +6 -6
- package/dist/{chunk-S2IAM3XA.cjs.map → chunk-TCBONS7E.cjs.map} +1 -1
- package/dist/{chunk-CCSDLJ4R.cjs → chunk-TCYMIJBC.cjs} +58 -38
- package/dist/chunk-TCYMIJBC.cjs.map +1 -0
- package/dist/{chunk-VIFSKMHB.cjs → chunk-UPN4B6M6.cjs} +144 -74
- package/dist/chunk-UPN4B6M6.cjs.map +1 -0
- package/dist/{chunk-6KOC7ZWU.js → chunk-W5KOH3TV.js} +9 -3
- package/dist/chunk-W5KOH3TV.js.map +1 -0
- package/dist/{chunk-43QGEIRW.js → chunk-XNQFJOCX.js} +3 -3
- package/dist/{chunk-52PWNTC3.js → chunk-Z7YENR5L.js} +47 -47
- package/dist/{chunk-52PWNTC3.js.map → chunk-Z7YENR5L.js.map} +1 -1
- package/dist/components/bar-chart/index.cjs +5 -5
- package/dist/components/bar-chart/index.d.cts +3 -3
- package/dist/components/bar-chart/index.d.ts +3 -3
- package/dist/components/bar-chart/index.js +4 -4
- package/dist/components/bar-list-chart/index.cjs +6 -6
- package/dist/components/bar-list-chart/index.d.cts +3 -3
- package/dist/components/bar-list-chart/index.d.ts +3 -3
- package/dist/components/bar-list-chart/index.js +5 -5
- package/dist/components/conversion-funnel-chart/index.cjs +3 -3
- package/dist/components/conversion-funnel-chart/index.cjs.map +1 -1
- package/dist/components/conversion-funnel-chart/index.css +0 -6
- package/dist/components/conversion-funnel-chart/index.css.map +1 -1
- package/dist/components/conversion-funnel-chart/index.d.cts +15 -17
- package/dist/components/conversion-funnel-chart/index.d.ts +15 -17
- package/dist/components/conversion-funnel-chart/index.js +4 -4
- package/dist/components/leaderboard-chart/index.cjs +4 -4
- package/dist/components/leaderboard-chart/index.d.cts +3 -3
- package/dist/components/leaderboard-chart/index.d.ts +3 -3
- package/dist/components/leaderboard-chart/index.js +3 -3
- package/dist/components/legend/index.cjs +3 -3
- package/dist/components/legend/index.d.cts +4 -4
- package/dist/components/legend/index.d.ts +4 -4
- package/dist/components/legend/index.js +2 -2
- package/dist/components/line-chart/index.cjs +5 -5
- package/dist/components/line-chart/index.d.cts +7 -5
- package/dist/components/line-chart/index.d.ts +7 -5
- package/dist/components/line-chart/index.js +4 -4
- package/dist/components/pie-chart/index.cjs +5 -5
- package/dist/components/pie-chart/index.d.cts +12 -4
- package/dist/components/pie-chart/index.d.ts +12 -4
- package/dist/components/pie-chart/index.js +4 -4
- package/dist/components/pie-semi-circle-chart/index.cjs +5 -5
- package/dist/components/pie-semi-circle-chart/index.d.cts +12 -4
- package/dist/components/pie-semi-circle-chart/index.d.ts +12 -4
- package/dist/components/pie-semi-circle-chart/index.js +4 -4
- package/dist/components/tooltip/index.cjs +2 -2
- package/dist/components/tooltip/index.d.cts +2 -2
- package/dist/components/tooltip/index.d.ts +2 -2
- package/dist/components/tooltip/index.js +1 -1
- package/dist/hooks/index.cjs +2 -2
- package/dist/hooks/index.d.cts +10 -2
- package/dist/hooks/index.d.ts +10 -2
- package/dist/hooks/index.js +1 -1
- package/dist/index.cjs +11 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +0 -6
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +12 -12
- package/dist/{leaderboard-chart-DLN3L7-R.d.cts → leaderboard-chart-BZ-QCfWH.d.cts} +2 -2
- package/dist/{leaderboard-chart-C9liwX4T.d.ts → leaderboard-chart-CLoNqZLC.d.ts} +2 -2
- package/dist/{legend-CP4jfCL3.d.cts → legend-C5kRXo9G.d.cts} +1 -1
- package/dist/{legend-D_hcatNS.d.ts → legend-C98mlA3T.d.ts} +1 -1
- package/dist/providers/index.cjs +2 -2
- package/dist/providers/index.d.cts +3 -3
- package/dist/providers/index.d.ts +3 -3
- package/dist/providers/index.js +1 -1
- package/dist/{themes-Cs55crdB.d.ts → themes--5gPcnIN.d.ts} +2 -2
- package/dist/{themes-BQl0lAdj.d.cts → themes-BWeLXxeV.d.cts} +2 -2
- package/dist/{types-tkjBLYdd.d.cts → types-B1gVmMiG.d.cts} +1 -1
- package/dist/{types-athdF3-8.d.cts → types-BW-sJNCQ.d.cts} +5 -0
- package/dist/{types-athdF3-8.d.ts → types-BW-sJNCQ.d.ts} +5 -0
- package/dist/{types-C0J1pP_c.d.ts → types-BekKo3_f.d.ts} +1 -1
- package/dist/{types-oNXkzU5p.d.cts → types-cMouhu7d.d.cts} +12 -1
- package/dist/{types-oNXkzU5p.d.ts → types-cMouhu7d.d.ts} +12 -1
- package/package.json +7 -7
- package/src/components/bar-chart/bar-chart.tsx +2 -0
- package/src/components/conversion-funnel-chart/conversion-funnel-chart.module.scss +0 -8
- package/src/components/conversion-funnel-chart/conversion-funnel-chart.tsx +80 -122
- package/src/components/conversion-funnel-chart/index.ts +1 -1
- package/src/components/conversion-funnel-chart/test/conversion-funnel-chart.test.tsx +4 -4
- package/src/components/conversion-funnel-chart/types.ts +79 -0
- package/src/components/legend/private/base-legend.tsx +6 -1
- package/src/components/legend/test/legend.test.tsx +14 -0
- package/src/components/legend/types.ts +5 -0
- package/src/components/line-chart/index.ts +1 -1
- package/src/components/line-chart/line-chart.tsx +86 -59
- package/src/components/line-chart/private/index.ts +1 -0
- package/src/components/line-chart/private/line-chart-glyph.tsx +47 -0
- package/src/components/line-chart/test/line-chart.test.tsx +381 -0
- package/src/components/line-chart/types.ts +23 -2
- package/src/components/pie-chart/pie-chart.tsx +64 -20
- package/src/components/pie-chart/test/pie-chart.test.tsx +112 -1
- package/src/components/pie-semi-circle-chart/pie-semi-circle-chart.tsx +43 -22
- package/src/components/private/default-glyph/default-glyph.tsx +4 -5
- package/src/components/tooltip/base-tooltip.tsx +16 -2
- package/src/hooks/test/use-chart-mouse-handler.test.tsx +2 -4
- package/src/hooks/use-chart-mouse-handler.ts +13 -4
- package/src/providers/chart-context/global-charts-provider.tsx +38 -8
- package/src/providers/chart-context/private/get-chart-color.ts +209 -0
- package/src/providers/chart-context/test/chart-context.test.tsx +184 -5
- package/src/providers/chart-context/themes.ts +3 -3
- package/src/types.ts +18 -1
- package/src/utils/color-utils.ts +84 -6
- package/src/utils/index.ts +1 -1
- package/src/utils/test/color-utils.test.ts +371 -1
- package/dist/chunk-3WXEHYPV.js.map +0 -1
- package/dist/chunk-64WB3TV2.js.map +0 -1
- package/dist/chunk-6KOC7ZWU.js.map +0 -1
- package/dist/chunk-CCSDLJ4R.cjs.map +0 -1
- package/dist/chunk-CDC6J372.js.map +0 -1
- package/dist/chunk-EOYI6JHT.cjs.map +0 -1
- package/dist/chunk-GXTFSTZS.js.map +0 -1
- package/dist/chunk-H43FBWWZ.cjs.map +0 -1
- package/dist/chunk-JGNNQIBW.cjs.map +0 -1
- package/dist/chunk-M4IPOSJU.cjs.map +0 -1
- package/dist/chunk-M4OSG2ES.cjs.map +0 -1
- package/dist/chunk-SEPMBOVD.cjs.map +0 -1
- package/dist/chunk-TOFS2PL4.js.map +0 -1
- package/dist/chunk-UNF3E7UO.js.map +0 -1
- package/dist/chunk-VIFSKMHB.cjs.map +0 -1
- package/dist/chunk-XLKUVSWX.js.map +0 -1
- /package/dist/{chunk-43QGEIRW.js.map → chunk-XNQFJOCX.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.40.0] - 2025-10-06
|
|
9
|
+
### Added
|
|
10
|
+
- Add `legendItemClassName` prop for custom legend item styling. [#45286]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- Update package dependencies. [#45334]
|
|
14
|
+
- Update package dependencies. [#45335]
|
|
15
|
+
|
|
16
|
+
## [0.39.0] - 2025-09-29
|
|
17
|
+
### Added
|
|
18
|
+
- Generate extra colors from theme colors if needed. [#45276]
|
|
19
|
+
- Global Charts context: Add documentation. [#45313]
|
|
20
|
+
- Guess a better x-axis ticks value in line charts. [#45259]
|
|
21
|
+
- Line Chart: Add support for annotated line section. [#45284]
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
- Improve tooltip positioning in pie charts. [#45237]
|
|
25
|
+
- Conversion Funnel chart: Use global charts context theme for consistency. [#45264]
|
|
26
|
+
|
|
8
27
|
## [0.38.2] - 2025-09-22
|
|
9
28
|
### Changed
|
|
10
29
|
- Update dependencies. [#43811]
|
|
@@ -475,6 +494,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
475
494
|
- Fixed lints following ESLint rule changes for TS [#40584]
|
|
476
495
|
- Fixing a bug in Chart storybook data. [#40640]
|
|
477
496
|
|
|
497
|
+
[0.40.0]: https://github.com/Automattic/charts/compare/v0.39.0...v0.40.0
|
|
498
|
+
[0.39.0]: https://github.com/Automattic/charts/compare/v0.38.2...v0.39.0
|
|
478
499
|
[0.38.2]: https://github.com/Automattic/charts/compare/v0.38.1...v0.38.2
|
|
479
500
|
[0.38.1]: https://github.com/Automattic/charts/compare/v0.38.0...v0.38.1
|
|
480
501
|
[0.38.0]: https://github.com/Automattic/charts/compare/v0.37.0...v0.38.0
|
|
@@ -15,6 +15,12 @@ type TooltipCommonProps = {
|
|
|
15
15
|
left: number;
|
|
16
16
|
style?: CSSProperties;
|
|
17
17
|
className?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Whether to render the tooltip container div. When false, only renders the content.
|
|
20
|
+
* Useful when the tooltip is rendered inside a portal or custom container.
|
|
21
|
+
* @default true
|
|
22
|
+
*/
|
|
23
|
+
renderContainer?: boolean;
|
|
18
24
|
};
|
|
19
25
|
type DefaultDataTooltip = {
|
|
20
26
|
data: TooltipData;
|
|
@@ -27,6 +33,6 @@ type CustomTooltip = {
|
|
|
27
33
|
component?: never;
|
|
28
34
|
};
|
|
29
35
|
type BaseTooltipProps = TooltipCommonProps & (DefaultDataTooltip | CustomTooltip);
|
|
30
|
-
declare const BaseTooltip: ({ data, top, left, component: Component, children, className, }: BaseTooltipProps) => react_jsx_runtime.JSX.Element;
|
|
36
|
+
declare const BaseTooltip: ({ data, top, left, component: Component, children, className, style, renderContainer, }: BaseTooltipProps) => string | number | true | Iterable<ReactNode> | react_jsx_runtime.JSX.Element;
|
|
31
37
|
|
|
32
38
|
export { BaseTooltip as B, type TooltipData as T, type BaseTooltipProps as a };
|
|
@@ -15,6 +15,12 @@ type TooltipCommonProps = {
|
|
|
15
15
|
left: number;
|
|
16
16
|
style?: CSSProperties;
|
|
17
17
|
className?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Whether to render the tooltip container div. When false, only renders the content.
|
|
20
|
+
* Useful when the tooltip is rendered inside a portal or custom container.
|
|
21
|
+
* @default true
|
|
22
|
+
*/
|
|
23
|
+
renderContainer?: boolean;
|
|
18
24
|
};
|
|
19
25
|
type DefaultDataTooltip = {
|
|
20
26
|
data: TooltipData;
|
|
@@ -27,6 +33,6 @@ type CustomTooltip = {
|
|
|
27
33
|
component?: never;
|
|
28
34
|
};
|
|
29
35
|
type BaseTooltipProps = TooltipCommonProps & (DefaultDataTooltip | CustomTooltip);
|
|
30
|
-
declare const BaseTooltip: ({ data, top, left, component: Component, children, className, }: BaseTooltipProps) => react_jsx_runtime.JSX.Element;
|
|
36
|
+
declare const BaseTooltip: ({ data, top, left, component: Component, children, className, style, renderContainer, }: BaseTooltipProps) => string | number | true | Iterable<ReactNode> | react_jsx_runtime.JSX.Element;
|
|
31
37
|
|
|
32
38
|
export { BaseTooltip as B, type TooltipData as T, type BaseTooltipProps as a };
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-NFRB2POF.js";
|
|
4
4
|
import {
|
|
5
5
|
BaseTooltip
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-W5KOH3TV.js";
|
|
7
7
|
import {
|
|
8
8
|
ChartHTML,
|
|
9
9
|
ChartSVG,
|
|
@@ -16,24 +16,25 @@ import {
|
|
|
16
16
|
Legend,
|
|
17
17
|
SingleChartContext,
|
|
18
18
|
useChartLegendItems
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-663ETEC4.js";
|
|
20
20
|
import {
|
|
21
21
|
GlobalChartsContext,
|
|
22
22
|
GlobalChartsProvider,
|
|
23
23
|
attachSubComponents,
|
|
24
24
|
useChartId,
|
|
25
|
-
useChartMouseHandler,
|
|
26
25
|
useChartRegistration,
|
|
27
26
|
useElementHeight,
|
|
28
27
|
useGlobalChartsContext,
|
|
29
28
|
useGlobalChartsTheme
|
|
30
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-KACVKFMH.js";
|
|
31
30
|
|
|
32
31
|
// src/components/pie-chart/pie-chart.tsx
|
|
32
|
+
import { localPoint } from "@visx/event";
|
|
33
33
|
import { Group } from "@visx/group";
|
|
34
34
|
import { Pie } from "@visx/shape";
|
|
35
|
+
import { useTooltip, useTooltipInPortal } from "@visx/tooltip";
|
|
35
36
|
import clsx from "clsx";
|
|
36
|
-
import { useContext, useMemo } from "react";
|
|
37
|
+
import { useCallback, useContext, useMemo } from "react";
|
|
37
38
|
|
|
38
39
|
// src/components/pie-chart/pie-chart.module.scss
|
|
39
40
|
var pie_chart_module_default = {
|
|
@@ -67,6 +68,7 @@ var PieChartInternal = ({
|
|
|
67
68
|
legendAlignment = "center",
|
|
68
69
|
legendMaxWidth,
|
|
69
70
|
legendTextOverflow = "wrap",
|
|
71
|
+
legendItemClassName,
|
|
70
72
|
legendShape = "circle",
|
|
71
73
|
size,
|
|
72
74
|
thickness = 1,
|
|
@@ -75,14 +77,25 @@ var PieChartInternal = ({
|
|
|
75
77
|
cornerScale = 0,
|
|
76
78
|
showLabels = true,
|
|
77
79
|
legendValueDisplay = "percentage",
|
|
78
|
-
children = null
|
|
80
|
+
children = null,
|
|
81
|
+
tooltipOffsetX = 0,
|
|
82
|
+
tooltipOffsetY = -15
|
|
79
83
|
}) => {
|
|
80
84
|
const providerTheme = useGlobalChartsTheme();
|
|
81
85
|
const chartId = useChartId(providedChartId);
|
|
82
86
|
const [legendRef, legendHeight] = useElementHeight();
|
|
83
|
-
const {
|
|
84
|
-
|
|
87
|
+
const { tooltipOpen, tooltipLeft, tooltipTop, tooltipData, hideTooltip, showTooltip } = useTooltip();
|
|
88
|
+
const { containerRef, TooltipInPortal } = useTooltipInPortal({
|
|
89
|
+
detectBounds: true,
|
|
90
|
+
scroll: true,
|
|
91
|
+
debounce: 0
|
|
85
92
|
});
|
|
93
|
+
const onMouseLeave = useCallback(() => {
|
|
94
|
+
if (!withTooltips) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
hideTooltip();
|
|
98
|
+
}, [withTooltips, hideTooltip]);
|
|
86
99
|
const legendOptions = useMemo(
|
|
87
100
|
() => ({ showValues: true, legendValueDisplay }),
|
|
88
101
|
[legendValueDisplay]
|
|
@@ -141,6 +154,7 @@ var PieChartInternal = ({
|
|
|
141
154
|
children: /* @__PURE__ */ jsxs(
|
|
142
155
|
"div",
|
|
143
156
|
{
|
|
157
|
+
ref: containerRef,
|
|
144
158
|
className: clsx("pie-chart", pie_chart_module_default["pie-chart"], className),
|
|
145
159
|
style: {
|
|
146
160
|
display: "flex",
|
|
@@ -168,21 +182,36 @@ var PieChartInternal = ({
|
|
|
168
182
|
return pie.arcs.map((arc, index) => {
|
|
169
183
|
const [centroidX, centroidY] = pie.path.centroid(arc);
|
|
170
184
|
const hasSpaceForLabel = arc.endAngle - arc.startAngle >= 0.25;
|
|
171
|
-
const handleMouseMove = (event) =>
|
|
185
|
+
const handleMouseMove = (event) => {
|
|
186
|
+
if (!withTooltips) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const coords = localPoint(event);
|
|
190
|
+
if (coords) {
|
|
191
|
+
const legendOffset = showLegend && legendPosition === "top" ? legendHeight : 0;
|
|
192
|
+
showTooltip({
|
|
193
|
+
tooltipData: arc.data,
|
|
194
|
+
tooltipLeft: coords.x + tooltipOffsetX,
|
|
195
|
+
tooltipTop: coords.y + legendOffset + tooltipOffsetY
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
};
|
|
172
199
|
const pathProps = {
|
|
173
200
|
d: pie.path(arc) || "",
|
|
174
|
-
fill: accessors.fill(arc.data)
|
|
201
|
+
fill: accessors.fill(arc.data),
|
|
202
|
+
"data-testid": "pie-segment"
|
|
175
203
|
};
|
|
204
|
+
const groupProps = {};
|
|
176
205
|
if (withTooltips) {
|
|
177
|
-
|
|
178
|
-
|
|
206
|
+
groupProps.onMouseMove = handleMouseMove;
|
|
207
|
+
groupProps.onMouseLeave = onMouseLeave;
|
|
179
208
|
}
|
|
180
209
|
const fontSize = 12;
|
|
181
210
|
const estimatedTextWidth = getStringWidth(arc.data.label, { fontSize });
|
|
182
211
|
const labelPadding = 6;
|
|
183
212
|
const backgroundWidth = estimatedTextWidth + labelPadding * 2;
|
|
184
213
|
const backgroundHeight = fontSize + labelPadding * 2;
|
|
185
|
-
return /* @__PURE__ */ jsxs("g", { children: [
|
|
214
|
+
return /* @__PURE__ */ jsxs("g", { ...groupProps, children: [
|
|
186
215
|
/* @__PURE__ */ jsx("path", { ...pathProps }),
|
|
187
216
|
showLabels && hasSpaceForLabel && /* @__PURE__ */ jsxs("g", { children: [
|
|
188
217
|
providerTheme.labelBackgroundColor && /* @__PURE__ */ jsx(
|
|
@@ -229,23 +258,14 @@ var PieChartInternal = ({
|
|
|
229
258
|
alignment: legendAlignment,
|
|
230
259
|
maxWidth: legendMaxWidth,
|
|
231
260
|
textOverflow: legendTextOverflow,
|
|
261
|
+
legendItemClassName,
|
|
232
262
|
className: pie_chart_module_default["pie-chart-legend"],
|
|
233
263
|
shape: legendShape,
|
|
234
264
|
ref: legendRef,
|
|
235
265
|
chartId
|
|
236
266
|
}
|
|
237
267
|
),
|
|
238
|
-
withTooltips && tooltipOpen && tooltipData && /* @__PURE__ */ jsx(
|
|
239
|
-
BaseTooltip,
|
|
240
|
-
{
|
|
241
|
-
data: tooltipData,
|
|
242
|
-
top: tooltipTop || 0,
|
|
243
|
-
left: tooltipLeft || 0,
|
|
244
|
-
style: {
|
|
245
|
-
transform: "translate(-50%, -100%)"
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
),
|
|
268
|
+
withTooltips && tooltipOpen && tooltipData && /* @__PURE__ */ jsx(TooltipInPortal, { top: tooltipTop || 0, left: tooltipLeft || 0, children: /* @__PURE__ */ jsx("div", { role: "tooltip", children: /* @__PURE__ */ jsx(BaseTooltip, { data: tooltipData, top: 0, left: 0, renderContainer: false }) }) }),
|
|
249
269
|
htmlChildren,
|
|
250
270
|
otherChildren
|
|
251
271
|
]
|
|
@@ -280,4 +300,4 @@ export {
|
|
|
280
300
|
PieChart,
|
|
281
301
|
PieChartResponsive
|
|
282
302
|
};
|
|
283
|
-
//# sourceMappingURL=chunk-
|
|
303
|
+
//# sourceMappingURL=chunk-2YVSCZ6E.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/pie-chart/pie-chart.tsx","../src/components/pie-chart/pie-chart.module.scss"],"sourcesContent":["import { localPoint } from '@visx/event';\nimport { Group } from '@visx/group';\nimport { Pie } from '@visx/shape';\nimport { useTooltip, useTooltipInPortal } from '@visx/tooltip';\nimport clsx from 'clsx';\nimport { useCallback, useContext, useMemo } from 'react';\nimport { useElementHeight } from '../../hooks';\nimport {\n\tGlobalChartsProvider,\n\tuseChartId,\n\tuseChartRegistration,\n\tuseGlobalChartsContext,\n\tuseGlobalChartsTheme,\n\tGlobalChartsContext,\n} from '../../providers';\nimport { attachSubComponents } from '../../utils';\nimport { getStringWidth } from '../../visx/text';\nimport { Legend, useChartLegendItems } from '../legend';\nimport { ChartSVG, ChartHTML, useChartChildren } from '../private/chart-composition';\nimport { SingleChartContext } from '../private/single-chart-context';\nimport { withResponsive, ResponsiveConfig } from '../private/with-responsive';\nimport { BaseTooltip } from '../tooltip';\nimport styles from './pie-chart.module.scss';\nimport type { BaseChartProps, DataPointPercentage, Optional } from '../../types';\nimport type { LegendValueDisplay } from '../legend';\nimport type { ChartComponentWithComposition } from '../private/chart-composition';\nimport type { SVGProps, MouseEvent, ReactNode, FC } from 'react';\n\nexport interface PieChartProps extends BaseChartProps< DataPointPercentage[] > {\n\t/**\n\t * Inner radius in pixels. If > 0, creates a donut chart. Defaults to 0.\n\t */\n\tinnerRadius?: number;\n\n\t/**\n\t * Add padding to the chart\n\t */\n\tpadding?: number;\n\n\t/**\n\t * Thickness of the pie chart.\n\t * A value between 0 and 1, where 0 means no thickness\n\t * and 1 means the maximum thickness.\n\t */\n\tthickness?: number;\n\n\t/**\n\t * Scale of the gap between groups in the pie chart\n\t * A value between 0 and 1, where 0 means no gap.\n\t */\n\tgapScale?: number;\n\n\t/**\n\t * Scale of the corner radius for the pie chart segments.\n\t * A value between 0 and 1, where 0 means no corner radius.\n\t */\n\tcornerScale?: number;\n\n\t/**\n\t * Whether to show labels on pie segments. Defaults to true.\n\t */\n\tshowLabels?: boolean;\n\n\t/**\n\t * What type of value to display in the legend when showValues is true.\n\t * - 'percentage': Shows percentage values (e.g., \"23%\") [default]\n\t * - 'value': Shows raw numeric values (e.g., \"30000\")\n\t * - 'valueDisplay': Shows formatted values (e.g., \"30K\")\n\t * - 'none': Shows no values, only labels\n\t */\n\tlegendValueDisplay?: LegendValueDisplay;\n\n\t/**\n\t * Use the children prop to render additional elements on the chart.\n\t */\n\tchildren?: ReactNode;\n\n\t/**\n\t * Horizontal offset for tooltip positioning in pixels (default: 0)\n\t */\n\ttooltipOffsetX?: number;\n\n\t/**\n\t * Vertical offset for tooltip positioning in pixels (default: -15)\n\t */\n\ttooltipOffsetY?: number;\n}\n\n// Base props type with optional responsive properties\ntype PieChartBaseProps = Optional< PieChartProps, 'size' >;\n\n// Composition API types\ntype PieChartComponent = ChartComponentWithComposition< PieChartBaseProps >;\ntype PieChartResponsiveComponent = ChartComponentWithComposition<\n\tPieChartBaseProps & ResponsiveConfig\n>;\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: DataPointPercentage[] ) => {\n\tif ( ! data.length ) {\n\t\treturn { isValid: false, message: 'No data available' };\n\t}\n\n\t// Check for negative values\n\tconst hasNegativeValues = data.some( item => item.percentage < 0 || item.value < 0 );\n\tif ( hasNegativeValues ) {\n\t\treturn { isValid: false, message: 'Invalid data: Negative values are not allowed' };\n\t}\n\n\t// Validate total percentage\n\tconst totalPercentage = data.reduce( ( sum, item ) => sum + item.percentage, 0 );\n\tif ( Math.abs( totalPercentage - 100 ) > 0.01 ) {\n\t\t// Using small epsilon for floating point comparison\n\t\treturn { isValid: false, message: 'Invalid percentage total: Must equal 100' };\n\t}\n\n\treturn { isValid: true, message: '' };\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\tdata,\n\tchartId: providedChartId,\n\twithTooltips = false,\n\tclassName,\n\tshowLegend = false,\n\tlegendOrientation = 'horizontal',\n\tlegendPosition = 'bottom',\n\tlegendAlignment = 'center',\n\tlegendMaxWidth,\n\tlegendTextOverflow = 'wrap',\n\tlegendItemClassName,\n\tlegendShape = 'circle',\n\tsize,\n\tthickness = 1,\n\tpadding = 20,\n\tgapScale = 0,\n\tcornerScale = 0,\n\tshowLabels = true,\n\tlegendValueDisplay = 'percentage',\n\tchildren = null,\n\ttooltipOffsetX = 0,\n\ttooltipOffsetY = -15,\n}: PieChartProps ) => {\n\tconst providerTheme = useGlobalChartsTheme();\n\tconst chartId = useChartId( providedChartId );\n\tconst [ legendRef, legendHeight ] = useElementHeight< HTMLDivElement >();\n\tconst { tooltipOpen, tooltipLeft, tooltipTop, tooltipData, hideTooltip, showTooltip } =\n\t\tuseTooltip< DataPointPercentage >();\n\n\t// Set up portal tooltip for better z-index handling\n\tconst { containerRef, TooltipInPortal } = useTooltipInPortal( {\n\t\tdetectBounds: true,\n\t\tscroll: true,\n\t\tdebounce: 0,\n\t} );\n\n\tconst onMouseLeave = useCallback( () => {\n\t\tif ( ! withTooltips ) {\n\t\t\treturn;\n\t\t}\n\t\thideTooltip();\n\t}, [ withTooltips, hideTooltip ] );\n\n\t// Memoize legend options to prevent unnecessary re-calculations\n\tconst legendOptions = useMemo(\n\t\t() => ( { showValues: true, legendValueDisplay } ),\n\t\t[ legendValueDisplay ]\n\t);\n\n\t// Create legend items using the reusable hook\n\tconst legendItems = useChartLegendItems( data, legendOptions );\n\n\tconst { isValid, message } = validateData( data );\n\n\t// Process children to extract compound components\n\tconst { svgChildren, htmlChildren, otherChildren } = useChartChildren( children, 'PieChart' );\n\n\t// Memoize metadata to prevent unnecessary re-registration\n\tconst chartMetadata = useMemo(\n\t\t() => ( {\n\t\t\tthickness,\n\t\t\tgapScale,\n\t\t\tcornerScale,\n\t\t} ),\n\t\t[ thickness, gapScale, cornerScale ]\n\t);\n\n\t// Register chart with context only if data is valid\n\tuseChartRegistration( {\n\t\tchartId,\n\t\tlegendItems,\n\t\tchartType: 'pie',\n\t\tisDataValid: isValid,\n\t\tmetadata: chartMetadata,\n\t} );\n\n\tconst { getElementStyles } = useGlobalChartsContext();\n\n\tif ( ! isValid ) {\n\t\treturn (\n\t\t\t<div className={ clsx( 'pie-chart', styles[ 'pie-chart' ], className ) }>\n\t\t\t\t<div className={ styles[ 'error-message' ] }>{ message }</div>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tconst width = size;\n\tconst height = size;\n\tconst adjustedHeight = showLegend && legendPosition === 'top' ? height - legendHeight : height;\n\n\t// Calculate radius based on width/height\n\tconst radius = Math.min( width, adjustedHeight ) / 2;\n\n\t// Center the chart in the available space\n\tconst centerX = width / 2;\n\tconst centerY = adjustedHeight / 2;\n\n\t// Calculate the angle between each\n\tconst padAngle = gapScale * ( ( 2 * Math.PI ) / data.length );\n\n\tconst outerRadius = radius - padding;\n\tconst innerRadius = thickness === 0 ? 0 : outerRadius * ( 1 - thickness );\n\n\tconst maxCornerRadius = ( outerRadius - innerRadius ) / 2;\n\tconst cornerRadius = cornerScale ? Math.min( cornerScale * outerRadius, maxCornerRadius ) : 0;\n\n\t// Map the data to include index for color assignment\n\tconst dataWithIndex = data.map( ( d, index ) => ( {\n\t\t...d,\n\t\tindex,\n\t} ) );\n\n\tconst accessors = {\n\t\tvalue: ( d: DataPointPercentage ) => d.value,\n\t\tfill: ( d: DataPointPercentage & { index: number } ) => {\n\t\t\treturn getElementStyles( { data: d, index: d.index } ).color;\n\t\t},\n\t};\n\n\treturn (\n\t\t<SingleChartContext.Provider\n\t\t\tvalue={ {\n\t\t\t\tchartId,\n\t\t\t\tchartWidth: width,\n\t\t\t\tchartHeight: adjustedHeight,\n\t\t\t} }\n\t\t>\n\t\t\t<div\n\t\t\t\tref={ containerRef }\n\t\t\t\tclassName={ clsx( 'pie-chart', styles[ 'pie-chart' ], className ) }\n\t\t\t\tstyle={ {\n\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\tflexDirection: showLegend && legendPosition === 'top' ? 'column-reverse' : 'column',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\tviewBox={ `0 0 ${ width } ${ adjustedHeight }` }\n\t\t\t\t\tpreserveAspectRatio=\"xMidYMid meet\"\n\t\t\t\t\twidth={ width }\n\t\t\t\t\theight={ adjustedHeight }\n\t\t\t\t>\n\t\t\t\t\t<Group top={ centerY } left={ centerX }>\n\t\t\t\t\t\t<Pie< DataPointPercentage & { index: number } >\n\t\t\t\t\t\t\tdata={ dataWithIndex }\n\t\t\t\t\t\t\tpieValue={ accessors.value }\n\t\t\t\t\t\t\touterRadius={ outerRadius }\n\t\t\t\t\t\t\tinnerRadius={ innerRadius }\n\t\t\t\t\t\t\tpadAngle={ padAngle }\n\t\t\t\t\t\t\tcornerRadius={ cornerRadius }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ pie => {\n\t\t\t\t\t\t\t\treturn pie.arcs.map( ( arc, index ) => {\n\t\t\t\t\t\t\t\t\tconst [ centroidX, centroidY ] = pie.path.centroid( arc );\n\t\t\t\t\t\t\t\t\tconst hasSpaceForLabel = arc.endAngle - arc.startAngle >= 0.25;\n\t\t\t\t\t\t\t\t\tconst handleMouseMove = ( event: MouseEvent< SVGElement > ) => {\n\t\t\t\t\t\t\t\t\t\tif ( ! withTooltips ) {\n\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t// Get coordinates relative to the current target element\n\t\t\t\t\t\t\t\t\t\tconst coords = localPoint( event );\n\t\t\t\t\t\t\t\t\t\tif ( coords ) {\n\t\t\t\t\t\t\t\t\t\t\t// Account for legend offset when legend is on top\n\t\t\t\t\t\t\t\t\t\t\tconst legendOffset =\n\t\t\t\t\t\t\t\t\t\t\t\tshowLegend && legendPosition === 'top' ? legendHeight : 0;\n\t\t\t\t\t\t\t\t\t\t\tshowTooltip( {\n\t\t\t\t\t\t\t\t\t\t\t\ttooltipData: arc.data,\n\t\t\t\t\t\t\t\t\t\t\t\ttooltipLeft: coords.x + tooltipOffsetX,\n\t\t\t\t\t\t\t\t\t\t\t\ttooltipTop: coords.y + legendOffset + tooltipOffsetY,\n\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\t\tconst pathProps: SVGProps< SVGPathElement > & { 'data-testid'?: string } = {\n\t\t\t\t\t\t\t\t\t\td: pie.path( arc ) || '',\n\t\t\t\t\t\t\t\t\t\tfill: accessors.fill( arc.data ),\n\t\t\t\t\t\t\t\t\t\t'data-testid': 'pie-segment',\n\t\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\t\tconst groupProps: SVGProps< SVGGElement > = {};\n\t\t\t\t\t\t\t\t\tif ( withTooltips ) {\n\t\t\t\t\t\t\t\t\t\tgroupProps.onMouseMove = handleMouseMove;\n\t\t\t\t\t\t\t\t\t\tgroupProps.onMouseLeave = onMouseLeave;\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t// Estimate text width more accurately for background sizing\n\t\t\t\t\t\t\t\t\tconst fontSize = 12;\n\t\t\t\t\t\t\t\t\tconst estimatedTextWidth = getStringWidth( arc.data.label, { fontSize } );\n\t\t\t\t\t\t\t\t\tconst labelPadding = 6;\n\t\t\t\t\t\t\t\t\tconst backgroundWidth = estimatedTextWidth + labelPadding * 2;\n\t\t\t\t\t\t\t\t\tconst backgroundHeight = fontSize + labelPadding * 2;\n\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<g key={ `arc-${ index }` } { ...groupProps }>\n\t\t\t\t\t\t\t\t\t\t\t<path { ...pathProps } />\n\t\t\t\t\t\t\t\t\t\t\t{ showLabels && hasSpaceForLabel && (\n\t\t\t\t\t\t\t\t\t\t\t\t<g>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ providerTheme.labelBackgroundColor && (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<rect\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tx={ centroidX - backgroundWidth / 2 }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ty={ centroidY - backgroundHeight / 2 }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twidth={ backgroundWidth }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\theight={ backgroundHeight }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfill={ providerTheme.labelBackgroundColor }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\trx={ 4 }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\try={ 4 }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpointerEvents=\"none\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t<text\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tx={ centroidX }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ty={ centroidY }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdy=\".33em\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfill={ providerTheme.labelTextColor || '#333' }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfontSize={ fontSize }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttextAnchor=\"middle\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tpointerEvents=\"none\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ arc.data.label }\n\t\t\t\t\t\t\t\t\t\t\t\t\t</text>\n\t\t\t\t\t\t\t\t\t\t\t\t</g>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</g>\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t</Pie>\n\n\t\t\t\t\t\t{ /* Render SVG children (like Group, Text) inside the SVG */ }\n\t\t\t\t\t\t{ svgChildren }\n\t\t\t\t\t</Group>\n\t\t\t\t</svg>\n\n\t\t\t\t{ showLegend && (\n\t\t\t\t\t<Legend\n\t\t\t\t\t\torientation={ legendOrientation }\n\t\t\t\t\t\tposition={ legendPosition }\n\t\t\t\t\t\talignment={ legendAlignment }\n\t\t\t\t\t\tmaxWidth={ legendMaxWidth }\n\t\t\t\t\t\ttextOverflow={ legendTextOverflow }\n\t\t\t\t\t\tlegendItemClassName={ legendItemClassName }\n\t\t\t\t\t\tclassName={ styles[ 'pie-chart-legend' ] }\n\t\t\t\t\t\tshape={ legendShape }\n\t\t\t\t\t\tref={ legendRef }\n\t\t\t\t\t\tchartId={ chartId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ withTooltips && tooltipOpen && tooltipData && (\n\t\t\t\t\t<TooltipInPortal top={ tooltipTop || 0 } left={ tooltipLeft || 0 }>\n\t\t\t\t\t\t<div role=\"tooltip\">\n\t\t\t\t\t\t\t<BaseTooltip data={ tooltipData } top={ 0 } left={ 0 } renderContainer={ false } />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</TooltipInPortal>\n\t\t\t\t) }\n\n\t\t\t\t{ /* Render HTML component children from PieChart.HTML */ }\n\t\t\t\t{ htmlChildren }\n\n\t\t\t\t{ /* Render other React children for backward compatibility */ }\n\t\t\t\t{ otherChildren }\n\t\t\t</div>\n\t\t</SingleChartContext.Provider>\n\t);\n};\n\nconst PieChartWithProvider: FC< PieChartProps > = props => {\n\tconst existingContext = useContext( GlobalChartsContext );\n\n\t// If we're already in a GlobalChartsProvider context, don't create a new one\n\tif ( existingContext ) {\n\t\treturn <PieChartInternal { ...props } />;\n\t}\n\n\t// Otherwise, create our own GlobalChartsProvider\n\treturn (\n\t\t<GlobalChartsProvider>\n\t\t\t<PieChartInternal { ...props } />\n\t\t</GlobalChartsProvider>\n\t);\n};\n\nPieChartWithProvider.displayName = 'PieChart';\n\n// Create PieChart with composition API\nconst PieChart = attachSubComponents( PieChartWithProvider, {\n\tLegend: Legend,\n\tSVG: ChartSVG,\n\tHTML: ChartHTML,\n} ) as PieChartComponent;\n\n// Create responsive PieChart with composition API\nconst PieChartResponsive = attachSubComponents(\n\twithResponsive< PieChartProps >( PieChartWithProvider ),\n\t{\n\t\tLegend: Legend,\n\t\tSVG: ChartSVG,\n\t\tHTML: ChartHTML,\n\t}\n) as PieChartResponsiveComponent;\n\nexport { PieChartResponsive as default, PieChart as PieChartUnresponsive };\n","import 'css-chunk:src/components/pie-chart/pie-chart.module.scss';export default {\n \"pie-chart\": \"a8ccharts-R12VhH\"\n};"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AACtB,SAAS,WAAW;AACpB,SAAS,YAAY,0BAA0B;AAC/C,OAAO,UAAU;AACjB,SAAS,aAAa,YAAY,eAAe;;;ACLiB,IAAO,2BAAQ;AAAA,EAC/E,aAAa;AACf;;;ADiNI,cAmHQ,YAnHR;AA7GJ,IAAM,eAAe,CAAE,SAAiC;AACvD,MAAK,CAAE,KAAK,QAAS;AACpB,WAAO,EAAE,SAAS,OAAO,SAAS,oBAAoB;AAAA,EACvD;AAGA,QAAM,oBAAoB,KAAK,KAAM,UAAQ,KAAK,aAAa,KAAK,KAAK,QAAQ,CAAE;AACnF,MAAK,mBAAoB;AACxB,WAAO,EAAE,SAAS,OAAO,SAAS,gDAAgD;AAAA,EACnF;AAGA,QAAM,kBAAkB,KAAK,OAAQ,CAAE,KAAK,SAAU,MAAM,KAAK,YAAY,CAAE;AAC/E,MAAK,KAAK,IAAK,kBAAkB,GAAI,IAAI,MAAO;AAE/C,WAAO,EAAE,SAAS,OAAO,SAAS,2CAA2C;AAAA,EAC9E;AAEA,SAAO,EAAE,SAAS,MAAM,SAAS,GAAG;AACrC;AAQA,IAAM,mBAAmB,CAAE;AAAA,EAC1B;AAAA,EACA,SAAS;AAAA,EACT,eAAe;AAAA,EACf;AAAA,EACA,aAAa;AAAA,EACb,oBAAoB;AAAA,EACpB,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB;AAAA,EACA,qBAAqB;AAAA,EACrB;AAAA,EACA,cAAc;AAAA,EACd;AAAA,EACA,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,WAAW;AAAA,E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AC3D;AAAA,EACA,KAAK;AAAA,EACL,MAAM;AACP,CAAE;AAGF,IAAM,qBAAqB;AAAA,EAC1B,eAAiC,oBAAqB;AAAA,EACtD;AAAA,IACC;AAAA,IACA,KAAK;AAAA,IACL,MAAM;AAAA,EACP;AACD;","names":[]}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
useGlobalChartsContext,
|
|
5
5
|
useGlobalChartsTheme,
|
|
6
6
|
useTextTruncation
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-KACVKFMH.js";
|
|
8
8
|
|
|
9
9
|
// src/components/legend/legend.tsx
|
|
10
10
|
import { useContext as useContext2, useMemo, forwardRef as forwardRef2 } from "react";
|
|
@@ -127,6 +127,7 @@ var BaseLegend = forwardRef(
|
|
|
127
127
|
itemMargin = "0",
|
|
128
128
|
itemDirection = "row",
|
|
129
129
|
legendLabelProps,
|
|
130
|
+
legendItemClassName,
|
|
130
131
|
...legendItemProps
|
|
131
132
|
}, ref) => {
|
|
132
133
|
const theme = useGlobalChartsTheme();
|
|
@@ -165,7 +166,11 @@ var BaseLegend = forwardRef(
|
|
|
165
166
|
children: labels.map((label, i) => /* @__PURE__ */ jsxs(
|
|
166
167
|
LegendItem,
|
|
167
168
|
{
|
|
168
|
-
className: clsx(
|
|
169
|
+
className: clsx(
|
|
170
|
+
"visx-legend-item",
|
|
171
|
+
base_legend_module_default["legend-item"],
|
|
172
|
+
legendItemClassName
|
|
173
|
+
),
|
|
169
174
|
"data-testid": "legend-item",
|
|
170
175
|
margin: itemMargin,
|
|
171
176
|
flexDirection: orientation === "vertical" && alignment === "end" ? "row-reverse" : itemDirection,
|
|
@@ -381,4 +386,4 @@ export {
|
|
|
381
386
|
Legend,
|
|
382
387
|
useChartLegendItems
|
|
383
388
|
};
|
|
384
|
-
//# sourceMappingURL=chunk-
|
|
389
|
+
//# sourceMappingURL=chunk-663ETEC4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/legend/legend.tsx","../src/components/private/single-chart-context/single-chart-context.tsx","../src/components/private/single-chart-context/use-single-chart-context.ts","../src/components/legend/private/base-legend.tsx","../src/components/legend/utils/value-or-identity.ts","../src/components/legend/utils/label-transform-factory.ts","../src/components/legend/private/base-legend.module.scss","../src/components/legend/hooks/use-chart-legend-items.ts"],"sourcesContent":["import { useContext, useMemo, forwardRef } from 'react';\nimport { GlobalChartsContext } from '../../providers';\nimport { SingleChartContext } from '../private/single-chart-context';\nimport { BaseLegend } from './private';\nimport type { LegendProps } from './types';\n\nexport const Legend = forwardRef< HTMLDivElement, LegendProps >(\n\t( { chartId, items, ...props }, ref ) => {\n\t\t// Get context but don't throw if it doesn't exist\n\t\tconst context = useContext( GlobalChartsContext );\n\t\tconst singleChartContext = useContext( SingleChartContext );\n\n\t\t// When chartId is used, it is standalone mode\n\t\t// When chartId is not provided, we use the context's chartId, meaning it is in a single chart context\n\t\tconst contextChartId = chartId ?? singleChartContext?.chartId;\n\n\t\t// Use useMemo to ensure re-rendering when context changes\n\t\tconst contextItems = useMemo( () => {\n\t\t\treturn contextChartId && context\n\t\t\t\t? context.getChartData( contextChartId )?.legendItems\n\t\t\t\t: undefined;\n\t\t}, [ contextChartId, context ] );\n\n\t\t// Provided items take precedence over context items\n\t\tconst legendItems = ( items || contextItems ) as typeof items;\n\n\t\tif ( ! legendItems ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn <BaseLegend ref={ ref } items={ legendItems } { ...props } />;\n\t}\n);\n","import { createContext } from 'react';\n\nexport interface ChartInstanceRef {\n\tgetScales: () => { xScale: unknown; yScale: unknown } | null;\n\tgetChartDimensions: () => {\n\t\twidth: number;\n\t\theight: number;\n\t\tmargin: { top?: number; right?: number; bottom?: number; left?: number };\n\t};\n}\n\n// Local context for chart implicit state sharing\nexport interface ChartInstanceContextValue {\n\tchartId: string;\n\tchartRef?: React.RefObject< ChartInstanceRef >;\n\tchartWidth: number;\n\tchartHeight: number;\n}\n\nexport const ChartInstanceContext = createContext< ChartInstanceContextValue | null >( null );\n\n// Backward compatibility exports\nexport const SingleChartContext = ChartInstanceContext;\nexport type SingleChartContextValue = ChartInstanceContextValue;\nexport type SingleChartRef = ChartInstanceRef;\n","import { useContext } from 'react';\nimport { ChartInstanceContext, type ChartInstanceContextValue } from './single-chart-context';\n\nexport const useChartInstanceContext = (): ChartInstanceContextValue => {\n\tconst context = useContext( ChartInstanceContext );\n\tif ( ! context ) {\n\t\tthrow new Error( 'useChartInstanceContext must be used within a Chart component' );\n\t}\n\treturn context;\n};\n\nexport const useSingleChartContext = useChartInstanceContext;\n","import { Group } from '@visx/group';\nimport { LegendItem, LegendLabel, LegendOrdinal, LegendShape } from '@visx/legend';\nimport { scaleOrdinal } from '@visx/scale';\nimport clsx from 'clsx';\nimport { type RefAttributes, type ForwardRefExoticComponent, forwardRef, useCallback } from 'react';\nimport { useTextTruncation } from '../../../hooks';\nimport { useGlobalChartsTheme } from '../../../providers';\nimport { valueOrIdentity, valueOrIdentityString, labelTransformFactory } from '../utils';\nimport styles from './base-legend.module.scss';\nimport type { BaseLegendProps } from '../types';\n\nconst orientationToFlexDirection = {\n\thorizontal: 'row' as const,\n\tvertical: 'column' as const,\n};\n\n// Component for legend text with truncation detection\n// Moved outside BaseLegend to prevent recreation on every render\nconst LegendText = ( {\n\ttext,\n\ttextOverflow,\n\tmaxWidth,\n}: {\n\ttext: string;\n\ttextOverflow: 'ellipsis' | 'wrap';\n\tmaxWidth?: string;\n} ) => {\n\tconst isEllipsis = maxWidth != null && textOverflow === 'ellipsis';\n\tconst [ textRef, isTruncated ] = useTextTruncation( Boolean( isEllipsis ) );\n\n\treturn (\n\t\t<span\n\t\t\tref={ textRef }\n\t\t\tclassName={ clsx(\n\t\t\t\tstyles[ 'legend-item-text' ],\n\t\t\t\tmaxWidth != null && styles[ `legend-item-text--${ textOverflow }` ]\n\t\t\t) }\n\t\t\tstyle={ {\n\t\t\t\t...( maxWidth != null && {\n\t\t\t\t\tmaxWidth,\n\t\t\t\t\tminWidth: 0,\n\t\t\t\t} ),\n\t\t\t} }\n\t\t\ttitle={ isEllipsis && isTruncated ? text : undefined }\n\t\t>\n\t\t\t{ text }\n\t\t</span>\n\t);\n};\n\n/*\n * Base legend component that displays color-coded items with labels based on visx LegendOrdinal.\n * We avoid using LegendOrdinal directly to enable support for advanced features such as interactivity.\n */\nexport const BaseLegend: ForwardRefExoticComponent<\n\tBaseLegendProps & RefAttributes< HTMLDivElement >\n> = forwardRef< HTMLDivElement, BaseLegendProps >(\n\t(\n\t\t{\n\t\t\titems,\n\t\t\tclassName,\n\t\t\torientation = 'horizontal',\n\t\t\tposition = 'bottom',\n\t\t\talignment = 'center',\n\t\t\tmaxWidth,\n\t\t\ttextOverflow = 'wrap',\n\t\t\tshape = 'rect',\n\t\t\tfill = valueOrIdentityString,\n\t\t\tsize = valueOrIdentityString,\n\t\t\tlabelFormat = valueOrIdentity,\n\t\t\tlabelTransform = labelTransformFactory,\n\t\t\tshapeWidth = 16,\n\t\t\tshapeHeight = 16,\n\t\t\tshapeMargin = '2px 4px 2px 0',\n\t\t\tlabelAlign = 'left',\n\t\t\tlabelFlex = '0 0 auto', // Use natural width instead of expanding to fill space\n\t\t\tlabelMargin = '0 4px',\n\t\t\titemMargin = '0',\n\t\t\titemDirection = 'row',\n\t\t\tlegendLabelProps,\n\t\t\tlegendItemClassName,\n\t\t\t...legendItemProps\n\t\t},\n\t\tref\n\t) => {\n\t\tconst theme = useGlobalChartsTheme();\n\n\t\tconst legendScale = scaleOrdinal( {\n\t\t\tdomain: items.map( item => item.label ),\n\t\t\trange: items.map( item => item.color ),\n\t\t} );\n\t\tconst domain = legendScale.domain();\n\n\t\tconst getShapeStyle = useCallback(\n\t\t\t( { index }: { index: number } ) => items[ index ]?.shapeStyle,\n\t\t\t[ items ]\n\t\t);\n\n\t\treturn (\n\t\t\t<LegendOrdinal\n\t\t\t\tscale={ legendScale }\n\t\t\t\tlabelFormat={ labelFormat }\n\t\t\t\tlabelTransform={ labelTransform }\n\t\t\t>\n\t\t\t\t{ labels => (\n\t\t\t\t\t<div\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\trole=\"list\"\n\t\t\t\t\t\tdata-testid={ `legend-${ orientation }` }\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\tstyles.legend,\n\t\t\t\t\t\t\tstyles[ `legend--${ orientation }` ],\n\t\t\t\t\t\t\tstyles[ `legend--alignment-${ alignment }` ],\n\t\t\t\t\t\t\tstyles[ `legend--position-${ position }` ],\n\t\t\t\t\t\t\tclassName\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\tflexDirection: orientationToFlexDirection[ orientation ],\n\t\t\t\t\t\t\t...theme.legendContainerStyles,\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ labels.map( ( label, i ) => (\n\t\t\t\t\t\t\t<LegendItem\n\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t'visx-legend-item',\n\t\t\t\t\t\t\t\t\tstyles[ 'legend-item' ],\n\t\t\t\t\t\t\t\t\tlegendItemClassName\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tdata-testid=\"legend-item\"\n\t\t\t\t\t\t\t\tkey={ `legend-${ label.text }-${ i }` }\n\t\t\t\t\t\t\t\tmargin={ itemMargin }\n\t\t\t\t\t\t\t\tflexDirection={\n\t\t\t\t\t\t\t\t\torientation === 'vertical' && alignment === 'end' ? 'row-reverse' : itemDirection\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t{ ...legendItemProps }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ items[ i ]?.renderGlyph ? (\n\t\t\t\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\t\t\t\twidth={ items[ i ]?.glyphSize * 2 }\n\t\t\t\t\t\t\t\t\t\theight={ items[ i ]?.glyphSize * 2 }\n\t\t\t\t\t\t\t\t\t\tdata-testid=\"legend-glyph\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<Group>\n\t\t\t\t\t\t\t\t\t\t\t{ items[ i ]?.renderGlyph( {\n\t\t\t\t\t\t\t\t\t\t\t\tkey: `legend-glyph-${ label.text }`,\n\t\t\t\t\t\t\t\t\t\t\t\tdatum: {},\n\t\t\t\t\t\t\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\t\t\t\t\t\t\tcolor: fill( label ),\n\t\t\t\t\t\t\t\t\t\t\t\tsize: items[ i ]?.glyphSize,\n\t\t\t\t\t\t\t\t\t\t\t\tx: items[ i ]?.glyphSize,\n\t\t\t\t\t\t\t\t\t\t\t\ty: items[ i ]?.glyphSize,\n\t\t\t\t\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t\t\t\t</Group>\n\t\t\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<LegendShape\n\t\t\t\t\t\t\t\t\t\tshape={ shape }\n\t\t\t\t\t\t\t\t\t\theight={ shapeHeight }\n\t\t\t\t\t\t\t\t\t\twidth={ shapeWidth }\n\t\t\t\t\t\t\t\t\t\tmargin={ shapeMargin }\n\t\t\t\t\t\t\t\t\t\titem={ domain[ i ] }\n\t\t\t\t\t\t\t\t\t\titemIndex={ i }\n\t\t\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\t\t\tfill={ fill }\n\t\t\t\t\t\t\t\t\t\tsize={ size }\n\t\t\t\t\t\t\t\t\t\tshapeStyle={ getShapeStyle }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t<LegendLabel\n\t\t\t\t\t\t\t\t\tclassName={ clsx( 'visx-legend-label', styles[ 'legend-item-label' ] ) }\n\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\tjustifyContent: labelAlign,\n\t\t\t\t\t\t\t\t\t\tflex: labelFlex,\n\t\t\t\t\t\t\t\t\t\tmargin: labelMargin,\n\t\t\t\t\t\t\t\t\t\t...theme.legendLabelStyles,\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t{ ...legendLabelProps }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<LegendText\n\t\t\t\t\t\t\t\t\t\ttext={ label.text }\n\t\t\t\t\t\t\t\t\t\ttextOverflow={ textOverflow }\n\t\t\t\t\t\t\t\t\t\tmaxWidth={ maxWidth }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ items.find( item => item.label === label.text )?.value && (\n\t\t\t\t\t\t\t\t\t\t<span className={ styles[ 'legend-item-value' ] }>\n\t\t\t\t\t\t\t\t\t\t\t{ '\\u00A0' }\n\t\t\t\t\t\t\t\t\t\t\t{ items.find( item => item.label === label.text )?.value }\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</LegendLabel>\n\t\t\t\t\t\t\t</LegendItem>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</LegendOrdinal>\n\t\t);\n\t}\n);\n","export type ValueOrIdentity< T > = T | { value?: T };\n\n/**\n * Returns an object's value if defined, or the object.\n * @param _ - The object to return the value of.\n * @return The value of the object, or the object itself.\n */\nexport function valueOrIdentity< T >( _: ValueOrIdentity< T > ): T {\n\tif ( _ && typeof _ === 'object' && 'value' in _ && typeof _.value !== 'undefined' )\n\t\treturn _.value;\n\treturn _ as T;\n}\n\n/**\n * Returns an object's value if defined, or the object, coerced to a string.\n * @param _ - The object to return the value of.\n * @return The value of the object, or the object itself.\n */\nexport function valueOrIdentityString< T >( _: ValueOrIdentity< T > ): string {\n\treturn String( valueOrIdentity( _ ) );\n}\n","import type { ItemTransformer, LabelFormatter } from '@visx/legend/lib/types';\nimport type { AnyD3Scale, ScaleInput } from '@visx/scale';\n\n/**\n * Returns a function which takes a Datum and index as input, and returns a formatted label object.\n * @param {object} root0 - The object to return the value of.\n * @param {AnyD3Scale} root0.scale - The scale to use.\n * @param {LabelFormatter<ScaleInput<Scale>>} root0.labelFormat - The label format to use.\n * @return {ItemTransformer<ScaleInput<Scale>, ReturnType<Scale>>} The label transform factory.\n */\nexport function labelTransformFactory< Scale extends AnyD3Scale >( {\n\tscale,\n\tlabelFormat,\n}: {\n\tscale: Scale;\n\tlabelFormat: LabelFormatter< ScaleInput< Scale > >;\n} ): ItemTransformer< ScaleInput< Scale >, ReturnType< Scale > > {\n\treturn ( d, i ) => ( {\n\t\tdatum: d,\n\t\tindex: i,\n\t\ttext: `${ labelFormat( d, i ) }`,\n\t\tvalue: scale( d ),\n\t} );\n}\n","import 'css-chunk:src/components/legend/private/base-legend.module.scss';export default {\n \"legend--horizontal\": \"a8ccharts-AELBvX\",\n \"legend--vertical\": \"a8ccharts-fX8uQe\",\n \"legend--alignment-start\": \"a8ccharts-DEe0wg\",\n \"legend--alignment-center\": \"a8ccharts-WBKF9I\",\n \"legend--alignment-end\": \"a8ccharts-JfwMng\",\n \"legend--position-top\": \"a8ccharts-8Y73Kh\",\n \"legend--position-bottom\": \"a8ccharts-TVM-IY\",\n \"legend-item\": \"a8ccharts-Vflwq8\",\n \"legend-item-label\": \"a8ccharts-2H65Kr\",\n \"legend-item-text--wrap\": \"a8ccharts-faSDBI\",\n \"legend-item-text--ellipsis\": \"a8ccharts-FISUIO\",\n \"legend-item-value\": \"a8ccharts-DTZlT-\"\n};","import { useMemo } from 'react';\nimport {\n\tuseGlobalChartsContext,\n\ttype GetElementStylesParams,\n\ttype ElementStyles,\n} from '../../../providers';\nimport { formatPercentage } from '../../../utils';\nimport type { SeriesData, DataPointDate, DataPointPercentage } from '../../../types';\nimport type { BaseLegendItem } from '../types';\nimport type { LegendShape } from '@visx/legend/lib/types';\nimport type { GlyphProps } from '@visx/xychart';\nimport type { ReactNode } from 'react';\n\nexport type LegendValueDisplay = 'percentage' | 'value' | 'valueDisplay' | 'none';\n\nexport interface ChartLegendOptions {\n\twithGlyph?: boolean;\n\tglyphSize?: number;\n\trenderGlyph?: < Datum extends object >( props: GlyphProps< Datum > ) => ReactNode;\n\tshowValues?: boolean;\n\tlegendValueDisplay?: LegendValueDisplay;\n\tlegendShape?: LegendShape< SeriesData[], number >;\n}\n\n/**\n * Formats the value for a data point based on its type and display preference\n * @param point - The data point to format\n * @param showValues - Whether to show values or return empty string\n * @param legendValueDisplay - What type of value to display\n * @return Formatted value string\n */\nfunction formatPointValue(\n\tpoint: DataPointDate | DataPointPercentage,\n\tshowValues: boolean,\n\tlegendValueDisplay: LegendValueDisplay = 'percentage'\n): string {\n\tif ( ! showValues || legendValueDisplay === 'none' ) {\n\t\treturn '';\n\t}\n\n\t// Handle DataPointPercentage (pie chart data)\n\tif ( 'percentage' in point ) {\n\t\tconst percentagePoint = point as DataPointPercentage;\n\t\tswitch ( legendValueDisplay ) {\n\t\t\tcase 'percentage':\n\t\t\t\treturn formatPercentage( percentagePoint.percentage );\n\t\t\tcase 'value':\n\t\t\t\treturn percentagePoint.value.toString();\n\t\t\tcase 'valueDisplay':\n\t\t\t\treturn percentagePoint.valueDisplay || percentagePoint.value.toString();\n\t\t\tdefault:\n\t\t\t\treturn '';\n\t\t}\n\t}\n\n\t// Handle DataPointDate (time series data)\n\tif ( 'value' in point ) {\n\t\treturn point.value.toString();\n\t}\n\n\treturn '';\n}\n\n/**\n * Applies glyph configuration to a legend item if needed\n * @param baseItem - The base legend item\n * @param withGlyph - Whether to include glyph rendering\n * @param glyph - Glyph component from theme\n * @param renderGlyph - Custom glyph render function\n * @param glyphSize - Size of the glyph\n * @return The legend item with glyph configuration applied if applicable\n */\nfunction applyGlyphToLegendItem(\n\tbaseItem: BaseLegendItem,\n\twithGlyph: boolean,\n\tglyph?: < Datum extends object >( props: GlyphProps< Datum > ) => ReactNode,\n\trenderGlyph?: < Datum extends object >( props: GlyphProps< Datum > ) => ReactNode,\n\tglyphSize?: number\n): BaseLegendItem {\n\tif ( withGlyph ) {\n\t\tconst glyphToUse = glyph || renderGlyph;\n\t\tif ( glyphToUse ) {\n\t\t\treturn {\n\t\t\t\t...baseItem,\n\t\t\t\tglyphSize,\n\t\t\t\trenderGlyph: glyphToUse,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn baseItem;\n}\n\n/**\n * Processes SeriesData into legend items\n * @param seriesData - The series data to process\n * @param getElementStyles - Function to get element styles\n * @param showValues - Whether to show values in legend\n * @param withGlyph - Whether to include glyph rendering\n * @param glyphSize - Size of the glyph\n * @param renderGlyph - Component to render the glyph\n * @param legendShape - The shape type for legend items (string literal or React component)\n * @return Array of processed legend items\n */\nfunction processSeriesData(\n\tseriesData: SeriesData[],\n\tgetElementStyles: ( params: GetElementStylesParams ) => ElementStyles,\n\tshowValues: boolean,\n\twithGlyph: boolean,\n\tglyphSize: number,\n\trenderGlyph?: < Datum extends object >( props: GlyphProps< Datum > ) => ReactNode,\n\tlegendShape?: LegendShape< SeriesData[], number >\n): BaseLegendItem[] {\n\tconst mapper = ( series: SeriesData, index: number ) => {\n\t\tconst { color, glyph, shapeStyles } = getElementStyles( {\n\t\t\tdata: series,\n\t\t\tindex,\n\t\t\tlegendShape,\n\t\t} );\n\n\t\tconst baseItem: BaseLegendItem = {\n\t\t\tlabel: series.label,\n\t\t\tvalue: showValues ? series.data?.length?.toString() || '0' : '',\n\t\t\tcolor,\n\t\t\tshapeStyle: shapeStyles,\n\t\t};\n\n\t\treturn applyGlyphToLegendItem( baseItem, withGlyph, glyph, renderGlyph, glyphSize );\n\t};\n\n\treturn seriesData.map( mapper );\n}\n\n/**\n * Processes point data into legend items\n * @param pointData - The point data to process\n * @param getElementStyles - Function to get element styles\n * @param showValues - Whether to show values in legend\n * @param legendValueDisplay - What type of value to display\n * @param withGlyph - Whether to include glyph rendering\n * @param glyphSize - Size of the glyph\n * @param renderGlyph - Component to render the glyph\n * @param legendShape - The shape type for legend items (string literal or React component)\n * @return Array of processed legend items\n */\nfunction processPointData(\n\tpointData: ( DataPointDate | DataPointPercentage )[],\n\tgetElementStyles: ( params: GetElementStylesParams ) => ElementStyles,\n\tshowValues: boolean,\n\tlegendValueDisplay: LegendValueDisplay,\n\twithGlyph: boolean,\n\tglyphSize: number,\n\trenderGlyph?: < Datum extends object >( props: GlyphProps< Datum > ) => ReactNode,\n\tlegendShape?: LegendShape< SeriesData[], number >\n): BaseLegendItem[] {\n\tconst mapper = ( point: DataPointDate | DataPointPercentage, index: number ) => {\n\t\tconst { color, glyph, shapeStyles } = getElementStyles( {\n\t\t\tdata: point as DataPointPercentage,\n\t\t\tindex,\n\t\t\tlegendShape,\n\t\t} );\n\n\t\tconst baseItem: BaseLegendItem = {\n\t\t\tlabel: point.label,\n\t\t\tvalue: formatPointValue( point, showValues, legendValueDisplay ),\n\t\t\tcolor,\n\t\t\tshapeStyle: shapeStyles,\n\t\t};\n\n\t\treturn applyGlyphToLegendItem( baseItem, withGlyph, glyph, renderGlyph, glyphSize );\n\t};\n\n\treturn pointData.map( mapper );\n}\n\n/**\n * Hook to transform chart data into legend items\n * @param data - The chart data to transform\n * @param options - Configuration options for legend generation\n * @param legendShape - The shape type for legend items (string literal or React component)\n * @return Array of legend items ready for display\n */\nexport function useChartLegendItems<\n\tT extends SeriesData[] | DataPointDate[] | DataPointPercentage[],\n>(\n\tdata: T,\n\toptions: ChartLegendOptions = {},\n\tlegendShape?: LegendShape< SeriesData[], number >\n): BaseLegendItem[] {\n\tconst {\n\t\tshowValues = false,\n\t\tlegendValueDisplay = 'percentage',\n\t\twithGlyph = false,\n\t\tglyphSize = 8,\n\t\trenderGlyph,\n\t} = options;\n\tconst { getElementStyles } = useGlobalChartsContext();\n\n\treturn useMemo( () => {\n\t\tif ( ! data || ! Array.isArray( data ) || data.length === 0 ) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// Handle SeriesData (multiple series with data points)\n\t\tif ( 'data' in data[ 0 ] ) {\n\t\t\treturn processSeriesData(\n\t\t\t\tdata as SeriesData[],\n\t\t\t\tgetElementStyles,\n\t\t\t\tshowValues,\n\t\t\t\twithGlyph,\n\t\t\t\tglyphSize,\n\t\t\t\trenderGlyph,\n\t\t\t\tlegendShape\n\t\t\t);\n\t\t}\n\n\t\t// Handle DataPointDate or DataPointPercentage (single data points)\n\t\treturn processPointData(\n\t\t\tdata as ( DataPointDate | DataPointPercentage )[],\n\t\t\tgetElementStyles,\n\t\t\tshowValues,\n\t\t\tlegendValueDisplay,\n\t\t\twithGlyph,\n\t\t\tglyphSize,\n\t\t\trenderGlyph,\n\t\t\tlegendShape\n\t\t);\n\t}, [\n\t\tdata,\n\t\tgetElementStyles,\n\t\tshowValues,\n\t\tlegendValueDisplay,\n\t\twithGlyph,\n\t\tglyphSize,\n\t\trenderGlyph,\n\t\tlegendShape,\n\t] );\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,cAAAA,aAAY,SAAS,cAAAC,mBAAkB;;;ACAhD,SAAS,qBAAqB;AAmBvB,IAAM,uBAAuB,cAAmD,IAAK;AAGrF,IAAM,qBAAqB;;;ACtBlC,SAAS,kBAAkB;AAGpB,IAAM,0BAA0B,MAAiC;AACvE,QAAM,UAAU,WAAY,oBAAqB;AACjD,MAAK,CAAE,SAAU;AAChB,UAAM,IAAI,MAAO,+DAAgE;AAAA,EAClF;AACA,SAAO;AACR;AAEO,IAAM,wBAAwB;;;ACXrC,SAAS,aAAa;AACtB,SAAS,YAAY,aAAa,eAAe,mBAAmB;AACpE,SAAS,oBAAoB;AAC7B,OAAO,UAAU;AACjB,SAA6D,YAAY,mBAAmB;;;ACGrF,SAAS,gBAAsB,GAA6B;AAClE,MAAK,KAAK,OAAO,MAAM,YAAY,WAAW,KAAK,OAAO,EAAE,UAAU;AACrE,WAAO,EAAE;AACV,SAAO;AACR;AAOO,SAAS,sBAA4B,GAAkC;AAC7E,SAAO,OAAQ,gBAAiB,CAAE,CAAE;AACrC;;;ACVO,SAAS,sBAAmD;AAAA,E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AAS,MAAM;AACrB,QAAK,CAAE,QAAQ,CAAE,MAAM,QAAS,IAAK,KAAK,KAAK,WAAW,GAAI;AAC7D,aAAO,CAAC;AAAA,IACT;AAGA,QAAK,UAAU,KAAM,CAAE,GAAI;AAC1B,aAAO;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAGA,WAAO;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;","names":["useContext","forwardRef","jsx","forwardRef","useContext","useMemo","useMemo"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk6GO5PFYLcjs = require('./chunk-6GO5PFYL.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -13,7 +13,7 @@ var _chunkFX2PTUFCcjs = require('./chunk-FX2PTUFC.cjs');
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkNRVZS2ICcjs = require('./chunk-NRVZS2IC.cjs');
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
@@ -22,7 +22,7 @@ var _chunkSEPMBOVDcjs = require('./chunk-SEPMBOVD.cjs');
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
var
|
|
25
|
+
var _chunkRTUQVBUJcjs = require('./chunk-RTUQVBUJ.cjs');
|
|
26
26
|
|
|
27
27
|
// src/components/pie-semi-circle-chart/pie-semi-circle-chart.tsx
|
|
28
28
|
var _event = require('@visx/event');
|
|
@@ -70,27 +70,37 @@ var PieSemiCircleChartInternal = ({
|
|
|
70
70
|
legendAlignment = "center",
|
|
71
71
|
legendMaxWidth,
|
|
72
72
|
legendTextOverflow = "wrap",
|
|
73
|
+
legendItemClassName,
|
|
73
74
|
legendShape = "circle",
|
|
74
75
|
legendValueDisplay = "percentage",
|
|
75
76
|
label,
|
|
76
77
|
note,
|
|
77
78
|
className,
|
|
78
|
-
children
|
|
79
|
+
children,
|
|
80
|
+
tooltipOffsetX = 0,
|
|
81
|
+
tooltipOffsetY = -15
|
|
79
82
|
}) => {
|
|
80
|
-
const chartId =
|
|
81
|
-
const [legendRef, legendHeight] =
|
|
83
|
+
const chartId = _chunkRTUQVBUJcjs.useChartId.call(void 0, providedChartId);
|
|
84
|
+
const [legendRef, legendHeight] = _chunkRTUQVBUJcjs.useElementHeight.call(void 0, );
|
|
82
85
|
const { tooltipOpen, tooltipLeft, tooltipTop, tooltipData, hideTooltip, showTooltip } = _tooltip.useTooltip.call(void 0, );
|
|
86
|
+
const { containerRef, TooltipInPortal } = _tooltip.useTooltipInPortal.call(void 0, {
|
|
87
|
+
detectBounds: true,
|
|
88
|
+
scroll: true,
|
|
89
|
+
debounce: 0
|
|
90
|
+
});
|
|
83
91
|
const handleMouseMove = _react.useCallback.call(void 0,
|
|
84
92
|
(event, arc) => {
|
|
85
93
|
const coords = _event.localPoint.call(void 0, event);
|
|
86
|
-
if (
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
if (coords) {
|
|
95
|
+
const legendOffset = showLegend && legendPosition === "top" ? legendHeight : 0;
|
|
96
|
+
showTooltip({
|
|
97
|
+
tooltipData: arc.data,
|
|
98
|
+
tooltipLeft: coords.x + tooltipOffsetX,
|
|
99
|
+
tooltipTop: coords.y + legendOffset + tooltipOffsetY
|
|
100
|
+
});
|
|
101
|
+
}
|
|
92
102
|
},
|
|
93
|
-
[showTooltip]
|
|
103
|
+
[showTooltip, tooltipOffsetX, tooltipOffsetY, showLegend, legendPosition, legendHeight]
|
|
94
104
|
);
|
|
95
105
|
const handleMouseLeave = _react.useCallback.call(void 0, () => {
|
|
96
106
|
hideTooltip();
|
|
@@ -102,7 +112,7 @@ var PieSemiCircleChartInternal = ({
|
|
|
102
112
|
[handleMouseMove]
|
|
103
113
|
);
|
|
104
114
|
const { isValid, message } = validateData(data);
|
|
105
|
-
const { getElementStyles } =
|
|
115
|
+
const { getElementStyles } = _chunkRTUQVBUJcjs.useGlobalChartsContext.call(void 0, );
|
|
106
116
|
const accessors = _react.useMemo.call(void 0,
|
|
107
117
|
() => ({
|
|
108
118
|
value: (d) => d.value,
|
|
@@ -115,7 +125,7 @@ var PieSemiCircleChartInternal = ({
|
|
|
115
125
|
() => ({ showValues: true, legendValueDisplay }),
|
|
116
126
|
[legendValueDisplay]
|
|
117
127
|
);
|
|
118
|
-
const legendItems =
|
|
128
|
+
const legendItems = _chunkNRVZS2ICcjs.useChartLegendItems.call(void 0, data, legendOptions);
|
|
119
129
|
const { svgChildren, htmlChildren, otherChildren } = _chunk3Z526IL2cjs.useChartChildren.call(void 0,
|
|
120
130
|
children,
|
|
121
131
|
"PieSemiCircleChart"
|
|
@@ -127,7 +137,7 @@ var PieSemiCircleChartInternal = ({
|
|
|
127
137
|
}),
|
|
128
138
|
[thickness, clockwise]
|
|
129
139
|
);
|
|
130
|
-
|
|
140
|
+
_chunkRTUQVBUJcjs.useChartRegistration.call(void 0, {
|
|
131
141
|
chartId,
|
|
132
142
|
legendItems,
|
|
133
143
|
chartType: "pie-semi-circle",
|
|
@@ -148,7 +158,7 @@ var PieSemiCircleChartInternal = ({
|
|
|
148
158
|
const startAngle = clockwise ? -Math.PI / 2 : Math.PI / 2;
|
|
149
159
|
const endAngle = clockwise ? Math.PI / 2 : -Math.PI / 2;
|
|
150
160
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
151
|
-
|
|
161
|
+
_chunkNRVZS2ICcjs.SingleChartContext.Provider,
|
|
152
162
|
{
|
|
153
163
|
value: {
|
|
154
164
|
chartId,
|
|
@@ -158,6 +168,7 @@ var PieSemiCircleChartInternal = ({
|
|
|
158
168
|
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
159
169
|
"div",
|
|
160
170
|
{
|
|
171
|
+
ref: containerRef,
|
|
161
172
|
className: _clsx2.default.call(void 0, "pie-semi-circle-chart", pie_semi_circle_chart_module_default["pie-semi-circle-chart"], className),
|
|
162
173
|
"data-testid": "pie-chart-container",
|
|
163
174
|
style: {
|
|
@@ -189,8 +200,8 @@ var PieSemiCircleChartInternal = ({
|
|
|
189
200
|
return pie.arcs.map((arc) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
190
201
|
"g",
|
|
191
202
|
{
|
|
192
|
-
onMouseMove: handleArcMouseMove(arc),
|
|
193
|
-
onMouseLeave: handleMouseLeave,
|
|
203
|
+
onMouseMove: withTooltips ? handleArcMouseMove(arc) : void 0,
|
|
204
|
+
onMouseLeave: withTooltips ? handleMouseLeave : void 0,
|
|
194
205
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
195
206
|
"path",
|
|
196
207
|
{
|
|
@@ -231,26 +242,16 @@ var PieSemiCircleChartInternal = ({
|
|
|
231
242
|
] })
|
|
232
243
|
}
|
|
233
244
|
),
|
|
234
|
-
withTooltips && tooltipOpen && tooltipData && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
235
|
-
_chunkH43FBWWZcjs.BaseTooltip,
|
|
236
|
-
{
|
|
237
|
-
data: {
|
|
238
|
-
label: tooltipData.label,
|
|
239
|
-
value: tooltipData.value,
|
|
240
|
-
valueDisplay: tooltipData.valueDisplay
|
|
241
|
-
},
|
|
242
|
-
top: tooltipTop || 0,
|
|
243
|
-
left: tooltipLeft || 0
|
|
244
|
-
}
|
|
245
|
-
),
|
|
245
|
+
withTooltips && tooltipOpen && tooltipData && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipInPortal, { top: tooltipTop || 0, left: tooltipLeft || 0, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { role: "tooltip", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk6GO5PFYLcjs.BaseTooltip, { data: tooltipData, top: 0, left: 0, renderContainer: false }) }) }),
|
|
246
246
|
showLegend && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
247
|
-
|
|
247
|
+
_chunkNRVZS2ICcjs.Legend,
|
|
248
248
|
{
|
|
249
249
|
orientation: legendOrientation,
|
|
250
250
|
position: legendPosition,
|
|
251
251
|
alignment: legendAlignment,
|
|
252
252
|
maxWidth: legendMaxWidth,
|
|
253
253
|
textOverflow: legendTextOverflow,
|
|
254
|
+
legendItemClassName,
|
|
254
255
|
shape: legendShape,
|
|
255
256
|
ref: legendRef,
|
|
256
257
|
chartId
|
|
@@ -265,22 +266,22 @@ var PieSemiCircleChartInternal = ({
|
|
|
265
266
|
);
|
|
266
267
|
};
|
|
267
268
|
var PieSemiCircleChartWithProvider = (props) => {
|
|
268
|
-
const existingContext = _react.useContext.call(void 0,
|
|
269
|
+
const existingContext = _react.useContext.call(void 0, _chunkRTUQVBUJcjs.GlobalChartsContext);
|
|
269
270
|
if (existingContext) {
|
|
270
271
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PieSemiCircleChartInternal, { ...props });
|
|
271
272
|
}
|
|
272
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
273
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRTUQVBUJcjs.GlobalChartsProvider, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PieSemiCircleChartInternal, { ...props }) });
|
|
273
274
|
};
|
|
274
275
|
PieSemiCircleChartWithProvider.displayName = "PieSemiCircleChart";
|
|
275
|
-
var PieSemiCircleChart =
|
|
276
|
-
Legend:
|
|
276
|
+
var PieSemiCircleChart = _chunkRTUQVBUJcjs.attachSubComponents.call(void 0, PieSemiCircleChartWithProvider, {
|
|
277
|
+
Legend: _chunkNRVZS2ICcjs.Legend,
|
|
277
278
|
SVG: _chunk3Z526IL2cjs.ChartSVG,
|
|
278
279
|
HTML: _chunk3Z526IL2cjs.ChartHTML
|
|
279
280
|
});
|
|
280
|
-
var PieSemiCircleChartResponsive =
|
|
281
|
+
var PieSemiCircleChartResponsive = _chunkRTUQVBUJcjs.attachSubComponents.call(void 0,
|
|
281
282
|
_chunkFX2PTUFCcjs.withResponsive.call(void 0, PieSemiCircleChartWithProvider),
|
|
282
283
|
{
|
|
283
|
-
Legend:
|
|
284
|
+
Legend: _chunkNRVZS2ICcjs.Legend,
|
|
284
285
|
SVG: _chunk3Z526IL2cjs.ChartSVG,
|
|
285
286
|
HTML: _chunk3Z526IL2cjs.ChartHTML
|
|
286
287
|
}
|
|
@@ -290,4 +291,4 @@ var PieSemiCircleChartResponsive = _chunkM4OSG2EScjs.attachSubComponents.call(vo
|
|
|
290
291
|
|
|
291
292
|
|
|
292
293
|
exports.PieSemiCircleChart = PieSemiCircleChart; exports.PieSemiCircleChartResponsive = PieSemiCircleChartResponsive;
|
|
293
|
-
//# sourceMappingURL=chunk-
|
|
294
|
+
//# sourceMappingURL=chunk-66JB3JZA.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/jetpack/jetpack/projects/js-packages/charts/dist/chunk-66JB3JZA.cjs","../src/components/pie-semi-circle-chart/pie-semi-circle-chart.tsx","../src/components/pie-semi-circle-chart/pie-semi-circle-chart.module.scss"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;AC1BA,oCAA2B;AA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KE,EAAA;AAGH;AAE6C;AAGG;AAC/C,EAAA;AACK,EAAA;AACC,EAAA;AACL;AAGmC;AACsC,EAAA;AAC1E,EAAA;AACC,IAAA;AACK,IAAA;AACC,IAAA;AACP,EAAA;AACD;ADxHqD;AACA;AACA;AACA;AACA","file":"/home/runner/work/jetpack/jetpack/projects/js-packages/charts/dist/chunk-66JB3JZA.cjs","sourcesContent":[null,"import { localPoint } from '@visx/event';\nimport { Group } from '@visx/group';\nimport { Pie } from '@visx/shape';\nimport { Text } from '@visx/text';\nimport { useTooltip, useTooltipInPortal } from '@visx/tooltip';\nimport clsx from 'clsx';\nimport { useCallback, useContext, useMemo } from 'react';\nimport { useElementHeight } from '../../hooks';\nimport {\n\tGlobalChartsProvider,\n\tuseChartId,\n\tuseChartRegistration,\n\tuseGlobalChartsContext,\n\tGlobalChartsContext,\n} from '../../providers';\nimport { attachSubComponents } from '../../utils';\nimport { Legend, useChartLegendItems } from '../legend';\nimport { ChartSVG, ChartHTML, useChartChildren } from '../private/chart-composition';\nimport { SingleChartContext } from '../private/single-chart-context';\nimport { withResponsive } from '../private/with-responsive';\nimport { BaseTooltip } from '../tooltip';\nimport styles from './pie-semi-circle-chart.module.scss';\nimport type { BaseChartProps, DataPointPercentage, Optional } from '../../types';\nimport type { LegendValueDisplay } from '../legend';\nimport type { ChartComponentWithComposition } from '../private/chart-composition';\nimport type { ResponsiveConfig } from '../private/with-responsive';\nimport type { PieArcDatum } from '@visx/shape/lib/shapes/Pie';\nimport type { FC, MouseEvent, ReactNode } from 'react';\n\nconst PAD_ANGLE = 0.03; // Padding between segments\n\nexport interface PieSemiCircleChartProps extends BaseChartProps< DataPointPercentage[] > {\n\t/**\n\t * Width of the chart in pixels; height would be half of this value calculated automatically.\n\t */\n\twidth?: number;\n\n\t/**\n\t * Thickness of the pie chart. A value between 0 and 1\n\t */\n\tthickness?: number;\n\n\t/**\n\t * Direction of chart rendering\n\t * true for clockwise, false for counter-clockwise\n\t */\n\tclockwise?: boolean;\n\n\t/**\n\t * Label text to display above the chart\n\t */\n\tlabel?: string;\n\n\t/**\n\t * Note text to display below the label\n\t */\n\tnote?: string;\n\n\t/**\n\t * Use the children prop to render additional elements on the chart.\n\t */\n\tchildren?: ReactNode;\n\n\t/**\n\t * What type of value to display in the legend when showValues is true.\n\t * - 'percentage': Shows percentage values (e.g., \"23%\") [default]\n\t * - 'value': Shows raw numeric values (e.g., \"30000\")\n\t * - 'valueDisplay': Shows formatted values (e.g., \"30K\")\n\t * - 'none': Shows no values, only labels\n\t */\n\tlegendValueDisplay?: LegendValueDisplay;\n\n\t/**\n\t * Horizontal offset for tooltip positioning in pixels (default: 0)\n\t */\n\ttooltipOffsetX?: number;\n\n\t/**\n\t * Vertical offset for tooltip positioning in pixels (default: -15)\n\t */\n\ttooltipOffsetY?: number;\n}\n\n// Base props type with optional responsive properties\ntype PieSemiCircleChartBaseProps = Optional< PieSemiCircleChartProps, 'width' >;\n\n// Composition API types\ntype PieSemiCircleChartComponent = ChartComponentWithComposition< PieSemiCircleChartBaseProps >;\ntype PieSemiCircleChartResponsiveComponent = ChartComponentWithComposition<\n\tPieSemiCircleChartBaseProps & ResponsiveConfig\n>;\n\nexport type ArcData = PieArcDatum< DataPointPercentage >;\n\n/**\n * Validates the semi-circle pie chart data\n * @param data - The data to validate\n * @return Object containing validation result and error message\n */\nconst validateData = ( data: DataPointPercentage[] ) => {\n\tif ( ! data.length ) {\n\t\treturn { isValid: false, message: 'No data available' };\n\t}\n\n\t// Check for negative values\n\tconst hasNegativeValues = data.some( item => item.percentage < 0 || item.value < 0 );\n\tif ( hasNegativeValues ) {\n\t\treturn { isValid: false, message: 'Invalid data: Negative values are not allowed' };\n\t}\n\n\t// Validate total percentage is greater than 0\n\tconst totalPercentage = data.reduce( ( sum, item ) => sum + item.percentage, 0 );\n\tif ( totalPercentage <= 0 ) {\n\t\treturn { isValid: false, message: 'Invalid percentage total: Must be greater than 0' };\n\t}\n\n\treturn { isValid: true, message: '' };\n};\n\nconst PieSemiCircleChartInternal: FC< PieSemiCircleChartProps > = ( {\n\tdata,\n\tchartId: providedChartId,\n\twidth = 400,\n\tthickness = 0.4,\n\tclockwise = true,\n\twithTooltips = false,\n\tshowLegend = false,\n\tlegendOrientation = 'horizontal',\n\tlegendPosition = 'bottom',\n\tlegendAlignment = 'center',\n\tlegendMaxWidth,\n\tlegendTextOverflow = 'wrap',\n\tlegendItemClassName,\n\tlegendShape = 'circle',\n\tlegendValueDisplay = 'percentage',\n\tlabel,\n\tnote,\n\tclassName,\n\tchildren,\n\ttooltipOffsetX = 0,\n\ttooltipOffsetY = -15,\n} ) => {\n\tconst chartId = useChartId( providedChartId );\n\tconst [ legendRef, legendHeight ] = useElementHeight< HTMLDivElement >();\n\tconst { tooltipOpen, tooltipLeft, tooltipTop, tooltipData, hideTooltip, showTooltip } =\n\t\tuseTooltip< DataPointPercentage >();\n\n\t// Set up portal tooltip for better z-index handling\n\tconst { containerRef, TooltipInPortal } = useTooltipInPortal( {\n\t\tdetectBounds: true,\n\t\tscroll: true,\n\t\tdebounce: 0,\n\t} );\n\n\tconst handleMouseMove = useCallback(\n\t\t( event: MouseEvent< SVGElement >, arc: ArcData ) => {\n\t\t\t// Get coordinates relative to the current target element\n\t\t\tconst coords = localPoint( event );\n\t\t\tif ( coords ) {\n\t\t\t\t// Account for legend offset when legend is on top\n\t\t\t\tconst legendOffset = showLegend && legendPosition === 'top' ? legendHeight : 0;\n\t\t\t\tshowTooltip( {\n\t\t\t\t\ttooltipData: arc.data,\n\t\t\t\t\ttooltipLeft: coords.x + tooltipOffsetX,\n\t\t\t\t\ttooltipTop: coords.y + legendOffset + tooltipOffsetY,\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ showTooltip, tooltipOffsetX, tooltipOffsetY, showLegend, legendPosition, legendHeight ]\n\t);\n\n\tconst handleMouseLeave = useCallback( () => {\n\t\thideTooltip();\n\t}, [ hideTooltip ] );\n\n\tconst handleArcMouseMove = useCallback(\n\t\t( arc: ArcData ) => ( event: MouseEvent< SVGElement > ) => {\n\t\t\thandleMouseMove( event, arc );\n\t\t},\n\t\t[ handleMouseMove ]\n\t);\n\n\t// Validate data first to get validation result\n\tconst { isValid, message } = validateData( data );\n\n\tconst { getElementStyles } = useGlobalChartsContext();\n\n\t// Define accessors with useMemo to avoid changing dependencies\n\tconst accessors = useMemo(\n\t\t() => ( {\n\t\t\tvalue: ( d: DataPointPercentage ) => d.value,\n\t\t\tsort: (\n\t\t\t\ta: DataPointPercentage & { index: number },\n\t\t\t\tb: DataPointPercentage & { index: number }\n\t\t\t) => b.value - a.value,\n\t\t\tfill: ( d: DataPointPercentage & { index: number } ) =>\n\t\t\t\tgetElementStyles( { data: d, index: d.index } ).color,\n\t\t} ),\n\t\t[ getElementStyles ]\n\t);\n\n\t// Memoize legend options to prevent unnecessary re-calculations\n\tconst legendOptions = useMemo(\n\t\t() => ( { showValues: true, legendValueDisplay } ),\n\t\t[ legendValueDisplay ]\n\t);\n\n\t// Create legend items using the reusable hook\n\tconst legendItems = useChartLegendItems( data, legendOptions );\n\n\t// Process children to extract compound components\n\tconst { svgChildren, htmlChildren, otherChildren } = useChartChildren(\n\t\tchildren,\n\t\t'PieSemiCircleChart'\n\t);\n\n\t// Memoize metadata to prevent unnecessary re-registration\n\tconst chartMetadata = useMemo(\n\t\t() => ( {\n\t\t\tthickness,\n\t\t\tclockwise,\n\t\t} ),\n\t\t[ thickness, clockwise ]\n\t);\n\n\t// Register chart with context only if data is valid\n\tuseChartRegistration( {\n\t\tchartId,\n\t\tlegendItems,\n\t\tchartType: 'pie-semi-circle',\n\t\tisDataValid: isValid,\n\t\tmetadata: chartMetadata,\n\t} );\n\n\tif ( ! isValid ) {\n\t\treturn (\n\t\t\t<div className={ styles[ 'pie-semi-circle-chart' ] }>\n\t\t\t\t<svg width={ width } height={ width / 2 } data-testid=\"pie-chart-svg\">\n\t\t\t\t\t<text x=\"50%\" y=\"50%\" textAnchor=\"middle\" className={ styles.error }>\n\t\t\t\t\t\t{ message }\n\t\t\t\t\t</text>\n\t\t\t\t</svg>\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Calculate chart dimensions\n\t// TODO: we might want to accept height as a prop in the future, because the height of container might not always be enough.\n\tconst height = width / 2;\n\t// The chart only takes the height minus the legend height.\n\tconst chartHeight = height - ( showLegend && legendPosition === 'top' ? legendHeight : 0 );\n\tconst radius = Math.min( width / 2, chartHeight );\n\tconst innerRadius = radius * ( 1 - thickness );\n\n\t// Map data with index for color assignment\n\tconst dataWithIndex = data.map( ( d, index ) => ( {\n\t\t...d,\n\t\tindex,\n\t} ) );\n\n\t// Configure pie angles based on clockwise direction\n\tconst startAngle = clockwise ? -Math.PI / 2 : Math.PI / 2;\n\tconst endAngle = clockwise ? Math.PI / 2 : -Math.PI / 2;\n\n\treturn (\n\t\t<SingleChartContext.Provider\n\t\t\tvalue={ {\n\t\t\t\tchartId,\n\t\t\t\tchartWidth: width,\n\t\t\t\tchartHeight: radius,\n\t\t\t} }\n\t\t>\n\t\t\t<div\n\t\t\t\tref={ containerRef }\n\t\t\t\tclassName={ clsx( 'pie-semi-circle-chart', styles[ 'pie-semi-circle-chart' ], className ) }\n\t\t\t\tdata-testid=\"pie-chart-container\"\n\t\t\t\tstyle={ {\n\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\tflexDirection: showLegend && legendPosition === 'top' ? 'column-reverse' : 'column',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\twidth={ width }\n\t\t\t\t\theight={ radius }\n\t\t\t\t\tviewBox={ `0 0 ${ width } ${ chartHeight }` }\n\t\t\t\t\tdata-testid=\"pie-chart-svg\"\n\t\t\t\t>\n\t\t\t\t\t{ /* Main chart group centered horizontally and positioned at bottom */ }\n\t\t\t\t\t<Group top={ chartHeight } left={ width / 2 }>\n\t\t\t\t\t\t{ /* Pie chart */ }\n\t\t\t\t\t\t<Pie< DataPointPercentage & { index: number } >\n\t\t\t\t\t\t\tdata={ dataWithIndex }\n\t\t\t\t\t\t\tpieValue={ accessors.value }\n\t\t\t\t\t\t\touterRadius={ radius }\n\t\t\t\t\t\t\tinnerRadius={ innerRadius }\n\t\t\t\t\t\t\tcornerRadius={ 3 }\n\t\t\t\t\t\t\tpadAngle={ PAD_ANGLE }\n\t\t\t\t\t\t\tstartAngle={ startAngle }\n\t\t\t\t\t\t\tendAngle={ endAngle }\n\t\t\t\t\t\t\tpieSort={ accessors.sort }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ pie => {\n\t\t\t\t\t\t\t\treturn pie.arcs.map( arc => (\n\t\t\t\t\t\t\t\t\t<g\n\t\t\t\t\t\t\t\t\t\tkey={ arc.data.label }\n\t\t\t\t\t\t\t\t\t\tonMouseMove={ withTooltips ? handleArcMouseMove( arc ) : undefined }\n\t\t\t\t\t\t\t\t\t\tonMouseLeave={ withTooltips ? handleMouseLeave : undefined }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<path\n\t\t\t\t\t\t\t\t\t\t\td={ pie.path( arc ) || '' }\n\t\t\t\t\t\t\t\t\t\t\tfill={ accessors.fill( arc.data ) }\n\t\t\t\t\t\t\t\t\t\t\tdata-testid=\"pie-segment\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</g>\n\t\t\t\t\t\t\t\t) );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t</Pie>\n\n\t\t\t\t\t\t{ /* Label and note text */ }\n\t\t\t\t\t\t<Group>\n\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\ttextAnchor=\"middle\"\n\t\t\t\t\t\t\t\tverticalAnchor=\"start\"\n\t\t\t\t\t\t\t\ty={ -40 } // Position above the chart with space for note\n\t\t\t\t\t\t\t\tclassName={ styles.label }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\ttextAnchor=\"middle\"\n\t\t\t\t\t\t\t\tverticalAnchor=\"start\"\n\t\t\t\t\t\t\t\ty={ -20 } // Position between label and chart\n\t\t\t\t\t\t\t\tclassName={ styles.note }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ note }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</Group>\n\n\t\t\t\t\t\t{ /* Render SVG children from composition API */ }\n\t\t\t\t\t\t{ svgChildren }\n\t\t\t\t\t</Group>\n\t\t\t\t</svg>\n\n\t\t\t\t{ withTooltips && tooltipOpen && tooltipData && (\n\t\t\t\t\t<TooltipInPortal top={ tooltipTop || 0 } left={ tooltipLeft || 0 }>\n\t\t\t\t\t\t<div role=\"tooltip\">\n\t\t\t\t\t\t\t<BaseTooltip data={ tooltipData } top={ 0 } left={ 0 } renderContainer={ false } />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</TooltipInPortal>\n\t\t\t\t) }\n\n\t\t\t\t{ showLegend && (\n\t\t\t\t\t<Legend\n\t\t\t\t\t\torientation={ legendOrientation }\n\t\t\t\t\t\tposition={ legendPosition }\n\t\t\t\t\t\talignment={ legendAlignment }\n\t\t\t\t\t\tmaxWidth={ legendMaxWidth }\n\t\t\t\t\t\ttextOverflow={ legendTextOverflow }\n\t\t\t\t\t\tlegendItemClassName={ legendItemClassName }\n\t\t\t\t\t\tshape={ legendShape }\n\t\t\t\t\t\tref={ legendRef }\n\t\t\t\t\t\tchartId={ chartId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ /* Render HTML children from composition API */ }\n\t\t\t\t{ htmlChildren }\n\n\t\t\t\t{ /* Render any other children that aren't compound components */ }\n\t\t\t\t{ otherChildren }\n\t\t\t</div>\n\t\t</SingleChartContext.Provider>\n\t);\n};\n\nconst PieSemiCircleChartWithProvider: FC< PieSemiCircleChartProps > = props => {\n\tconst existingContext = useContext( GlobalChartsContext );\n\n\t// If we're already in a GlobalChartsProvider context, don't create a new one\n\tif ( existingContext ) {\n\t\treturn <PieSemiCircleChartInternal { ...props } />;\n\t}\n\n\t// Otherwise, create our own GlobalChartsProvider\n\treturn (\n\t\t<GlobalChartsProvider>\n\t\t\t<PieSemiCircleChartInternal { ...props } />\n\t\t</GlobalChartsProvider>\n\t);\n};\n\nPieSemiCircleChartWithProvider.displayName = 'PieSemiCircleChart';\n\n// Create PieSemiCircleChart with composition API\nconst PieSemiCircleChart = attachSubComponents( PieSemiCircleChartWithProvider, {\n\tLegend: Legend,\n\tSVG: ChartSVG,\n\tHTML: ChartHTML,\n} ) as PieSemiCircleChartComponent;\n\n// Create responsive PieSemiCircleChart with composition API\nconst PieSemiCircleChartResponsive = attachSubComponents(\n\twithResponsive< PieSemiCircleChartProps >( PieSemiCircleChartWithProvider ),\n\t{\n\t\tLegend: Legend,\n\t\tSVG: ChartSVG,\n\t\tHTML: ChartHTML,\n\t}\n) as PieSemiCircleChartResponsiveComponent;\n\nexport {\n\tPieSemiCircleChartResponsive as default,\n\tPieSemiCircleChart as PieSemiCircleChartUnresponsive,\n};\n","import 'css-chunk:src/components/pie-semi-circle-chart/pie-semi-circle-chart.module.scss';export default {\n \"pie-semi-circle-chart\": \"a8ccharts-r5jk9c\",\n \"label\": \"a8ccharts-nPqOgD\",\n \"note\": \"a8ccharts-LpBZQh\"\n};"]}
|