@aura-react-comp/charts 0.2.0 → 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.
Files changed (98) hide show
  1. package/esm/charts/area-chart/index.d.ts +2 -2
  2. package/esm/charts/area-chart/index.js +28 -23
  3. package/esm/charts/bar-chart/index.d.ts +1 -1
  4. package/esm/charts/bar-chart/index.js +18 -21
  5. package/esm/charts/candlestick-chart/index.d.ts +2 -2
  6. package/esm/charts/candlestick-chart/index.js +243 -180
  7. package/esm/charts/combo-chart/index.d.ts +1 -1
  8. package/esm/charts/combo-chart/index.js +9 -20
  9. package/esm/charts/funnel-chart/index.d.ts +2 -2
  10. package/esm/charts/funnel-chart/index.js +134 -108
  11. package/esm/charts/gauge-chart/index.d.ts +1 -1
  12. package/esm/charts/gauge-chart/index.js +103 -105
  13. package/esm/charts/graph-chart/index.d.ts +3 -3
  14. package/esm/charts/graph-chart/index.js +155 -114
  15. package/esm/charts/heatmap-chart/index.d.ts +2 -2
  16. package/esm/charts/heatmap-chart/index.js +180 -135
  17. package/esm/charts/line-chart/index.d.ts +2 -2
  18. package/esm/charts/line-chart/index.js +29 -24
  19. package/esm/charts/pie-chart/index.d.ts +2 -2
  20. package/esm/charts/pie-chart/index.d.ts.map +1 -1
  21. package/esm/charts/pie-chart/index.js +199 -139
  22. package/esm/charts/radar-chart/index.d.ts +2 -2
  23. package/esm/charts/radar-chart/index.d.ts.map +1 -1
  24. package/esm/charts/radar-chart/index.js +155 -128
  25. package/esm/charts/ring-progress/index.d.ts +1 -1
  26. package/esm/charts/ring-progress/index.js +82 -82
  27. package/esm/charts/sankey-chart/index.d.ts +3 -3
  28. package/esm/charts/sankey-chart/index.js +172 -141
  29. package/esm/charts/scatter-chart/index.d.ts +3 -3
  30. package/esm/charts/scatter-chart/index.d.ts.map +1 -1
  31. package/esm/charts/scatter-chart/index.js +226 -159
  32. package/esm/charts/sparkline/index.d.ts +1 -1
  33. package/esm/charts/sparkline/index.js +82 -66
  34. package/esm/charts/tree-chart/index.d.ts +3 -3
  35. package/esm/charts/tree-chart/index.js +129 -102
  36. package/esm/charts/treemap-chart/index.d.ts +3 -3
  37. package/esm/charts/treemap-chart/index.js +163 -141
  38. package/esm/charts/waterfall-chart/index.d.ts +2 -2
  39. package/esm/charts/waterfall-chart/index.js +166 -121
  40. package/esm/components/Legend.d.ts +5 -4
  41. package/esm/components/Legend.d.ts.map +1 -1
  42. package/esm/components/Legend.js +80 -48
  43. package/esm/components/Tooltip.d.ts +2 -2
  44. package/esm/components/Tooltip.js +63 -71
  45. package/esm/components/chart/index.d.ts +5 -2
  46. package/esm/components/chart/index.d.ts.map +1 -1
  47. package/esm/components/chart/index.js +81 -102
  48. package/esm/components/chart.less +13 -0
  49. package/esm/core/animation.js +32 -43
  50. package/esm/core/export.d.ts +34 -0
  51. package/esm/core/export.d.ts.map +1 -0
  52. package/esm/core/export.js +390 -0
  53. package/esm/core/force.js +23 -45
  54. package/esm/core/format.js +49 -52
  55. package/esm/core/hierarchy.d.ts +1 -1
  56. package/esm/core/hierarchy.js +61 -92
  57. package/esm/core/layout.d.ts +1 -1
  58. package/esm/core/layout.js +33 -50
  59. package/esm/core/sampling.js +31 -53
  60. package/esm/core/sankey.js +36 -55
  61. package/esm/core/scale.js +73 -86
  62. package/esm/core/shape.js +102 -133
  63. package/esm/core/sync.d.ts +41 -0
  64. package/esm/core/sync.d.ts.map +1 -0
  65. package/esm/core/sync.js +120 -0
  66. package/esm/hooks/useChartExport.d.ts +19 -0
  67. package/esm/hooks/useChartExport.d.ts.map +1 -0
  68. package/esm/hooks/useChartExport.js +35 -0
  69. package/esm/hooks/useChartTheme.d.ts +6 -5
  70. package/esm/hooks/useChartTheme.d.ts.map +1 -1
  71. package/esm/hooks/useChartTheme.js +18 -18
  72. package/esm/hooks/useChartTransition.d.ts +1 -1
  73. package/esm/hooks/useChartTransition.js +59 -73
  74. package/esm/hooks/useElementSize.js +20 -28
  75. package/esm/hooks/usePlotPointer.d.ts +23 -0
  76. package/esm/hooks/usePlotPointer.d.ts.map +1 -0
  77. package/esm/hooks/usePlotPointer.js +94 -0
  78. package/esm/index.d.ts +56 -50
  79. package/esm/index.d.ts.map +1 -1
  80. package/esm/index.js +137 -47
  81. package/esm/internal/CartesianChart.d.ts +1 -1
  82. package/esm/internal/CartesianChart.d.ts.map +1 -1
  83. package/esm/internal/CartesianChart.js +667 -485
  84. package/esm/internal/model.d.ts +2 -2
  85. package/esm/internal/model.js +45 -60
  86. package/esm/scene/canvas.d.ts +1 -1
  87. package/esm/scene/canvas.js +101 -107
  88. package/esm/scene/svg.d.ts +1 -1
  89. package/esm/scene/svg.js +107 -99
  90. package/esm/scene/types.js +9 -15
  91. package/esm/style.css +10 -0
  92. package/esm/theme/index.d.ts +2 -2
  93. package/esm/theme/index.d.ts.map +1 -1
  94. package/esm/theme/index.js +145 -170
  95. package/esm/types.d.ts +7 -3
  96. package/esm/types.d.ts.map +1 -1
  97. package/esm/types.js +1 -1
  98. package/package.json +2 -2
