@aura-react-comp/charts 0.3.1 → 0.4.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/esm/charts/area-chart/index.js +27 -23
- package/esm/charts/bar-chart/index.js +17 -21
- package/esm/charts/candlestick-chart/index.js +242 -180
- package/esm/charts/combo-chart/index.js +8 -20
- package/esm/charts/funnel-chart/index.js +133 -108
- package/esm/charts/gauge-chart/index.js +102 -105
- package/esm/charts/graph-chart/index.js +154 -114
- package/esm/charts/heatmap-chart/index.js +179 -135
- package/esm/charts/line-chart/index.js +28 -24
- package/esm/charts/pie-chart/index.d.ts.map +1 -1
- package/esm/charts/pie-chart/index.js +198 -139
- package/esm/charts/radar-chart/index.d.ts.map +1 -1
- package/esm/charts/radar-chart/index.js +154 -128
- package/esm/charts/ring-progress/index.js +81 -82
- package/esm/charts/sankey-chart/index.js +171 -141
- package/esm/charts/scatter-chart/index.d.ts.map +1 -1
- package/esm/charts/scatter-chart/index.js +225 -159
- package/esm/charts/sparkline/index.js +81 -66
- package/esm/charts/tree-chart/index.js +128 -102
- package/esm/charts/treemap-chart/index.js +162 -141
- package/esm/charts/waterfall-chart/index.js +165 -121
- package/esm/components/Legend.d.ts +3 -2
- package/esm/components/Legend.d.ts.map +1 -1
- package/esm/components/Legend.js +79 -48
- package/esm/components/Tooltip.js +62 -71
- package/esm/components/chart/index.d.ts +4 -1
- package/esm/components/chart/index.d.ts.map +1 -1
- package/esm/components/chart/index.js +80 -102
- package/esm/components/chart.less +13 -0
- package/esm/core/animation.js +31 -43
- package/esm/core/export.d.ts +34 -0
- package/esm/core/export.d.ts.map +1 -0
- package/esm/core/export.js +390 -0
- package/esm/core/force.js +22 -45
- package/esm/core/format.js +48 -52
- package/esm/core/hierarchy.js +60 -92
- package/esm/core/layout.js +32 -50
- package/esm/core/sampling.js +30 -53
- package/esm/core/sankey.js +35 -55
- package/esm/core/scale.js +72 -86
- package/esm/core/shape.js +101 -133
- package/esm/core/sync.d.ts +41 -0
- package/esm/core/sync.d.ts.map +1 -0
- package/esm/core/sync.js +120 -0
- package/esm/hooks/useChartExport.d.ts +19 -0
- package/esm/hooks/useChartExport.d.ts.map +1 -0
- package/esm/hooks/useChartExport.js +35 -0
- package/esm/hooks/useChartTheme.js +17 -19
- package/esm/hooks/useChartTransition.js +58 -73
- package/esm/hooks/useElementSize.js +19 -28
- package/esm/hooks/usePlotPointer.d.ts +23 -0
- package/esm/hooks/usePlotPointer.d.ts.map +1 -0
- package/esm/hooks/usePlotPointer.js +94 -0
- package/esm/index.d.ts +6 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +136 -47
- package/esm/internal/CartesianChart.d.ts.map +1 -1
- package/esm/internal/CartesianChart.js +666 -485
- package/esm/internal/model.js +44 -60
- package/esm/scene/canvas.js +100 -107
- package/esm/scene/svg.js +106 -99
- package/esm/scene/types.js +8 -15
- package/esm/style.css +10 -0
- package/esm/theme/index.js +143 -171
- package/esm/types.d.ts +4 -0
- package/esm/types.d.ts.map +1 -1
- package/esm/types.js +0 -1
- package/package.json +1 -1
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
2
|
+
// src/charts/pie-chart/index.tsx
|
|
3
|
+
import { useCallback, useMemo, useState } from "react";
|
|
4
|
+
import { classNames, prefixCls } from "@aura-react-comp/shared";
|
|
4
5
|
import { SvgScene } from "../../scene/svg";
|
|
5
6
|
import { arcPath } from "../../core/shape";
|
|
6
7
|
import { formatPercent } from "../../core/format";
|
|
7
8
|
import { useChartTheme } from "../../hooks/useChartTheme";
|
|
8
9
|
import { useElementSize } from "../../hooks/useElementSize";
|
|
9
10
|
import { useChartTransition } from "../../hooks/useChartTransition";
|
|
11
|
+
import { usePlotPointer } from "../../hooks/usePlotPointer";
|
|
10
12
|
import { resolveAnimation, staggerProgress } from "../../core/animation";
|
|
11
13
|
import { Legend } from "../../components/Legend";
|
|
12
14
|
import { Tooltip } from "../../components/Tooltip";
|
|
13
|
-
import { jsx
|
|
14
|
-
|
|
15
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
-
/**
|
|
17
|
-
* 饼图 / 环形图。
|
|
18
|
-
*
|
|
19
|
-
* 交互命中不用 DOM 事件绑定在每个扇形上,而是把鼠标坐标换算成极坐标角度后
|
|
20
|
-
* 反查所属扇区 —— 这样 SVG 与 Canvas 两种渲染方式可以共用同一套交互逻辑。
|
|
21
|
-
*/
|
|
22
|
-
export function PieChart({
|
|
15
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
+
function PieChart({
|
|
23
17
|
data = [],
|
|
24
|
-
width =
|
|
18
|
+
width = "100%",
|
|
25
19
|
height = 320,
|
|
26
20
|
theme: themeInput,
|
|
27
21
|
palette,
|
|
@@ -29,30 +23,41 @@ export function PieChart({
|
|
|
29
23
|
tooltip = true,
|
|
30
24
|
innerRadius = 0.6,
|
|
31
25
|
padAngle = 0.01,
|
|
32
|
-
label =
|
|
26
|
+
label = "outside",
|
|
33
27
|
centerContent,
|
|
34
28
|
animation = true,
|
|
35
29
|
className,
|
|
36
30
|
style,
|
|
37
31
|
ariaLabel,
|
|
38
|
-
emptyText =
|
|
32
|
+
emptyText = "暂无数据"
|
|
39
33
|
}) {
|
|
40
34
|
const theme = useChartTheme(themeInput, palette);
|
|
41
|
-
const {
|
|
42
|
-
ref,
|
|
43
|
-
size
|
|
44
|
-
} = useElementSize();
|
|
35
|
+
const { ref, size } = useElementSize();
|
|
45
36
|
const [hiddenKeys, setHiddenKeys] = useState([]);
|
|
46
37
|
const [activeIndex, setActiveIndex] = useState(null);
|
|
47
|
-
const visibleData = useMemo(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
38
|
+
const visibleData = useMemo(
|
|
39
|
+
() => data.filter((item) => !hiddenKeys.includes(item.name)),
|
|
40
|
+
[data, hiddenKeys]
|
|
41
|
+
);
|
|
42
|
+
const total = useMemo(
|
|
43
|
+
() => visibleData.reduce(
|
|
44
|
+
(sum, item) => sum + (Number.isFinite(item.value) ? item.value : 0),
|
|
45
|
+
0
|
|
46
|
+
),
|
|
47
|
+
[visibleData]
|
|
48
|
+
);
|
|
49
|
+
const animKey = typeof animation === "object" ? JSON.stringify(animation) : String(animation);
|
|
50
|
+
const animConfig = useMemo(
|
|
51
|
+
() => resolveAnimation(animation),
|
|
52
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
53
|
+
[animKey]
|
|
54
|
+
);
|
|
55
|
+
const valueMatrix = useMemo(
|
|
56
|
+
() => [
|
|
57
|
+
visibleData.map((item) => Number.isFinite(item.value) ? item.value : 0)
|
|
58
|
+
],
|
|
59
|
+
[visibleData]
|
|
60
|
+
);
|
|
56
61
|
const transition = useChartTransition(valueMatrix, animConfig);
|
|
57
62
|
const progress = transition.progress;
|
|
58
63
|
const animatedValues = transition.values[0] ?? valueMatrix[0];
|
|
@@ -76,7 +81,10 @@ export function PieChart({
|
|
|
76
81
|
});
|
|
77
82
|
}, [visibleData, animatedValues, animatedTotal, theme.palette]);
|
|
78
83
|
const geometry = useMemo(() => {
|
|
79
|
-
const outer = Math.max(
|
|
84
|
+
const outer = Math.max(
|
|
85
|
+
0,
|
|
86
|
+
Math.min(size.width, size.height) / 2 - (label === "outside" ? 36 : 14)
|
|
87
|
+
);
|
|
80
88
|
const inner = outer * Math.max(0, Math.min(0.92, innerRadius));
|
|
81
89
|
return {
|
|
82
90
|
cx: size.width / 2,
|
|
@@ -85,42 +93,55 @@ export function PieChart({
|
|
|
85
93
|
inner
|
|
86
94
|
};
|
|
87
95
|
}, [size.width, size.height, label, innerRadius]);
|
|
96
|
+
const hasCenterContent = centerContent !== void 0 && centerContent !== null;
|
|
88
97
|
const scene = useMemo(() => {
|
|
89
|
-
if (!slices.length || geometry.outer <= 0)
|
|
98
|
+
if (!slices.length || geometry.outer <= 0)
|
|
99
|
+
return [];
|
|
90
100
|
const nodes = [];
|
|
91
101
|
for (const slice of slices) {
|
|
92
|
-
|
|
93
|
-
|
|
102
|
+
const local = staggerProgress(
|
|
103
|
+
progress,
|
|
104
|
+
slice.index,
|
|
105
|
+
slices.length,
|
|
106
|
+
animConfig.stagger
|
|
107
|
+
);
|
|
94
108
|
const end = slice.startAngle + (slice.endAngle - slice.startAngle) * local;
|
|
95
109
|
const isActive = activeIndex === slice.index;
|
|
96
110
|
const gap = slices.length > 1 ? padAngle / 2 : 0;
|
|
97
111
|
const outer = isActive ? geometry.outer + 3 : geometry.outer;
|
|
98
112
|
nodes.push({
|
|
99
|
-
kind:
|
|
113
|
+
kind: "path",
|
|
100
114
|
key: `slice-${slice.name}`,
|
|
101
|
-
d: arcPath(
|
|
115
|
+
d: arcPath(
|
|
116
|
+
geometry.cx,
|
|
117
|
+
geometry.cy,
|
|
118
|
+
geometry.inner,
|
|
119
|
+
outer,
|
|
120
|
+
slice.startAngle + gap,
|
|
121
|
+
Math.max(slice.startAngle + gap, end - gap)
|
|
122
|
+
),
|
|
102
123
|
fill: slice.color,
|
|
103
124
|
opacity: activeIndex === null || isActive ? 1 : 0.55,
|
|
104
|
-
pointerEvents:
|
|
125
|
+
pointerEvents: "none"
|
|
105
126
|
});
|
|
106
|
-
if (label ===
|
|
127
|
+
if (label === "inside" && slice.percent >= 0.05) {
|
|
107
128
|
const mid = (slice.startAngle + end) / 2;
|
|
108
129
|
const radius = (geometry.inner + outer) / 2;
|
|
109
130
|
nodes.push({
|
|
110
|
-
kind:
|
|
131
|
+
kind: "text",
|
|
111
132
|
key: `inside-${slice.name}`,
|
|
112
133
|
x: geometry.cx + Math.cos(mid) * radius,
|
|
113
134
|
y: geometry.cy + Math.sin(mid) * radius,
|
|
114
135
|
text: formatPercent(slice.percent, 1, 0),
|
|
115
|
-
fill:
|
|
136
|
+
fill: "#fff",
|
|
116
137
|
fontSize: theme.font.size,
|
|
117
138
|
fontWeight: theme.font.weightMedium,
|
|
118
|
-
anchor:
|
|
119
|
-
baseline:
|
|
139
|
+
anchor: "middle",
|
|
140
|
+
baseline: "middle",
|
|
120
141
|
opacity: progress
|
|
121
142
|
});
|
|
122
143
|
}
|
|
123
|
-
if (label ===
|
|
144
|
+
if (label === "outside" && progress > 0.6 && slice.percent > 0.02) {
|
|
124
145
|
const mid = (slice.startAngle + end) / 2;
|
|
125
146
|
const anchorX = geometry.cx + Math.cos(mid) * (outer + 8);
|
|
126
147
|
const anchorY = geometry.cy + Math.sin(mid) * (outer + 8);
|
|
@@ -130,85 +151,104 @@ export function PieChart({
|
|
|
130
151
|
const textX = elbowX + (isRight ? 8 : -8);
|
|
131
152
|
const textY = elbowY + (Math.sin(mid) > 0.4 ? 4 : Math.sin(mid) < -0.4 ? -2 : 0);
|
|
132
153
|
nodes.push({
|
|
133
|
-
kind:
|
|
154
|
+
kind: "path",
|
|
134
155
|
key: `leader-${slice.name}`,
|
|
135
156
|
d: `M${anchorX},${anchorY}L${elbowX},${elbowY}L${textX},${textY}`,
|
|
136
|
-
fill:
|
|
157
|
+
fill: "none",
|
|
137
158
|
stroke: theme.axis.line,
|
|
138
159
|
strokeWidth: 1,
|
|
139
|
-
pointerEvents:
|
|
160
|
+
pointerEvents: "none"
|
|
140
161
|
});
|
|
141
162
|
nodes.push({
|
|
142
|
-
kind:
|
|
163
|
+
kind: "text",
|
|
143
164
|
key: `outside-${slice.name}`,
|
|
144
165
|
x: textX + (isRight ? 2 : -2),
|
|
145
166
|
y: textY,
|
|
146
167
|
text: `${slice.name} ${formatPercent(slice.percent, 1, 1)}`,
|
|
147
168
|
fill: isActive ? theme.text.primary : theme.text.secondary,
|
|
148
169
|
fontSize: theme.font.size,
|
|
149
|
-
anchor: isRight ?
|
|
150
|
-
baseline:
|
|
170
|
+
anchor: isRight ? "start" : "end",
|
|
171
|
+
baseline: "middle",
|
|
151
172
|
fontWeight: isActive ? theme.font.weightMedium : theme.font.weightNormal
|
|
152
173
|
});
|
|
153
174
|
}
|
|
154
175
|
}
|
|
155
|
-
if (geometry.inner > 0) {
|
|
156
|
-
const
|
|
176
|
+
if (geometry.inner > 0 && !hasCenterContent) {
|
|
177
|
+
const active2 = activeIndex !== null ? slices[activeIndex] : null;
|
|
157
178
|
nodes.push({
|
|
158
|
-
kind:
|
|
159
|
-
key:
|
|
179
|
+
kind: "text",
|
|
180
|
+
key: "center-main",
|
|
160
181
|
x: geometry.cx,
|
|
161
|
-
y: geometry.cy - (
|
|
162
|
-
text:
|
|
182
|
+
y: geometry.cy - (active2 ? 6 : 0),
|
|
183
|
+
text: active2 ? String(Math.round(active2.value)) : String(Math.round(animatedTotal)),
|
|
163
184
|
fill: theme.text.primary,
|
|
164
|
-
fontSize:
|
|
185
|
+
fontSize: active2 ? 20 : 22,
|
|
165
186
|
fontWeight: theme.font.weightMedium,
|
|
166
|
-
anchor:
|
|
167
|
-
baseline:
|
|
187
|
+
anchor: "middle",
|
|
188
|
+
baseline: "middle"
|
|
168
189
|
});
|
|
169
190
|
nodes.push({
|
|
170
|
-
kind:
|
|
171
|
-
key:
|
|
191
|
+
kind: "text",
|
|
192
|
+
key: "center-sub",
|
|
172
193
|
x: geometry.cx,
|
|
173
194
|
y: geometry.cy + 18,
|
|
174
|
-
text:
|
|
195
|
+
text: active2 ? `${active2.name} · ${formatPercent(active2.percent, 1, 1)}` : "总计",
|
|
175
196
|
fill: theme.text.secondary,
|
|
176
197
|
fontSize: theme.font.sizeSmall,
|
|
177
|
-
anchor:
|
|
178
|
-
baseline:
|
|
198
|
+
anchor: "middle",
|
|
199
|
+
baseline: "middle"
|
|
179
200
|
});
|
|
180
201
|
}
|
|
181
202
|
return nodes;
|
|
182
|
-
}, [
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
203
|
+
}, [
|
|
204
|
+
slices,
|
|
205
|
+
geometry,
|
|
206
|
+
progress,
|
|
207
|
+
activeIndex,
|
|
208
|
+
label,
|
|
209
|
+
padAngle,
|
|
210
|
+
theme,
|
|
211
|
+
animatedTotal,
|
|
212
|
+
animConfig.stagger,
|
|
213
|
+
hasCenterContent
|
|
214
|
+
]);
|
|
215
|
+
const indexFromPointer = useCallback(
|
|
216
|
+
(clientX, clientY) => {
|
|
217
|
+
const element = ref.current;
|
|
218
|
+
if (!element || !slices.length)
|
|
219
|
+
return null;
|
|
220
|
+
const rect = element.getBoundingClientRect();
|
|
221
|
+
const dx = clientX - rect.left - geometry.cx;
|
|
222
|
+
const dy = clientY - rect.top - geometry.cy;
|
|
223
|
+
const radius = Math.hypot(dx, dy);
|
|
224
|
+
if (radius < geometry.inner || radius > geometry.outer + 6)
|
|
225
|
+
return null;
|
|
226
|
+
let angle = Math.atan2(dy, dx);
|
|
227
|
+
const start = -Math.PI / 2;
|
|
228
|
+
while (angle < start)
|
|
229
|
+
angle += Math.PI * 2;
|
|
230
|
+
while (angle >= start + Math.PI * 2)
|
|
231
|
+
angle -= Math.PI * 2;
|
|
232
|
+
const hit = slices.find(
|
|
233
|
+
(slice) => angle >= slice.startAngle && angle < slice.endAngle
|
|
234
|
+
);
|
|
235
|
+
return hit ? hit.index : null;
|
|
236
|
+
},
|
|
237
|
+
[ref, slices, geometry]
|
|
238
|
+
);
|
|
201
239
|
const active = activeIndex !== null ? slices[activeIndex] : null;
|
|
202
240
|
const tooltipPayload = active ? {
|
|
203
241
|
label: active.name,
|
|
204
242
|
row: null,
|
|
205
|
-
series: [
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
243
|
+
series: [
|
|
244
|
+
{
|
|
245
|
+
key: active.name,
|
|
246
|
+
name: active.name,
|
|
247
|
+
color: active.color,
|
|
248
|
+
value: active.value,
|
|
249
|
+
formatted: `${active.value}(${formatPercent(active.percent, 1, 1)})`
|
|
250
|
+
}
|
|
251
|
+
]
|
|
212
252
|
} : null;
|
|
213
253
|
const legendItems = data.map((item, index) => ({
|
|
214
254
|
key: item.name,
|
|
@@ -216,57 +256,76 @@ export function PieChart({
|
|
|
216
256
|
color: item.color ?? theme.palette[index % theme.palette.length],
|
|
217
257
|
visible: !hiddenKeys.includes(item.name)
|
|
218
258
|
}));
|
|
219
|
-
const toggle = useCallback(key => {
|
|
220
|
-
setHiddenKeys(
|
|
259
|
+
const toggle = useCallback((key) => {
|
|
260
|
+
setHiddenKeys(
|
|
261
|
+
(prev) => prev.includes(key) ? prev.filter((item) => item !== key) : [...prev, key]
|
|
262
|
+
);
|
|
221
263
|
}, []);
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
width,
|
|
227
|
-
height,
|
|
228
|
-
...style
|
|
229
|
-
},
|
|
230
|
-
"data-aura-chart": "pie",
|
|
231
|
-
children: [/*#__PURE__*/_jsx(Legend, {
|
|
232
|
-
items: legendItems,
|
|
233
|
-
theme: theme,
|
|
234
|
-
config: legend,
|
|
235
|
-
onToggle: toggle
|
|
236
|
-
}), /*#__PURE__*/_jsxs("div", {
|
|
237
|
-
ref: ref,
|
|
238
|
-
className: prefixCls('chart__plot'),
|
|
239
|
-
onPointerMove: event => setActiveIndex(indexFromPointer(event.clientX, event.clientY)),
|
|
240
|
-
onPointerLeave: () => setActiveIndex(null),
|
|
241
|
-
children: [slices.length === 0 || total <= 0 ? /*#__PURE__*/_jsx("div", {
|
|
242
|
-
className: prefixCls('chart__empty'),
|
|
243
|
-
children: emptyText
|
|
244
|
-
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
245
|
-
children: [/*#__PURE__*/_jsx(SvgScene, {
|
|
246
|
-
nodes: scene,
|
|
247
|
-
width: size.width,
|
|
248
|
-
height: size.height,
|
|
249
|
-
ariaLabel: autoAriaLabel
|
|
250
|
-
}), centerContent && geometry.inner > 0 ? /*#__PURE__*/_jsx("div", {
|
|
251
|
-
style: {
|
|
252
|
-
position: 'absolute',
|
|
253
|
-
inset: 0,
|
|
254
|
-
display: 'flex',
|
|
255
|
-
alignItems: 'center',
|
|
256
|
-
justifyContent: 'center',
|
|
257
|
-
pointerEvents: 'none'
|
|
258
|
-
},
|
|
259
|
-
children: centerContent
|
|
260
|
-
}) : null]
|
|
261
|
-
}), /*#__PURE__*/_jsx(Tooltip, {
|
|
262
|
-
payload: tooltipPayload,
|
|
263
|
-
x: geometry.cx,
|
|
264
|
-
y: activeIndex !== null ? geometry.cy - geometry.outer * 0.5 : 0,
|
|
265
|
-
containerWidth: size.width,
|
|
266
|
-
containerHeight: size.height,
|
|
267
|
-
theme: theme,
|
|
268
|
-
config: tooltip
|
|
269
|
-
})]
|
|
270
|
-
})]
|
|
264
|
+
const pointerHandlers = usePlotPointer({
|
|
265
|
+
disabled: tooltip === false || slices.length === 0,
|
|
266
|
+
onMove: (clientX, clientY) => setActiveIndex(indexFromPointer(clientX, clientY)),
|
|
267
|
+
onLeave: () => setActiveIndex(null)
|
|
271
268
|
});
|
|
272
|
-
|
|
269
|
+
const autoAriaLabel = ariaLabel ?? "饼图";
|
|
270
|
+
return /* @__PURE__ */ jsxs(
|
|
271
|
+
"div",
|
|
272
|
+
{
|
|
273
|
+
className: classNames(prefixCls("chart"), className),
|
|
274
|
+
style: { width, height, ...style },
|
|
275
|
+
"data-aura-chart": "pie",
|
|
276
|
+
children: [
|
|
277
|
+
/* @__PURE__ */ jsx(
|
|
278
|
+
Legend,
|
|
279
|
+
{
|
|
280
|
+
items: legendItems,
|
|
281
|
+
theme,
|
|
282
|
+
config: legend,
|
|
283
|
+
onToggle: toggle
|
|
284
|
+
}
|
|
285
|
+
),
|
|
286
|
+
/* @__PURE__ */ jsxs("div", { ref, className: prefixCls("chart__plot"), ...pointerHandlers, children: [
|
|
287
|
+
slices.length === 0 || total <= 0 ? /* @__PURE__ */ jsx("div", { className: prefixCls("chart__empty"), children: emptyText }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
288
|
+
/* @__PURE__ */ jsx(
|
|
289
|
+
SvgScene,
|
|
290
|
+
{
|
|
291
|
+
nodes: scene,
|
|
292
|
+
width: size.width,
|
|
293
|
+
height: size.height,
|
|
294
|
+
ariaLabel: autoAriaLabel
|
|
295
|
+
}
|
|
296
|
+
),
|
|
297
|
+
centerContent && geometry.inner > 0 ? /* @__PURE__ */ jsx(
|
|
298
|
+
"div",
|
|
299
|
+
{
|
|
300
|
+
style: {
|
|
301
|
+
position: "absolute",
|
|
302
|
+
inset: 0,
|
|
303
|
+
display: "flex",
|
|
304
|
+
alignItems: "center",
|
|
305
|
+
justifyContent: "center",
|
|
306
|
+
pointerEvents: "none"
|
|
307
|
+
},
|
|
308
|
+
children: centerContent
|
|
309
|
+
}
|
|
310
|
+
) : null
|
|
311
|
+
] }),
|
|
312
|
+
/* @__PURE__ */ jsx(
|
|
313
|
+
Tooltip,
|
|
314
|
+
{
|
|
315
|
+
payload: tooltipPayload,
|
|
316
|
+
x: geometry.cx,
|
|
317
|
+
y: activeIndex !== null ? geometry.cy - geometry.outer * 0.5 : 0,
|
|
318
|
+
containerWidth: size.width,
|
|
319
|
+
containerHeight: size.height,
|
|
320
|
+
theme,
|
|
321
|
+
config: tooltip
|
|
322
|
+
}
|
|
323
|
+
)
|
|
324
|
+
] })
|
|
325
|
+
]
|
|
326
|
+
}
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
export {
|
|
330
|
+
PieChart
|
|
331
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAI9D,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAI9D,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAQ9D,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE/D,OAAO,6BAA6B,CAAC;AAErC,MAAM,WAAW,cAAc;IAC7B,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,GAAG,YAAY,CAAC;IAChC,OAAO,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC;IAClC,kBAAkB;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,EACzB,UAAe,EACf,MAAW,EACX,KAAc,EACd,MAAY,EACZ,KAAK,EAAE,UAAU,EACjB,OAAO,EACP,MAAa,EACb,OAAc,EACd,MAAU,EACV,SAAgB,EAChB,SAAS,EACT,KAAK,EACL,SAAS,EACT,SAAkB,GACnB,EAAE,eAAe,qBA4RjB"}
|