@aura-react-comp/charts 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +90 -2
- package/esm/charts/area-chart/index.d.ts +19 -0
- package/esm/charts/area-chart/index.d.ts.map +1 -0
- package/esm/charts/area-chart/index.js +30 -0
- package/esm/charts/bar-chart/index.d.ts +16 -0
- package/esm/charts/bar-chart/index.d.ts.map +1 -0
- package/esm/charts/bar-chart/index.js +27 -0
- package/esm/charts/candlestick-chart/index.d.ts +47 -0
- package/esm/charts/candlestick-chart/index.d.ts.map +1 -0
- package/esm/charts/candlestick-chart/index.js +346 -0
- package/esm/charts/combo-chart/index.d.ts +17 -0
- package/esm/charts/combo-chart/index.d.ts.map +1 -0
- package/esm/charts/combo-chart/index.js +25 -0
- package/esm/charts/funnel-chart/index.d.ts +35 -0
- package/esm/charts/funnel-chart/index.d.ts.map +1 -0
- package/esm/charts/funnel-chart/index.js +199 -0
- package/esm/charts/gauge-chart/index.d.ts +41 -0
- package/esm/charts/gauge-chart/index.d.ts.map +1 -0
- package/esm/charts/gauge-chart/index.js +216 -0
- package/esm/charts/graph-chart/index.d.ts +35 -0
- package/esm/charts/graph-chart/index.d.ts.map +1 -0
- package/esm/charts/graph-chart/index.js +223 -0
- package/esm/charts/heatmap-chart/index.d.ts +47 -0
- package/esm/charts/heatmap-chart/index.d.ts.map +1 -0
- package/esm/charts/heatmap-chart/index.js +280 -0
- package/esm/charts/line-chart/index.d.ts +23 -0
- package/esm/charts/line-chart/index.d.ts.map +1 -0
- package/esm/charts/line-chart/index.js +32 -0
- package/esm/charts/pie-chart/index.d.ts +38 -0
- package/esm/charts/pie-chart/index.d.ts.map +1 -0
- package/esm/charts/pie-chart/index.js +271 -0
- package/esm/charts/radar-chart/index.d.ts +44 -0
- package/esm/charts/radar-chart/index.d.ts.map +1 -0
- package/esm/charts/radar-chart/index.js +262 -0
- package/esm/charts/ring-progress/index.d.ts +38 -0
- package/esm/charts/ring-progress/index.d.ts.map +1 -0
- package/esm/charts/ring-progress/index.js +136 -0
- package/esm/charts/sankey-chart/index.d.ts +34 -0
- package/esm/charts/sankey-chart/index.d.ts.map +1 -0
- package/esm/charts/sankey-chart/index.js +247 -0
- package/esm/charts/scatter-chart/index.d.ts +34 -0
- package/esm/charts/scatter-chart/index.d.ts.map +1 -0
- package/esm/charts/scatter-chart/index.js +304 -0
- package/esm/charts/sparkline/index.d.ts +31 -0
- package/esm/charts/sparkline/index.d.ts.map +1 -0
- package/esm/charts/sparkline/index.js +151 -0
- package/esm/charts/tree-chart/index.d.ts +34 -0
- package/esm/charts/tree-chart/index.d.ts.map +1 -0
- package/esm/charts/tree-chart/index.js +199 -0
- package/esm/charts/treemap-chart/index.d.ts +35 -0
- package/esm/charts/treemap-chart/index.d.ts.map +1 -0
- package/esm/charts/treemap-chart/index.js +238 -0
- package/esm/charts/waterfall-chart/index.d.ts +41 -0
- package/esm/charts/waterfall-chart/index.d.ts.map +1 -0
- package/esm/charts/waterfall-chart/index.js +280 -0
- package/esm/components/Legend.d.ts +24 -0
- package/esm/components/Legend.d.ts.map +1 -0
- package/esm/components/Legend.js +49 -0
- package/esm/components/Tooltip.d.ts +24 -0
- package/esm/components/Tooltip.d.ts.map +1 -0
- package/esm/components/Tooltip.js +84 -0
- package/esm/components/chart/index.d.ts +71 -0
- package/esm/components/chart/index.d.ts.map +1 -0
- package/esm/components/chart/index.js +141 -0
- package/esm/components/chart.less +223 -0
- package/esm/core/animation.d.ts +49 -0
- package/esm/core/animation.d.ts.map +1 -0
- package/esm/core/animation.js +92 -0
- package/esm/core/force.d.ts +43 -0
- package/esm/core/force.d.ts.map +1 -0
- package/esm/core/force.js +133 -0
- package/esm/core/format.d.ts +34 -0
- package/esm/core/format.d.ts.map +1 -0
- package/esm/core/format.js +80 -0
- package/esm/core/hierarchy.d.ts +77 -0
- package/esm/core/hierarchy.d.ts.map +1 -0
- package/esm/core/hierarchy.js +232 -0
- package/esm/core/layout.d.ts +67 -0
- package/esm/core/layout.d.ts.map +1 -0
- package/esm/core/layout.js +120 -0
- package/esm/core/sampling.d.ts +32 -0
- package/esm/core/sampling.d.ts.map +1 -0
- package/esm/core/sampling.js +123 -0
- package/esm/core/sankey.d.ts +67 -0
- package/esm/core/sankey.d.ts.map +1 -0
- package/esm/core/sankey.js +135 -0
- package/esm/core/scale.d.ts +98 -0
- package/esm/core/scale.d.ts.map +1 -0
- package/esm/core/scale.js +206 -0
- package/esm/core/shape.d.ts +60 -0
- package/esm/core/shape.d.ts.map +1 -0
- package/esm/core/shape.js +245 -0
- package/esm/global.d.ts +6 -0
- package/esm/hooks/useChartTheme.d.ts +10 -0
- package/esm/hooks/useChartTheme.d.ts.map +1 -0
- package/esm/hooks/useChartTheme.js +33 -0
- package/esm/hooks/useChartTransition.d.ts +20 -0
- package/esm/hooks/useChartTransition.d.ts.map +1 -0
- package/esm/hooks/useChartTransition.js +119 -0
- package/esm/hooks/useElementSize.d.ts +17 -0
- package/esm/hooks/useElementSize.d.ts.map +1 -0
- package/esm/hooks/useElementSize.js +46 -0
- package/esm/index.d.ts +62 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +47 -0
- package/esm/internal/CartesianChart.d.ts +16 -0
- package/esm/internal/CartesianChart.d.ts.map +1 -0
- package/esm/internal/CartesianChart.js +810 -0
- package/esm/internal/model.d.ts +67 -0
- package/esm/internal/model.d.ts.map +1 -0
- package/esm/internal/model.js +145 -0
- package/esm/scene/canvas.d.ts +18 -0
- package/esm/scene/canvas.d.ts.map +1 -0
- package/esm/scene/canvas.js +137 -0
- package/esm/scene/svg.d.ts +12 -0
- package/esm/scene/svg.d.ts.map +1 -0
- package/esm/scene/svg.js +115 -0
- package/esm/scene/types.d.ts +89 -0
- package/esm/scene/types.d.ts.map +1 -0
- package/esm/scene/types.js +20 -0
- package/esm/style.css +196 -0
- package/esm/theme/index.d.ts +127 -0
- package/esm/theme/index.d.ts.map +1 -0
- package/esm/theme/index.js +297 -0
- package/esm/types.d.ts +168 -0
- package/esm/types.d.ts.map +1 -0
- package/esm/types.js +1 -0
- package/package.json +64 -3
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import { classNames, prefixCls } from '@aura-react-comp/shared';
|
|
3
|
+
import { SvgScene } from "../../scene/svg";
|
|
4
|
+
import { formatNumber, estimateTextWidth } from "../../core/format";
|
|
5
|
+
import { withAlpha } from "../../theme";
|
|
6
|
+
import { layoutForce } from "../../core/force";
|
|
7
|
+
import { useChartTheme } from "../../hooks/useChartTheme";
|
|
8
|
+
import { useElementSize } from "../../hooks/useElementSize";
|
|
9
|
+
import { useChartTransition } from "../../hooks/useChartTransition";
|
|
10
|
+
import { resolveAnimation, staggerProgress } from "../../core/animation";
|
|
11
|
+
import { Tooltip } from "../../components/Tooltip";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
/**
|
|
15
|
+
* 关系图(力导向)。
|
|
16
|
+
*
|
|
17
|
+
* 节点两两相斥、有连边的相互吸引,最终收敛成「抱团」的形状:
|
|
18
|
+
* 连得紧的聚成一簇,孤立的被推到边缘。这是一种**探索**型图表——
|
|
19
|
+
* 它的价值是让你看到结构,而不是读出精确数值。
|
|
20
|
+
*/
|
|
21
|
+
export function GraphChart({
|
|
22
|
+
nodes = [],
|
|
23
|
+
links = [],
|
|
24
|
+
iterations = 220,
|
|
25
|
+
nodeSize = 7,
|
|
26
|
+
showLabel = true,
|
|
27
|
+
scaleByDegree = true,
|
|
28
|
+
width = '100%',
|
|
29
|
+
height = 380,
|
|
30
|
+
theme: themeInput,
|
|
31
|
+
palette,
|
|
32
|
+
tooltip = true,
|
|
33
|
+
animation = true,
|
|
34
|
+
className,
|
|
35
|
+
style,
|
|
36
|
+
ariaLabel,
|
|
37
|
+
emptyText = '暂无数据'
|
|
38
|
+
}) {
|
|
39
|
+
const theme = useChartTheme(themeInput, palette);
|
|
40
|
+
const {
|
|
41
|
+
ref,
|
|
42
|
+
size
|
|
43
|
+
} = useElementSize();
|
|
44
|
+
const [activeId, setActiveId] = useState(null);
|
|
45
|
+
const animKey = typeof animation === 'object' ? JSON.stringify(animation) : String(animation);
|
|
46
|
+
const animConfig = useMemo(() => resolveAnimation(animation),
|
|
47
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
48
|
+
[animKey]);
|
|
49
|
+
const groups = useMemo(() => {
|
|
50
|
+
const list = [];
|
|
51
|
+
nodes.forEach(node => {
|
|
52
|
+
const group = node.group ?? '__default__';
|
|
53
|
+
if (!list.includes(group)) list.push(group);
|
|
54
|
+
});
|
|
55
|
+
return list;
|
|
56
|
+
}, [nodes]);
|
|
57
|
+
const positions = useMemo(() => {
|
|
58
|
+
if (!nodes.length || size.width <= 0) return [];
|
|
59
|
+
return layoutForce(nodes, links, {
|
|
60
|
+
x: 0,
|
|
61
|
+
y: 0,
|
|
62
|
+
width: size.width,
|
|
63
|
+
height: size.height
|
|
64
|
+
}, {
|
|
65
|
+
iterations,
|
|
66
|
+
radius: nodeSize + 4
|
|
67
|
+
});
|
|
68
|
+
}, [nodes, links, size.width, size.height, iterations, nodeSize]);
|
|
69
|
+
const positionMap = useMemo(() => new Map(positions.map(item => [item.id, item])), [positions]);
|
|
70
|
+
const maxDegree = Math.max(1, ...positions.map(item => item.degree));
|
|
71
|
+
const radiusOf = useCallback(position => {
|
|
72
|
+
if (!scaleByDegree) return nodeSize;
|
|
73
|
+
// 连接越多半径越大,但限制在 2.2 倍以内,避免中心节点吞掉整张图
|
|
74
|
+
return nodeSize * (1 + Math.min(1.2, position.degree / maxDegree) * 1.2);
|
|
75
|
+
}, [scaleByDegree, nodeSize, maxDegree]);
|
|
76
|
+
const colorOf = useCallback(node => {
|
|
77
|
+
const groupIndex = groups.indexOf(node.group ?? '__default__');
|
|
78
|
+
return theme.palette[Math.max(0, groupIndex) % theme.palette.length];
|
|
79
|
+
}, [groups, theme.palette]);
|
|
80
|
+
const degreeMatrix = useMemo(() => [positions.map(item => item.degree)], [positions]);
|
|
81
|
+
const progress = useChartTransition(degreeMatrix, animConfig).progress;
|
|
82
|
+
const neighbors = useMemo(() => {
|
|
83
|
+
const map = new Map();
|
|
84
|
+
for (const link of links) {
|
|
85
|
+
if (!map.has(link.source)) map.set(link.source, new Set());
|
|
86
|
+
if (!map.has(link.target)) map.set(link.target, new Set());
|
|
87
|
+
map.get(link.source).add(link.target);
|
|
88
|
+
map.get(link.target).add(link.source);
|
|
89
|
+
}
|
|
90
|
+
return map;
|
|
91
|
+
}, [links]);
|
|
92
|
+
const scene = useMemo(() => {
|
|
93
|
+
if (!positions.length || size.width <= 0) return [];
|
|
94
|
+
const nodes_ = [];
|
|
95
|
+
|
|
96
|
+
// 边
|
|
97
|
+
links.forEach((link, index) => {
|
|
98
|
+
const from = positionMap.get(link.source);
|
|
99
|
+
const to = positionMap.get(link.target);
|
|
100
|
+
if (!from || !to) return;
|
|
101
|
+
const related = activeId === null || activeId === link.source || activeId === link.target;
|
|
102
|
+
nodes_.push({
|
|
103
|
+
kind: 'line',
|
|
104
|
+
key: `edge-${index}`,
|
|
105
|
+
x1: from.x,
|
|
106
|
+
y1: from.y,
|
|
107
|
+
x2: to.x,
|
|
108
|
+
y2: to.y,
|
|
109
|
+
stroke: related && activeId !== null ? theme.emphasis : withAlpha(theme.axis.line, 0.9),
|
|
110
|
+
strokeWidth: related && activeId !== null ? 1.6 : 1,
|
|
111
|
+
opacity: (related ? 1 : 0.25) * progress,
|
|
112
|
+
pointerEvents: 'none'
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// 节点
|
|
117
|
+
positions.forEach((position, index) => {
|
|
118
|
+
const node = nodes.find(item => item.id === position.id);
|
|
119
|
+
if (!node) return;
|
|
120
|
+
const baseRadius = radiusOf(position);
|
|
121
|
+
const local = staggerProgress(progress, index, positions.length, animConfig.stagger);
|
|
122
|
+
const radius = baseRadius * local;
|
|
123
|
+
const isActive = activeId === position.id;
|
|
124
|
+
const isNeighbor = activeId ? neighbors.get(activeId)?.has(position.id) ?? false : false;
|
|
125
|
+
const dim = activeId !== null && !isActive && !isNeighbor;
|
|
126
|
+
nodes_.push({
|
|
127
|
+
kind: 'circle',
|
|
128
|
+
key: `node-${position.id}`,
|
|
129
|
+
cx: position.x,
|
|
130
|
+
cy: position.y,
|
|
131
|
+
r: Math.max(0.5, radius),
|
|
132
|
+
fill: colorOf(node),
|
|
133
|
+
opacity: dim ? 0.28 : 1,
|
|
134
|
+
stroke: isActive ? theme.text.primary : undefined,
|
|
135
|
+
strokeWidth: isActive ? 2 : 0,
|
|
136
|
+
pointerEvents: 'none'
|
|
137
|
+
});
|
|
138
|
+
if (!showLabel || radius < 4) return;
|
|
139
|
+
const label = node.name ?? node.id;
|
|
140
|
+
// 标签最多占 20% 画布宽度,超了就截断
|
|
141
|
+
const maxWidth = size.width * 0.2;
|
|
142
|
+
const text = estimateTextWidth(label, theme.font.sizeSmall) > maxWidth ? `${label.slice(0, Math.max(2, Math.floor(maxWidth / theme.font.sizeSmall)))}…` : label;
|
|
143
|
+
nodes_.push({
|
|
144
|
+
kind: 'text',
|
|
145
|
+
key: `label-${position.id}`,
|
|
146
|
+
x: position.x,
|
|
147
|
+
y: position.y + radius + theme.font.sizeSmall + 2,
|
|
148
|
+
text,
|
|
149
|
+
fill: theme.text.secondary,
|
|
150
|
+
fontSize: theme.font.sizeSmall,
|
|
151
|
+
anchor: 'middle',
|
|
152
|
+
baseline: 'middle',
|
|
153
|
+
opacity: dim ? 0.3 : local,
|
|
154
|
+
fontFamily: theme.font.family
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
return nodes_;
|
|
158
|
+
}, [positions, links, positionMap, nodes, theme, activeId, neighbors, progress, animConfig.stagger, showLabel, size.width, radiusOf, colorOf]);
|
|
159
|
+
const nodeFromPointer = (clientX, clientY) => {
|
|
160
|
+
const element = ref.current;
|
|
161
|
+
if (!element) return null;
|
|
162
|
+
const rect = element.getBoundingClientRect();
|
|
163
|
+
const x = clientX - rect.left;
|
|
164
|
+
const y = clientY - rect.top;
|
|
165
|
+
let nearest = null;
|
|
166
|
+
let min = Number.POSITIVE_INFINITY;
|
|
167
|
+
for (const position of positions) {
|
|
168
|
+
const distance = Math.hypot(position.x - x, position.y - y);
|
|
169
|
+
const hit = radiusOf(position) + 6;
|
|
170
|
+
if (distance <= hit && distance < min) {
|
|
171
|
+
min = distance;
|
|
172
|
+
nearest = position.id;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return nearest;
|
|
176
|
+
};
|
|
177
|
+
const activeNode = activeId ? nodes.find(node => node.id === activeId) : null;
|
|
178
|
+
const activePosition = activeId ? positionMap.get(activeId) : null;
|
|
179
|
+
const tooltipPayload = activeNode ? {
|
|
180
|
+
label: activeNode.name ?? activeNode.id,
|
|
181
|
+
row: null,
|
|
182
|
+
series: [{
|
|
183
|
+
key: 'degree',
|
|
184
|
+
name: '连接数',
|
|
185
|
+
color: colorOf(activeNode),
|
|
186
|
+
value: activePosition?.degree ?? 0,
|
|
187
|
+
formatted: formatNumber(activePosition?.degree ?? 0)
|
|
188
|
+
}]
|
|
189
|
+
} : null;
|
|
190
|
+
const autoAriaLabel = ariaLabel ?? `关系图:${nodes.length} 个节点,${links.length} 条关系`;
|
|
191
|
+
return /*#__PURE__*/_jsx("div", {
|
|
192
|
+
className: classNames(prefixCls('chart'), className),
|
|
193
|
+
style: {
|
|
194
|
+
width,
|
|
195
|
+
height,
|
|
196
|
+
...style
|
|
197
|
+
},
|
|
198
|
+
"data-aura-chart": "graph",
|
|
199
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
200
|
+
ref: ref,
|
|
201
|
+
className: prefixCls('chart__plot'),
|
|
202
|
+
onPointerMove: event => setActiveId(nodeFromPointer(event.clientX, event.clientY)),
|
|
203
|
+
onPointerLeave: () => setActiveId(null),
|
|
204
|
+
children: [!positions.length || size.width === 0 ? /*#__PURE__*/_jsx("div", {
|
|
205
|
+
className: prefixCls('chart__empty'),
|
|
206
|
+
children: emptyText
|
|
207
|
+
}) : /*#__PURE__*/_jsx(SvgScene, {
|
|
208
|
+
nodes: scene,
|
|
209
|
+
width: size.width,
|
|
210
|
+
height: size.height,
|
|
211
|
+
ariaLabel: autoAriaLabel
|
|
212
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
|
213
|
+
payload: tooltipPayload,
|
|
214
|
+
x: activePosition ? activePosition.x : 0,
|
|
215
|
+
y: activePosition ? activePosition.y - 20 : 0,
|
|
216
|
+
containerWidth: size.width,
|
|
217
|
+
containerHeight: size.height,
|
|
218
|
+
theme: theme,
|
|
219
|
+
config: tooltip
|
|
220
|
+
})]
|
|
221
|
+
})
|
|
222
|
+
});
|
|
223
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ChartThemeInput } from '../../theme';
|
|
3
|
+
import type { ChartAnimationInput, TooltipConfig } from '../../types';
|
|
4
|
+
export interface HeatmapCell {
|
|
5
|
+
/** 横轴分类 */
|
|
6
|
+
x: string;
|
|
7
|
+
/** 纵轴分类 */
|
|
8
|
+
y: string;
|
|
9
|
+
/** 该格数值;缺失时传 null,会渲染为空格 */
|
|
10
|
+
value: number | null;
|
|
11
|
+
}
|
|
12
|
+
export interface HeatmapChartProps {
|
|
13
|
+
data?: HeatmapCell[];
|
|
14
|
+
/** 显式指定横轴顺序;不传则按数据出现顺序 */
|
|
15
|
+
xLabels?: string[];
|
|
16
|
+
/** 显式指定纵轴顺序;不传则按数据出现顺序 */
|
|
17
|
+
yLabels?: string[];
|
|
18
|
+
/** 色阶:从低到高的两端颜色,缺省用主题强调色的浅→深 */
|
|
19
|
+
colorRange?: [string, string];
|
|
20
|
+
/** 是否在格子内显示数值 */
|
|
21
|
+
showValue?: boolean | 'auto';
|
|
22
|
+
/** 格子间隙(像素) */
|
|
23
|
+
cellGap?: number;
|
|
24
|
+
/** 格子圆角 */
|
|
25
|
+
cellRadius?: number;
|
|
26
|
+
width?: number | string;
|
|
27
|
+
height?: number;
|
|
28
|
+
theme?: ChartThemeInput;
|
|
29
|
+
palette?: string[];
|
|
30
|
+
tooltip?: boolean | TooltipConfig;
|
|
31
|
+
animation?: ChartAnimationInput;
|
|
32
|
+
className?: string;
|
|
33
|
+
style?: React.CSSProperties;
|
|
34
|
+
ariaLabel?: string;
|
|
35
|
+
emptyText?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 热力图。
|
|
39
|
+
*
|
|
40
|
+
* 用颜色深浅编码二维矩阵里的数值,密度远高于逐格标数字,
|
|
41
|
+
* 适合「一眼看出哪块热」——访问时段分布、地域 × 品类销量、相关性矩阵。
|
|
42
|
+
*
|
|
43
|
+
* 注意:颜色编码的精度低于长度/位置(这是视觉感知的固有限制),
|
|
44
|
+
* 需要读出准确数值时必须配合 tooltip 或数字。
|
|
45
|
+
*/
|
|
46
|
+
export declare function HeatmapChart({ data, xLabels: xLabelsProp, yLabels: yLabelsProp, colorRange, showValue, cellGap, cellRadius, width, height, theme: themeInput, palette, tooltip, animation, className, style, ariaLabel, emptyText, }: HeatmapChartProps): React.JSX.Element;
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAO9D,OAAO,EAAuB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAMxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,6BAA6B,CAAC;AAErC,MAAM,WAAW,WAAW;IAC1B,WAAW;IACX,CAAC,EAAE,MAAM,CAAC;IACV,WAAW;IACX,CAAC,EAAE,MAAM,CAAC;IACV,4BAA4B;IAC5B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,WAAW,EAAE,CAAC;IACrB,0BAA0B;IAC1B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,0BAA0B;IAC1B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,gCAAgC;IAChC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,iBAAiB;IACjB,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC7B,eAAe;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,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,OAAO,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC;IAClC,SAAS,CAAC,EAAE,mBAAmB,CAAC;IAChC,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;AAQD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,EAC3B,IAAS,EACT,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,WAAW,EACpB,UAAU,EACV,SAAkB,EAClB,OAAW,EACX,UAAc,EACd,KAAc,EACd,MAAY,EACZ,KAAK,EAAE,UAAU,EACjB,OAAO,EACP,OAAc,EACd,SAAgB,EAChB,SAAS,EACT,KAAK,EACL,SAAS,EACT,SAAkB,GACnB,EAAE,iBAAiB,qBAiUnB"}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import { classNames, prefixCls } from '@aura-react-comp/shared';
|
|
3
|
+
import { SvgScene } from "../../scene/svg";
|
|
4
|
+
import { createBandScale } from "../../core/scale";
|
|
5
|
+
import { formatNumber, estimateTextWidth } from "../../core/format";
|
|
6
|
+
import { roundedRectPath } from "../../core/shape";
|
|
7
|
+
import { mixColor, withAlpha } from "../../theme";
|
|
8
|
+
import { useChartTheme } from "../../hooks/useChartTheme";
|
|
9
|
+
import { useElementSize } from "../../hooks/useElementSize";
|
|
10
|
+
import { useChartTransition } from "../../hooks/useChartTransition";
|
|
11
|
+
import { resolveAnimation, staggerProgress } from "../../core/animation";
|
|
12
|
+
import { Tooltip } from "../../components/Tooltip";
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
/** 把数值映射到 0~1 的位置;全等值时统一给 0.6,避免整片同色看不清边界 */
|
|
16
|
+
function normalize(value, min, max) {
|
|
17
|
+
if (max === min) return 0.6;
|
|
18
|
+
return (value - min) / (max - min);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 热力图。
|
|
23
|
+
*
|
|
24
|
+
* 用颜色深浅编码二维矩阵里的数值,密度远高于逐格标数字,
|
|
25
|
+
* 适合「一眼看出哪块热」——访问时段分布、地域 × 品类销量、相关性矩阵。
|
|
26
|
+
*
|
|
27
|
+
* 注意:颜色编码的精度低于长度/位置(这是视觉感知的固有限制),
|
|
28
|
+
* 需要读出准确数值时必须配合 tooltip 或数字。
|
|
29
|
+
*/
|
|
30
|
+
export function HeatmapChart({
|
|
31
|
+
data = [],
|
|
32
|
+
xLabels: xLabelsProp,
|
|
33
|
+
yLabels: yLabelsProp,
|
|
34
|
+
colorRange,
|
|
35
|
+
showValue = 'auto',
|
|
36
|
+
cellGap = 3,
|
|
37
|
+
cellRadius = 3,
|
|
38
|
+
width = '100%',
|
|
39
|
+
height = 320,
|
|
40
|
+
theme: themeInput,
|
|
41
|
+
palette,
|
|
42
|
+
tooltip = true,
|
|
43
|
+
animation = true,
|
|
44
|
+
className,
|
|
45
|
+
style,
|
|
46
|
+
ariaLabel,
|
|
47
|
+
emptyText = '暂无数据'
|
|
48
|
+
}) {
|
|
49
|
+
const theme = useChartTheme(themeInput, palette);
|
|
50
|
+
const {
|
|
51
|
+
ref,
|
|
52
|
+
size
|
|
53
|
+
} = useElementSize();
|
|
54
|
+
const [activeCell, setActiveCell] = useState(null);
|
|
55
|
+
const animKey = typeof animation === 'object' ? JSON.stringify(animation) : String(animation);
|
|
56
|
+
const animConfig = useMemo(() => resolveAnimation(animation),
|
|
57
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
58
|
+
[animKey]);
|
|
59
|
+
const {
|
|
60
|
+
xLabels,
|
|
61
|
+
yLabels,
|
|
62
|
+
lookup,
|
|
63
|
+
range
|
|
64
|
+
} = useMemo(() => {
|
|
65
|
+
const xs = xLabelsProp?.length ? xLabelsProp : [];
|
|
66
|
+
const ys = yLabelsProp?.length ? yLabelsProp : [];
|
|
67
|
+
if (!xs.length) {
|
|
68
|
+
for (const cell of data) if (!xs.includes(cell.x)) xs.push(cell.x);
|
|
69
|
+
}
|
|
70
|
+
if (!ys.length) {
|
|
71
|
+
for (const cell of data) if (!ys.includes(cell.y)) ys.push(cell.y);
|
|
72
|
+
}
|
|
73
|
+
const map = new Map();
|
|
74
|
+
let min = Number.POSITIVE_INFINITY;
|
|
75
|
+
let max = Number.NEGATIVE_INFINITY;
|
|
76
|
+
for (const cell of data) {
|
|
77
|
+
map.set(`${cell.x}__${cell.y}`, cell.value);
|
|
78
|
+
if (cell.value !== null && Number.isFinite(cell.value)) {
|
|
79
|
+
min = Math.min(min, cell.value);
|
|
80
|
+
max = Math.max(max, cell.value);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
xLabels: xs,
|
|
85
|
+
yLabels: ys,
|
|
86
|
+
lookup: map,
|
|
87
|
+
range: [Number.isFinite(min) ? min : 0, Number.isFinite(max) ? max : 1]
|
|
88
|
+
};
|
|
89
|
+
}, [data, xLabelsProp, yLabelsProp]);
|
|
90
|
+
|
|
91
|
+
// 用数值矩阵驱动动画:更新时颜色平滑过渡
|
|
92
|
+
const matrix = useMemo(() => yLabels.map(y => xLabels.map(x => {
|
|
93
|
+
const value = lookup.get(`${x}__${y}`);
|
|
94
|
+
return value === undefined ? null : value;
|
|
95
|
+
})), [xLabels, yLabels, lookup]);
|
|
96
|
+
const transition = useChartTransition(matrix, animConfig);
|
|
97
|
+
const progress = transition.progress;
|
|
98
|
+
const geometry = useMemo(() => {
|
|
99
|
+
const labelWidth = Math.max(0, ...yLabels.map(label => estimateTextWidth(label, theme.font.size)));
|
|
100
|
+
const left = Math.ceil(labelWidth) + 8;
|
|
101
|
+
const top = 8;
|
|
102
|
+
const bottom = theme.font.size + 12;
|
|
103
|
+
const right = 8;
|
|
104
|
+
return {
|
|
105
|
+
left,
|
|
106
|
+
top,
|
|
107
|
+
right,
|
|
108
|
+
bottom,
|
|
109
|
+
plotWidth: Math.max(0, size.width - left - right),
|
|
110
|
+
plotHeight: Math.max(0, size.height - top - bottom)
|
|
111
|
+
};
|
|
112
|
+
}, [yLabels, size.width, size.height, theme.font.size]);
|
|
113
|
+
const xScale = useMemo(() => createBandScale({
|
|
114
|
+
domain: xLabels,
|
|
115
|
+
range: [geometry.left, geometry.left + geometry.plotWidth],
|
|
116
|
+
paddingInner: 0,
|
|
117
|
+
paddingOuter: 0
|
|
118
|
+
}), [xLabels, geometry.left, geometry.plotWidth]);
|
|
119
|
+
const rowHeight = yLabels.length > 0 ? geometry.plotHeight / yLabels.length : 0;
|
|
120
|
+
const colorAt = useCallback(value => {
|
|
121
|
+
const from = colorRange?.[0] ?? withAlpha(theme.emphasis, 0.08);
|
|
122
|
+
const to = colorRange?.[1] ?? theme.emphasis;
|
|
123
|
+
return mixColor(from, to, normalize(value, range[0], range[1]));
|
|
124
|
+
}, [colorRange, theme.emphasis, range]);
|
|
125
|
+
const cellSize = Math.max(0, xScale.step - cellGap);
|
|
126
|
+
const showNumbers = showValue === true || showValue === 'auto' && cellSize >= 42 && rowHeight >= 24;
|
|
127
|
+
const scene = useMemo(() => {
|
|
128
|
+
if (!xLabels.length || !yLabels.length || geometry.plotWidth <= 0) return [];
|
|
129
|
+
const nodes = [];
|
|
130
|
+
const total = yLabels.length * xLabels.length;
|
|
131
|
+
yLabels.forEach((yLabel, rowIndex) => {
|
|
132
|
+
const y = geometry.top + rowIndex * rowHeight;
|
|
133
|
+
nodes.push({
|
|
134
|
+
kind: 'text',
|
|
135
|
+
key: `yl-${yLabel}`,
|
|
136
|
+
x: geometry.left - 8,
|
|
137
|
+
y: y + rowHeight / 2,
|
|
138
|
+
text: yLabel,
|
|
139
|
+
fill: theme.axis.label,
|
|
140
|
+
fontSize: theme.font.size,
|
|
141
|
+
anchor: 'end',
|
|
142
|
+
baseline: 'middle',
|
|
143
|
+
fontFamily: theme.font.family
|
|
144
|
+
});
|
|
145
|
+
xLabels.forEach((xLabel, columnIndex) => {
|
|
146
|
+
const x = xScale.scale(xLabel);
|
|
147
|
+
if (x === undefined) return;
|
|
148
|
+
const raw = transition.values[rowIndex]?.[columnIndex] ?? null;
|
|
149
|
+
const flatIndex = rowIndex * xLabels.length + columnIndex;
|
|
150
|
+
const local = staggerProgress(progress, flatIndex, total, animConfig.stagger);
|
|
151
|
+
if (raw === null) {
|
|
152
|
+
// 缺失格:画一个极浅的底,让矩阵结构仍然完整
|
|
153
|
+
nodes.push({
|
|
154
|
+
kind: 'rect',
|
|
155
|
+
key: `empty-${xLabel}-${yLabel}`,
|
|
156
|
+
x: x + cellGap / 2,
|
|
157
|
+
y: y + cellGap / 2,
|
|
158
|
+
width: cellSize,
|
|
159
|
+
height: Math.max(0, rowHeight - cellGap),
|
|
160
|
+
radius: cellRadius,
|
|
161
|
+
fill: withAlpha(theme.axis.line, 0.35),
|
|
162
|
+
opacity: local,
|
|
163
|
+
pointerEvents: 'none'
|
|
164
|
+
});
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const isActive = activeCell?.x === xLabel && activeCell?.y === yLabel;
|
|
168
|
+
nodes.push({
|
|
169
|
+
kind: 'path',
|
|
170
|
+
key: `cell-${xLabel}-${yLabel}`,
|
|
171
|
+
d: roundedRectPath(x + cellGap / 2, y + cellGap / 2, cellSize, Math.max(0, rowHeight - cellGap), cellRadius),
|
|
172
|
+
fill: colorAt(raw),
|
|
173
|
+
stroke: isActive ? theme.text.primary : undefined,
|
|
174
|
+
strokeWidth: isActive ? 1.5 : 0,
|
|
175
|
+
opacity: local,
|
|
176
|
+
pointerEvents: 'none'
|
|
177
|
+
});
|
|
178
|
+
if (showNumbers) {
|
|
179
|
+
// 深色格子用白字,浅色用深字,保证可读
|
|
180
|
+
const ratio = normalize(raw, range[0], range[1]);
|
|
181
|
+
nodes.push({
|
|
182
|
+
kind: 'text',
|
|
183
|
+
key: `cell-value-${xLabel}-${yLabel}`,
|
|
184
|
+
x: x + xScale.step / 2,
|
|
185
|
+
y: y + rowHeight / 2,
|
|
186
|
+
text: formatNumber(raw),
|
|
187
|
+
fill: ratio > 0.55 ? '#fff' : theme.text.primary,
|
|
188
|
+
fontSize: theme.font.sizeSmall,
|
|
189
|
+
anchor: 'middle',
|
|
190
|
+
baseline: 'middle',
|
|
191
|
+
opacity: local,
|
|
192
|
+
fontFamily: theme.font.family
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
// 横轴标签
|
|
199
|
+
xLabels.forEach(xLabel => {
|
|
200
|
+
const x = xScale.scale(xLabel);
|
|
201
|
+
if (x === undefined) return;
|
|
202
|
+
nodes.push({
|
|
203
|
+
kind: 'text',
|
|
204
|
+
key: `xl-${xLabel}`,
|
|
205
|
+
x: x + xScale.step / 2,
|
|
206
|
+
y: geometry.top + geometry.plotHeight + theme.font.size + 4,
|
|
207
|
+
text: xLabel,
|
|
208
|
+
fill: theme.axis.label,
|
|
209
|
+
fontSize: theme.font.size,
|
|
210
|
+
anchor: 'middle',
|
|
211
|
+
fontFamily: theme.font.family
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
return nodes;
|
|
215
|
+
}, [xLabels, yLabels, geometry, rowHeight, xScale, cellSize, cellGap, cellRadius, theme, transition.values, progress, animConfig.stagger, range, showNumbers, activeCell, colorAt]);
|
|
216
|
+
const cellFromPointer = (clientX, clientY) => {
|
|
217
|
+
const element = ref.current;
|
|
218
|
+
if (!element || xScale.step <= 0 || rowHeight <= 0) return null;
|
|
219
|
+
const rect = element.getBoundingClientRect();
|
|
220
|
+
const localX = clientX - rect.left - geometry.left;
|
|
221
|
+
const localY = clientY - rect.top - geometry.top;
|
|
222
|
+
if (localX < 0 || localY < 0) return null;
|
|
223
|
+
const column = Math.floor(localX / xScale.step);
|
|
224
|
+
const row = Math.floor(localY / rowHeight);
|
|
225
|
+
const x = xLabels[column];
|
|
226
|
+
const y = yLabels[row];
|
|
227
|
+
if (x === undefined || y === undefined) return null;
|
|
228
|
+
const value = lookup.get(`${x}__${y}`);
|
|
229
|
+
if (value === undefined) return null;
|
|
230
|
+
return {
|
|
231
|
+
x,
|
|
232
|
+
y,
|
|
233
|
+
value
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
const tooltipPayload = activeCell ? {
|
|
237
|
+
label: `${activeCell.y} · ${activeCell.x}`,
|
|
238
|
+
row: null,
|
|
239
|
+
series: [{
|
|
240
|
+
key: activeCell.x,
|
|
241
|
+
name: '数值',
|
|
242
|
+
color: activeCell.value === null ? theme.text.secondary : colorAt(activeCell.value),
|
|
243
|
+
value: activeCell.value,
|
|
244
|
+
formatted: activeCell.value === null ? '无数据' : formatNumber(activeCell.value)
|
|
245
|
+
}]
|
|
246
|
+
} : null;
|
|
247
|
+
const autoAriaLabel = ariaLabel ?? `热力图:${yLabels.length} 行 × ${xLabels.length} 列`;
|
|
248
|
+
return /*#__PURE__*/_jsx("div", {
|
|
249
|
+
className: classNames(prefixCls('chart'), className),
|
|
250
|
+
style: {
|
|
251
|
+
width,
|
|
252
|
+
height,
|
|
253
|
+
...style
|
|
254
|
+
},
|
|
255
|
+
"data-aura-chart": "heatmap",
|
|
256
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
257
|
+
ref: ref,
|
|
258
|
+
className: prefixCls('chart__plot'),
|
|
259
|
+
onPointerMove: event => setActiveCell(cellFromPointer(event.clientX, event.clientY)),
|
|
260
|
+
onPointerLeave: () => setActiveCell(null),
|
|
261
|
+
children: [data.length === 0 || size.width === 0 ? /*#__PURE__*/_jsx("div", {
|
|
262
|
+
className: prefixCls('chart__empty'),
|
|
263
|
+
children: emptyText
|
|
264
|
+
}) : /*#__PURE__*/_jsx(SvgScene, {
|
|
265
|
+
nodes: scene,
|
|
266
|
+
width: size.width,
|
|
267
|
+
height: size.height,
|
|
268
|
+
ariaLabel: autoAriaLabel
|
|
269
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
|
270
|
+
payload: tooltipPayload,
|
|
271
|
+
x: size.width / 2,
|
|
272
|
+
y: 16,
|
|
273
|
+
containerWidth: size.width,
|
|
274
|
+
containerHeight: size.height,
|
|
275
|
+
theme: theme,
|
|
276
|
+
config: tooltip
|
|
277
|
+
})]
|
|
278
|
+
})
|
|
279
|
+
});
|
|
280
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { BaseChartProps } from '../../types';
|
|
3
|
+
import type { CurveType } from '../../core/shape';
|
|
4
|
+
export interface LineChartProps extends BaseChartProps {
|
|
5
|
+
/** 曲线插值方式,默认 monotone(平滑但不越界) */
|
|
6
|
+
curve?: CurveType;
|
|
7
|
+
/** 是否平滑,等价于 curve="smooth",保留是为了贴合直觉用法 */
|
|
8
|
+
smooth?: boolean;
|
|
9
|
+
/** 是否给折线填充面积 */
|
|
10
|
+
area?: boolean;
|
|
11
|
+
/** 是否显示数据点;不传时按点数自动决策(≤24 点时显示) */
|
|
12
|
+
showSymbol?: boolean;
|
|
13
|
+
/** 堆叠 */
|
|
14
|
+
stack?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 折线图。
|
|
18
|
+
*
|
|
19
|
+
* 默认曲线为 monotone 而非普通样条:普通样条在极值处会「冲出」数据范围,
|
|
20
|
+
* 折线图一旦画出超过真实最大值的高度,读者会基于错误信息做判断。
|
|
21
|
+
*/
|
|
22
|
+
export declare function LineChart({ curve, smooth, area, showSymbol, stack, series, ...rest }: LineChartProps): React.JSX.Element;
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,aAAa,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,MAAM,WAAW,cAAe,SAAQ,cAAc;IACpD,iCAAiC;IACjC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gBAAgB;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,mCAAmC;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS;IACT,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,EACxB,KAAkB,EAClB,MAAc,EACd,IAAY,EACZ,UAAU,EACV,KAAa,EACb,MAAM,EACN,GAAG,IAAI,EACR,EAAE,cAAc,qBAqBhB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { CartesianChart } from "../../internal/CartesianChart";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
/**
|
|
5
|
+
* 折线图。
|
|
6
|
+
*
|
|
7
|
+
* 默认曲线为 monotone 而非普通样条:普通样条在极值处会「冲出」数据范围,
|
|
8
|
+
* 折线图一旦画出超过真实最大值的高度,读者会基于错误信息做判断。
|
|
9
|
+
*/
|
|
10
|
+
export function LineChart({
|
|
11
|
+
curve = 'monotone',
|
|
12
|
+
smooth = false,
|
|
13
|
+
area = false,
|
|
14
|
+
showSymbol,
|
|
15
|
+
stack = false,
|
|
16
|
+
series,
|
|
17
|
+
...rest
|
|
18
|
+
}) {
|
|
19
|
+
const merged = useMemo(() => (series ?? []).map(item => ({
|
|
20
|
+
type: 'line',
|
|
21
|
+
curve: smooth ? 'smooth' : curve,
|
|
22
|
+
area,
|
|
23
|
+
showSymbol,
|
|
24
|
+
...item
|
|
25
|
+
})), [series, smooth, curve, area, showSymbol]);
|
|
26
|
+
return /*#__PURE__*/_jsx(CartesianChart, {
|
|
27
|
+
...rest,
|
|
28
|
+
series: merged,
|
|
29
|
+
defaultType: "line",
|
|
30
|
+
stack: stack
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChartThemeInput } from '../../theme';
|
|
3
|
+
import type { LegendConfig, TooltipConfig } from '../../types';
|
|
4
|
+
export interface PieDataItem {
|
|
5
|
+
name: string;
|
|
6
|
+
value: number;
|
|
7
|
+
color?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface PieChartProps {
|
|
10
|
+
data: PieDataItem[];
|
|
11
|
+
width?: number | string;
|
|
12
|
+
height?: number;
|
|
13
|
+
theme?: ChartThemeInput;
|
|
14
|
+
palette?: string[];
|
|
15
|
+
legend?: boolean | LegendConfig;
|
|
16
|
+
tooltip?: boolean | TooltipConfig;
|
|
17
|
+
/** 内径比例,0 为实心饼图,0.6 为常见环图 */
|
|
18
|
+
innerRadius?: number;
|
|
19
|
+
/** 扇区间隙角度(弧度),默认 0.01 */
|
|
20
|
+
padAngle?: number;
|
|
21
|
+
/** 标签:outside 引线标签 / inside 内部百分比 / false 不显示 */
|
|
22
|
+
label?: 'outside' | 'inside' | false;
|
|
23
|
+
/** 圆心的自定义内容(仅环图有意义) */
|
|
24
|
+
centerContent?: React.ReactNode;
|
|
25
|
+
animation?: boolean;
|
|
26
|
+
className?: string;
|
|
27
|
+
style?: React.CSSProperties;
|
|
28
|
+
ariaLabel?: string;
|
|
29
|
+
emptyText?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 饼图 / 环形图。
|
|
33
|
+
*
|
|
34
|
+
* 交互命中不用 DOM 事件绑定在每个扇形上,而是把鼠标坐标换算成极坐标角度后
|
|
35
|
+
* 反查所属扇区 —— 这样 SVG 与 Canvas 两种渲染方式可以共用同一套交互逻辑。
|
|
36
|
+
*/
|
|
37
|
+
export declare function PieChart({ data, width, height, theme: themeInput, palette, legend, tooltip, innerRadius, padAngle, label, centerContent, animation, className, style, ariaLabel, emptyText, }: PieChartProps): React.JSX.Element;
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAM9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAOnD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,6BAA6B,CAAC;AAErC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,WAAW,EAAE,CAAC;IACpB,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,6BAA6B;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yBAAyB;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,KAAK,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,KAAK,CAAC;IACrC,uBAAuB;IACvB,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAChC,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;AAUD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,EACvB,IAAS,EACT,KAAc,EACd,MAAY,EACZ,KAAK,EAAE,UAAU,EACjB,OAAO,EACP,MAAa,EACb,OAAc,EACd,WAAiB,EACjB,QAAe,EACf,KAAiB,EACjB,aAAa,EACb,SAAgB,EAChB,SAAS,EACT,KAAK,EACL,SAAS,EACT,SAAkB,GACnB,EAAE,aAAa,qBAsUf"}
|