@@ -1,26 +1,21 @@
1
- import React, { useCallback, useMemo, useState } from 'react';
2
- import { classNames, prefixCls } from '@aura-react-comp/shared';
1
+ 'use client';
2
+ // src/charts/pie-chart/index.tsx
3
+ import { useCallback, useMemo, useState } from "react";
4
+ import { classNames, prefixCls } from "@aura-react-comp/shared";
3
5
  import { SvgScene } from "../../scene/svg";
4
6
  import { arcPath } from "../../core/shape";
5
7
  import { formatPercent } from "../../core/format";
6
8
  import { useChartTheme } from "../../hooks/useChartTheme";
7
9
  import { useElementSize } from "../../hooks/useElementSize";
8
10
  import { useChartTransition } from "../../hooks/useChartTransition";
11
+ import { usePlotPointer } from "../../hooks/usePlotPointer";
9
12
  import { resolveAnimation, staggerProgress } from "../../core/animation";
10
13
  import { Legend } from "../../components/Legend";
11
14
  import { Tooltip } from "../../components/Tooltip";
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import { Fragment as _Fragment } from "react/jsx-runtime";
14
- import { jsxs as _jsxs } from "react/jsx-runtime";
15
- /**
16
- * 饼图 / 环形图。
17
- *
18
- * 交互命中不用 DOM 事件绑定在每个扇形上,而是把鼠标坐标换算成极坐标角度后
19
- * 反查所属扇区 —— 这样 SVG 与 Canvas 两种渲染方式可以共用同一套交互逻辑。
20
- */
21
- export function PieChart({
15
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
16
+ function PieChart({
22
17
  data = [],
23
- width = '100%',
18
+ width = "100%",
24
19
  height = 320,
25
20
  theme: themeInput,
26
21
  palette,
@@ -28,30 +23,41 @@ export function PieChart({
28
23
  tooltip = true,
29
24
  innerRadius = 0.6,
30
25
  padAngle = 0.01,
31
- label = 'outside',
26
+ label = "outside",
32
27
  centerContent,
33
28
  animation = true,
34
29
  className,
35
30
  style,
36
31
  ariaLabel,
37
- emptyText = '暂无数据'
32
+ emptyText = "暂无数据"
38
33
  }) {
39
34
  const theme = useChartTheme(themeInput, palette);
40
- const {
41
- ref,
42
- size
43
- } = useElementSize();
35
+ const { ref, size } = useElementSize();
44
36
  const [hiddenKeys, setHiddenKeys] = useState([]);
45
37
  const [activeIndex, setActiveIndex] = useState(null);
46
- const visibleData = useMemo(() => data.filter(item => !hiddenKeys.includes(item.name)), [data, hiddenKeys]);
47
- const total = useMemo(() => visibleData.reduce((sum, item) => sum + (Number.isFinite(item.value) ? item.value : 0), 0), [visibleData]);
48
- const animKey = typeof animation === 'object' ? JSON.stringify(animation) : String(animation);
49
- const animConfig = useMemo(() => resolveAnimation(animation),
50
- // eslint-disable-next-line react-hooks/exhaustive-deps
51
- [animKey]);
52
-
53
- // 用插值后的数值重算角度:数据更新时扇区会平滑重排,而不是整块重画
54
- const valueMatrix = useMemo(() => [visibleData.map(item => Number.isFinite(item.value) ? item.value : 0)], [visibleData]);
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
+ );
55
61
  const transition = useChartTransition(valueMatrix, animConfig);
56
62
  const progress = transition.progress;
57
63
  const animatedValues = transition.values[0] ?? valueMatrix[0];
@@ -75,7 +81,10 @@ export function PieChart({
75
81
  });
76
82
  }, [visibleData, animatedValues, animatedTotal, theme.palette]);
77
83
  const geometry = useMemo(() => {
78
- const outer = Math.max(0, Math.min(size.width, size.height) / 2 - (label === 'outside' ? 36 : 14));
84
+ const outer = Math.max(
85
+ 0,
86
+ Math.min(size.width, size.height) / 2 - (label === "outside" ? 36 : 14)
87
+ );
79
88
  const inner = outer * Math.max(0, Math.min(0.92, innerRadius));
80
89
  return {
81
90
  cx: size.width / 2,
@@ -84,42 +93,55 @@ export function PieChart({
84
93
  inner
85
94
  };
86
95
  }, [size.width, size.height, label, innerRadius]);
96
+ const hasCenterContent = centerContent !== void 0 && centerContent !== null;
87
97
  const scene = useMemo(() => {
88
- if (!slices.length || geometry.outer <= 0) return [];
98
+ if (!slices.length || geometry.outer <= 0)
99
+ return [];
89
100
  const nodes = [];
90
101
  for (const slice of slices) {
91
- // 扇区错峰展开:从 12 点方向顺时针依次扫出,比整块同时膨胀自然
92
- const local = staggerProgress(progress, slice.index, slices.length, animConfig.stagger);
102
+ const local = staggerProgress(
103
+ progress,
104
+ slice.index,
105
+ slices.length,
106
+ animConfig.stagger
107
+ );
93
108
  const end = slice.startAngle + (slice.endAngle - slice.startAngle) * local;
94
109
  const isActive = activeIndex === slice.index;
95
110
  const gap = slices.length > 1 ? padAngle / 2 : 0;
96
111
  const outer = isActive ? geometry.outer + 3 : geometry.outer;
97
112
  nodes.push({
98
- kind: 'path',
113
+ kind: "path",
99
114
  key: `slice-${slice.name}`,
100
- d: arcPath(geometry.cx, geometry.cy, geometry.inner, outer, slice.startAngle + gap, Math.max(slice.startAngle + gap, end - gap)),
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
+ ),
101
123
  fill: slice.color,
102
124
  opacity: activeIndex === null || isActive ? 1 : 0.55,
103
- pointerEvents: 'none'
125
+ pointerEvents: "none"
104
126
  });
105
- if (label === 'inside' && slice.percent >= 0.05) {
127
+ if (label === "inside" && slice.percent >= 0.05) {
106
128
  const mid = (slice.startAngle + end) / 2;
107
129
  const radius = (geometry.inner + outer) / 2;
108
130
  nodes.push({
109
- kind: 'text',
131
+ kind: "text",
110
132
  key: `inside-${slice.name}`,
111
133
  x: geometry.cx + Math.cos(mid) * radius,
112
134
  y: geometry.cy + Math.sin(mid) * radius,
113
135
  text: formatPercent(slice.percent, 1, 0),
114
- fill: '#fff',
136
+ fill: "#fff",
115
137
  fontSize: theme.font.size,
116
138
  fontWeight: theme.font.weightMedium,
117
- anchor: 'middle',
118
- baseline: 'middle',
139
+ anchor: "middle",
140
+ baseline: "middle",
119
141
  opacity: progress
120
142
  });
121
143
  }
122
- if (label === 'outside' && progress > 0.6 && slice.percent > 0.02) {
144
+ if (label === "outside" && progress > 0.6 && slice.percent > 0.02) {
123
145
  const mid = (slice.startAngle + end) / 2;
124
146
  const anchorX = geometry.cx + Math.cos(mid) * (outer + 8);
125
147
  const anchorY = geometry.cy + Math.sin(mid) * (outer + 8);
@@ -129,85 +151,104 @@ export function PieChart({
129
151
  const textX = elbowX + (isRight ? 8 : -8);
130
152
  const textY = elbowY + (Math.sin(mid) > 0.4 ? 4 : Math.sin(mid) < -0.4 ? -2 : 0);
131
153
  nodes.push({
132
- kind: 'path',
154
+ kind: "path",
133
155
  key: `leader-${slice.name}`,
134
156
  d: `M${anchorX},${anchorY}L${elbowX},${elbowY}L${textX},${textY}`,
135
- fill: 'none',
157
+ fill: "none",
136
158
  stroke: theme.axis.line,
137
159
  strokeWidth: 1,
138
- pointerEvents: 'none'
160
+ pointerEvents: "none"
139
161
  });
140
162
  nodes.push({
141
- kind: 'text',
163
+ kind: "text",
142
164
  key: `outside-${slice.name}`,
143
165
  x: textX + (isRight ? 2 : -2),
144
166
  y: textY,
145
167
  text: `${slice.name} ${formatPercent(slice.percent, 1, 1)}`,
146
168
  fill: isActive ? theme.text.primary : theme.text.secondary,
147
169
  fontSize: theme.font.size,
148
- anchor: isRight ? 'start' : 'end',
149
- baseline: 'middle',
170
+ anchor: isRight ? "start" : "end",
171
+ baseline: "middle",
150
172
  fontWeight: isActive ? theme.font.weightMedium : theme.font.weightNormal
151
173
  });
152
174
  }
153
175
  }
154
- if (geometry.inner > 0) {
155
- const active = activeIndex !== null ? slices[activeIndex] : null;
176
+ if (geometry.inner > 0 && !hasCenterContent) {
177
+ const active2 = activeIndex !== null ? slices[activeIndex] : null;
156
178
  nodes.push({
157
- kind: 'text',
158
- key: 'center-main',
179
+ kind: "text",
180
+ key: "center-main",
159
181
  x: geometry.cx,
160
- y: geometry.cy - (active ? 6 : 0),
161
- text: active ? String(Math.round(active.value)) : String(Math.round(animatedTotal)),
182
+ y: geometry.cy - (active2 ? 6 : 0),
183
+ text: active2 ? String(Math.round(active2.value)) : String(Math.round(animatedTotal)),
162
184
  fill: theme.text.primary,
163
- fontSize: active ? 20 : 22,
185
+ fontSize: active2 ? 20 : 22,
164
186
  fontWeight: theme.font.weightMedium,
165
- anchor: 'middle',
166
- baseline: 'middle'
187
+ anchor: "middle",
188
+ baseline: "middle"
167
189
  });
168
190
  nodes.push({
169
- kind: 'text',
170
- key: 'center-sub',
191
+ kind: "text",
192
+ key: "center-sub",
171
193
  x: geometry.cx,
172
194
  y: geometry.cy + 18,
173
- text: active ? `${active.name} · ${formatPercent(active.percent, 1, 1)}` : '总计',
195
+ text: active2 ? `${active2.name} · ${formatPercent(active2.percent, 1, 1)}` : "总计",
174
196
  fill: theme.text.secondary,
175
197
  fontSize: theme.font.sizeSmall,
176
- anchor: 'middle',
177
- baseline: 'middle'
198
+ anchor: "middle",
199
+ baseline: "middle"
178
200
  });
179
201
  }
180
202
  return nodes;
181
- }, [slices, geometry, progress, activeIndex, label, padAngle, theme, animatedTotal, animConfig.stagger]);
182
-
183
- /** 指针 → 扇区索引 */
184
- const indexFromPointer = useCallback((clientX, clientY) => {
185
- const element = ref.current;
186
- if (!element || !slices.length) return null;
187
- const rect = element.getBoundingClientRect();
188
- const dx = clientX - rect.left - geometry.cx;
189
- const dy = clientY - rect.top - geometry.cy;
190
- const radius = Math.hypot(dx, dy);
191
- if (radius < geometry.inner || radius > geometry.outer + 6) return null;
192
- let angle = Math.atan2(dy, dx);
193
- const start = -Math.PI / 2;
194
- // 归一化到 [start, start + 2π)
195
- while (angle < start) angle += Math.PI * 2;
196
- while (angle >= start + Math.PI * 2) angle -= Math.PI * 2;
197
- const hit = slices.find(slice => angle >= slice.startAngle && angle < slice.endAngle);
198
- return hit ? hit.index : null;
199
- }, [ref, slices, geometry]);
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
+ );
200
239
  const active = activeIndex !== null ? slices[activeIndex] : null;
201
240
  const tooltipPayload = active ? {
202
241
  label: active.name,
203
242
  row: null,
204
- series: [{
205
- key: active.name,
206
- name: active.name,
207
- color: active.color,
208
- value: active.value,
209
- formatted: `${active.value}(${formatPercent(active.percent, 1, 1)})`
210
- }]
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
+ ]
211
252
  } : null;
212
253
  const legendItems = data.map((item, index) => ({
213
254
  key: item.name,
@@ -215,57 +256,76 @@ export function PieChart({
215
256
  color: item.color ?? theme.palette[index % theme.palette.length],
216
257
  visible: !hiddenKeys.includes(item.name)
217
258
  }));
218
- const toggle = useCallback(key => {
219
- setHiddenKeys(prev => prev.includes(key) ? prev.filter(item => item !== key) : [...prev, key]);
259
+ const toggle = useCallback((key) => {
260
+ setHiddenKeys(
261
+ (prev) => prev.includes(key) ? prev.filter((item) => item !== key) : [...prev, key]
262
+ );
220
263
  }, []);
221
- const autoAriaLabel = ariaLabel ?? '饼图';
222
- return /*#__PURE__*/_jsxs("div", {
223
- className: classNames(prefixCls('chart'), className),
224
- style: {
225
- width,
226
- height,
227
- ...style
228
- },
229
- "data-aura-chart": "pie",
230
- children: [/*#__PURE__*/_jsx(Legend, {
231
- items: legendItems,
232
- theme: theme,
233
- config: legend,
234
- onToggle: toggle
235
- }), /*#__PURE__*/_jsxs("div", {
236
- ref: ref,
237
- className: prefixCls('chart__plot'),
238
- onPointerMove: event => setActiveIndex(indexFromPointer(event.clientX, event.clientY)),
239
- onPointerLeave: () => setActiveIndex(null),
240
- children: [slices.length === 0 || total <= 0 ? /*#__PURE__*/_jsx("div", {
241
- className: prefixCls('chart__empty'),
242
- children: emptyText
243
- }) : /*#__PURE__*/_jsxs(_Fragment, {
244
- children: [/*#__PURE__*/_jsx(SvgScene, {
245
- nodes: scene,
246
- width: size.width,
247
- height: size.height,
248
- ariaLabel: autoAriaLabel
249
- }), centerContent && geometry.inner > 0 ? /*#__PURE__*/_jsx("div", {
250
- style: {
251
- position: 'absolute',
252
- inset: 0,
253
- display: 'flex',
254
- alignItems: 'center',
255
- justifyContent: 'center',
256
- pointerEvents: 'none'
257
- },
258
- children: centerContent
259
- }) : null]
260
- }), /*#__PURE__*/_jsx(Tooltip, {
261
- payload: tooltipPayload,
262
- x: geometry.cx,
263
- y: activeIndex !== null ? geometry.cy - geometry.outer * 0.5 : 0,
264
- containerWidth: size.width,
265
- containerHeight: size.height,
266
- theme: theme,
267
- config: tooltip
268
- })]
269
- })]
264
+ const pointerHandlers = usePlotPointer({
265
+ disabled: tooltip === false || slices.length === 0,
266
+ onMove: (clientX, clientY) => setActiveIndex(indexFromPointer(clientX, clientY)),
267
+ onLeave: () => setActiveIndex(null)
270
268
  });
271
- }
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,6 +1,6 @@
1
1
  import React from 'react';
2
- import { type ChartThemeInput } from '../../theme';
3
- import type { LegendConfig, TooltipConfig } from '../../types';
2
+ import { type ChartThemeInput } from '../../theme/index.js';
3
+ import type { LegendConfig, TooltipConfig } from '../../types.js';
4
4
  export interface RadarIndicator {
5
5
  /** 指标名,显示在顶点外侧 */
6
6
  name: string;
@@ -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;AAO9D,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;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