@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,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
2
|
+
// src/charts/heatmap-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 { createBandScale } from "../../core/scale";
|
|
6
7
|
import { formatNumber, estimateTextWidth } from "../../core/format";
|
|
@@ -11,32 +12,21 @@ import { useElementSize } from "../../hooks/useElementSize";
|
|
|
11
12
|
import { useChartTransition } from "../../hooks/useChartTransition";
|
|
12
13
|
import { resolveAnimation, staggerProgress } from "../../core/animation";
|
|
13
14
|
import { Tooltip } from "../../components/Tooltip";
|
|
14
|
-
import { jsx
|
|
15
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
-
/** 把数值映射到 0~1 的位置;全等值时统一给 0.6,避免整片同色看不清边界 */
|
|
15
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
17
16
|
function normalize(value, min, max) {
|
|
18
|
-
if (max === min)
|
|
17
|
+
if (max === min)
|
|
18
|
+
return 0.6;
|
|
19
19
|
return (value - min) / (max - min);
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* 热力图。
|
|
24
|
-
*
|
|
25
|
-
* 用颜色深浅编码二维矩阵里的数值,密度远高于逐格标数字,
|
|
26
|
-
* 适合「一眼看出哪块热」——访问时段分布、地域 × 品类销量、相关性矩阵。
|
|
27
|
-
*
|
|
28
|
-
* 注意:颜色编码的精度低于长度/位置(这是视觉感知的固有限制),
|
|
29
|
-
* 需要读出准确数值时必须配合 tooltip 或数字。
|
|
30
|
-
*/
|
|
31
|
-
export function HeatmapChart({
|
|
21
|
+
function HeatmapChart({
|
|
32
22
|
data = [],
|
|
33
23
|
xLabels: xLabelsProp,
|
|
34
24
|
yLabels: yLabelsProp,
|
|
35
25
|
colorRange,
|
|
36
|
-
showValue =
|
|
26
|
+
showValue = "auto",
|
|
37
27
|
cellGap = 3,
|
|
38
28
|
cellRadius = 3,
|
|
39
|
-
width =
|
|
29
|
+
width = "100%",
|
|
40
30
|
height = 320,
|
|
41
31
|
theme: themeInput,
|
|
42
32
|
palette,
|
|
@@ -45,33 +35,31 @@ export function HeatmapChart({
|
|
|
45
35
|
className,
|
|
46
36
|
style,
|
|
47
37
|
ariaLabel,
|
|
48
|
-
emptyText =
|
|
38
|
+
emptyText = "暂无数据"
|
|
49
39
|
}) {
|
|
50
40
|
const theme = useChartTheme(themeInput, palette);
|
|
51
|
-
const {
|
|
52
|
-
ref,
|
|
53
|
-
size
|
|
54
|
-
} = useElementSize();
|
|
41
|
+
const { ref, size } = useElementSize();
|
|
55
42
|
const [activeCell, setActiveCell] = useState(null);
|
|
56
|
-
const animKey = typeof animation ===
|
|
57
|
-
const animConfig = useMemo(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
} = useMemo(() => {
|
|
66
|
-
const xs = xLabelsProp?.length ? xLabelsProp : [];
|
|
67
|
-
const ys = yLabelsProp?.length ? yLabelsProp : [];
|
|
43
|
+
const animKey = typeof animation === "object" ? JSON.stringify(animation) : String(animation);
|
|
44
|
+
const animConfig = useMemo(
|
|
45
|
+
() => resolveAnimation(animation),
|
|
46
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
47
|
+
[animKey]
|
|
48
|
+
);
|
|
49
|
+
const { xLabels, yLabels, lookup, range } = useMemo(() => {
|
|
50
|
+
const xs = (xLabelsProp == null ? void 0 : xLabelsProp.length) ? xLabelsProp : [];
|
|
51
|
+
const ys = (yLabelsProp == null ? void 0 : yLabelsProp.length) ? yLabelsProp : [];
|
|
68
52
|
if (!xs.length) {
|
|
69
|
-
for (const cell of data)
|
|
53
|
+
for (const cell of data)
|
|
54
|
+
if (!xs.includes(cell.x))
|
|
55
|
+
xs.push(cell.x);
|
|
70
56
|
}
|
|
71
57
|
if (!ys.length) {
|
|
72
|
-
for (const cell of data)
|
|
58
|
+
for (const cell of data)
|
|
59
|
+
if (!ys.includes(cell.y))
|
|
60
|
+
ys.push(cell.y);
|
|
73
61
|
}
|
|
74
|
-
const map = new Map();
|
|
62
|
+
const map = /* @__PURE__ */ new Map();
|
|
75
63
|
let min = Number.POSITIVE_INFINITY;
|
|
76
64
|
let max = Number.NEGATIVE_INFINITY;
|
|
77
65
|
for (const cell of data) {
|
|
@@ -85,19 +73,28 @@ export function HeatmapChart({
|
|
|
85
73
|
xLabels: xs,
|
|
86
74
|
yLabels: ys,
|
|
87
75
|
lookup: map,
|
|
88
|
-
range: [
|
|
76
|
+
range: [
|
|
77
|
+
Number.isFinite(min) ? min : 0,
|
|
78
|
+
Number.isFinite(max) ? max : 1
|
|
79
|
+
]
|
|
89
80
|
};
|
|
90
81
|
}, [data, xLabelsProp, yLabelsProp]);
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
82
|
+
const matrix = useMemo(
|
|
83
|
+
() => yLabels.map(
|
|
84
|
+
(y) => xLabels.map((x) => {
|
|
85
|
+
const value = lookup.get(`${x}__${y}`);
|
|
86
|
+
return value === void 0 ? null : value;
|
|
87
|
+
})
|
|
88
|
+
),
|
|
89
|
+
[xLabels, yLabels, lookup]
|
|
90
|
+
);
|
|
97
91
|
const transition = useChartTransition(matrix, animConfig);
|
|
98
92
|
const progress = transition.progress;
|
|
99
93
|
const geometry = useMemo(() => {
|
|
100
|
-
const labelWidth = Math.max(
|
|
94
|
+
const labelWidth = Math.max(
|
|
95
|
+
0,
|
|
96
|
+
...yLabels.map((label) => estimateTextWidth(label, theme.font.size))
|
|
97
|
+
);
|
|
101
98
|
const left = Math.ceil(labelWidth) + 8;
|
|
102
99
|
const top = 8;
|
|
103
100
|
const bottom = theme.font.size + 12;
|
|
@@ -111,48 +108,61 @@ export function HeatmapChart({
|
|
|
111
108
|
plotHeight: Math.max(0, size.height - top - bottom)
|
|
112
109
|
};
|
|
113
110
|
}, [yLabels, size.width, size.height, theme.font.size]);
|
|
114
|
-
const xScale = useMemo(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
const xScale = useMemo(
|
|
112
|
+
() => createBandScale({
|
|
113
|
+
domain: xLabels,
|
|
114
|
+
range: [geometry.left, geometry.left + geometry.plotWidth],
|
|
115
|
+
paddingInner: 0,
|
|
116
|
+
paddingOuter: 0
|
|
117
|
+
}),
|
|
118
|
+
[xLabels, geometry.left, geometry.plotWidth]
|
|
119
|
+
);
|
|
120
120
|
const rowHeight = yLabels.length > 0 ? geometry.plotHeight / yLabels.length : 0;
|
|
121
|
-
const colorAt = useCallback(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
121
|
+
const colorAt = useCallback(
|
|
122
|
+
(value) => {
|
|
123
|
+
const from = (colorRange == null ? void 0 : colorRange[0]) ?? withAlpha(theme.emphasis, 0.08);
|
|
124
|
+
const to = (colorRange == null ? void 0 : colorRange[1]) ?? theme.emphasis;
|
|
125
|
+
return mixColor(from, to, normalize(value, range[0], range[1]));
|
|
126
|
+
},
|
|
127
|
+
[colorRange, theme.emphasis, range]
|
|
128
|
+
);
|
|
126
129
|
const cellSize = Math.max(0, xScale.step - cellGap);
|
|
127
|
-
const showNumbers = showValue === true || showValue ===
|
|
130
|
+
const showNumbers = showValue === true || showValue === "auto" && cellSize >= 42 && rowHeight >= 24;
|
|
128
131
|
const scene = useMemo(() => {
|
|
129
|
-
if (!xLabels.length || !yLabels.length || geometry.plotWidth <= 0)
|
|
132
|
+
if (!xLabels.length || !yLabels.length || geometry.plotWidth <= 0)
|
|
133
|
+
return [];
|
|
130
134
|
const nodes = [];
|
|
131
135
|
const total = yLabels.length * xLabels.length;
|
|
132
136
|
yLabels.forEach((yLabel, rowIndex) => {
|
|
133
137
|
const y = geometry.top + rowIndex * rowHeight;
|
|
134
138
|
nodes.push({
|
|
135
|
-
kind:
|
|
139
|
+
kind: "text",
|
|
136
140
|
key: `yl-${yLabel}`,
|
|
137
141
|
x: geometry.left - 8,
|
|
138
142
|
y: y + rowHeight / 2,
|
|
139
143
|
text: yLabel,
|
|
140
144
|
fill: theme.axis.label,
|
|
141
145
|
fontSize: theme.font.size,
|
|
142
|
-
anchor:
|
|
143
|
-
baseline:
|
|
146
|
+
anchor: "end",
|
|
147
|
+
baseline: "middle",
|
|
144
148
|
fontFamily: theme.font.family
|
|
145
149
|
});
|
|
146
150
|
xLabels.forEach((xLabel, columnIndex) => {
|
|
151
|
+
var _a;
|
|
147
152
|
const x = xScale.scale(xLabel);
|
|
148
|
-
if (x ===
|
|
149
|
-
|
|
153
|
+
if (x === void 0)
|
|
154
|
+
return;
|
|
155
|
+
const raw = ((_a = transition.values[rowIndex]) == null ? void 0 : _a[columnIndex]) ?? null;
|
|
150
156
|
const flatIndex = rowIndex * xLabels.length + columnIndex;
|
|
151
|
-
const local = staggerProgress(
|
|
157
|
+
const local = staggerProgress(
|
|
158
|
+
progress,
|
|
159
|
+
flatIndex,
|
|
160
|
+
total,
|
|
161
|
+
animConfig.stagger
|
|
162
|
+
);
|
|
152
163
|
if (raw === null) {
|
|
153
|
-
// 缺失格:画一个极浅的底,让矩阵结构仍然完整
|
|
154
164
|
nodes.push({
|
|
155
|
-
kind:
|
|
165
|
+
kind: "rect",
|
|
156
166
|
key: `empty-${xLabel}-${yLabel}`,
|
|
157
167
|
x: x + cellGap / 2,
|
|
158
168
|
y: y + cellGap / 2,
|
|
@@ -161,121 +171,155 @@ export function HeatmapChart({
|
|
|
161
171
|
radius: cellRadius,
|
|
162
172
|
fill: withAlpha(theme.axis.line, 0.35),
|
|
163
173
|
opacity: local,
|
|
164
|
-
pointerEvents:
|
|
174
|
+
pointerEvents: "none"
|
|
165
175
|
});
|
|
166
176
|
return;
|
|
167
177
|
}
|
|
168
|
-
const isActive = activeCell
|
|
178
|
+
const isActive = (activeCell == null ? void 0 : activeCell.x) === xLabel && (activeCell == null ? void 0 : activeCell.y) === yLabel;
|
|
169
179
|
nodes.push({
|
|
170
|
-
kind:
|
|
180
|
+
kind: "path",
|
|
171
181
|
key: `cell-${xLabel}-${yLabel}`,
|
|
172
|
-
d: roundedRectPath(
|
|
182
|
+
d: roundedRectPath(
|
|
183
|
+
x + cellGap / 2,
|
|
184
|
+
y + cellGap / 2,
|
|
185
|
+
cellSize,
|
|
186
|
+
Math.max(0, rowHeight - cellGap),
|
|
187
|
+
cellRadius
|
|
188
|
+
),
|
|
173
189
|
fill: colorAt(raw),
|
|
174
|
-
stroke: isActive ? theme.text.primary :
|
|
190
|
+
stroke: isActive ? theme.text.primary : void 0,
|
|
175
191
|
strokeWidth: isActive ? 1.5 : 0,
|
|
176
192
|
opacity: local,
|
|
177
|
-
pointerEvents:
|
|
193
|
+
pointerEvents: "none"
|
|
178
194
|
});
|
|
179
195
|
if (showNumbers) {
|
|
180
|
-
// 深色格子用白字,浅色用深字,保证可读
|
|
181
196
|
const ratio = normalize(raw, range[0], range[1]);
|
|
182
197
|
nodes.push({
|
|
183
|
-
kind:
|
|
198
|
+
kind: "text",
|
|
184
199
|
key: `cell-value-${xLabel}-${yLabel}`,
|
|
185
200
|
x: x + xScale.step / 2,
|
|
186
201
|
y: y + rowHeight / 2,
|
|
187
202
|
text: formatNumber(raw),
|
|
188
|
-
fill: ratio > 0.55 ?
|
|
203
|
+
fill: ratio > 0.55 ? "#fff" : theme.text.primary,
|
|
189
204
|
fontSize: theme.font.sizeSmall,
|
|
190
|
-
anchor:
|
|
191
|
-
baseline:
|
|
205
|
+
anchor: "middle",
|
|
206
|
+
baseline: "middle",
|
|
192
207
|
opacity: local,
|
|
193
208
|
fontFamily: theme.font.family
|
|
194
209
|
});
|
|
195
210
|
}
|
|
196
211
|
});
|
|
197
212
|
});
|
|
198
|
-
|
|
199
|
-
// 横轴标签
|
|
200
|
-
xLabels.forEach(xLabel => {
|
|
213
|
+
xLabels.forEach((xLabel) => {
|
|
201
214
|
const x = xScale.scale(xLabel);
|
|
202
|
-
if (x ===
|
|
215
|
+
if (x === void 0)
|
|
216
|
+
return;
|
|
203
217
|
nodes.push({
|
|
204
|
-
kind:
|
|
218
|
+
kind: "text",
|
|
205
219
|
key: `xl-${xLabel}`,
|
|
206
220
|
x: x + xScale.step / 2,
|
|
207
221
|
y: geometry.top + geometry.plotHeight + theme.font.size + 4,
|
|
208
222
|
text: xLabel,
|
|
209
223
|
fill: theme.axis.label,
|
|
210
224
|
fontSize: theme.font.size,
|
|
211
|
-
anchor:
|
|
225
|
+
anchor: "middle",
|
|
212
226
|
fontFamily: theme.font.family
|
|
213
227
|
});
|
|
214
228
|
});
|
|
215
229
|
return nodes;
|
|
216
|
-
}, [
|
|
230
|
+
}, [
|
|
231
|
+
xLabels,
|
|
232
|
+
yLabels,
|
|
233
|
+
geometry,
|
|
234
|
+
rowHeight,
|
|
235
|
+
xScale,
|
|
236
|
+
cellSize,
|
|
237
|
+
cellGap,
|
|
238
|
+
cellRadius,
|
|
239
|
+
theme,
|
|
240
|
+
transition.values,
|
|
241
|
+
progress,
|
|
242
|
+
animConfig.stagger,
|
|
243
|
+
range,
|
|
244
|
+
showNumbers,
|
|
245
|
+
activeCell,
|
|
246
|
+
colorAt
|
|
247
|
+
]);
|
|
217
248
|
const cellFromPointer = (clientX, clientY) => {
|
|
218
249
|
const element = ref.current;
|
|
219
|
-
if (!element || xScale.step <= 0 || rowHeight <= 0)
|
|
250
|
+
if (!element || xScale.step <= 0 || rowHeight <= 0)
|
|
251
|
+
return null;
|
|
220
252
|
const rect = element.getBoundingClientRect();
|
|
221
253
|
const localX = clientX - rect.left - geometry.left;
|
|
222
254
|
const localY = clientY - rect.top - geometry.top;
|
|
223
|
-
if (localX < 0 || localY < 0)
|
|
255
|
+
if (localX < 0 || localY < 0)
|
|
256
|
+
return null;
|
|
224
257
|
const column = Math.floor(localX / xScale.step);
|
|
225
258
|
const row = Math.floor(localY / rowHeight);
|
|
226
259
|
const x = xLabels[column];
|
|
227
260
|
const y = yLabels[row];
|
|
228
|
-
if (x ===
|
|
261
|
+
if (x === void 0 || y === void 0)
|
|
262
|
+
return null;
|
|
229
263
|
const value = lookup.get(`${x}__${y}`);
|
|
230
|
-
if (value ===
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
y,
|
|
234
|
-
value
|
|
235
|
-
};
|
|
264
|
+
if (value === void 0)
|
|
265
|
+
return null;
|
|
266
|
+
return { x, y, value };
|
|
236
267
|
};
|
|
237
268
|
const tooltipPayload = activeCell ? {
|
|
238
269
|
label: `${activeCell.y} · ${activeCell.x}`,
|
|
239
270
|
row: null,
|
|
240
|
-
series: [
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
271
|
+
series: [
|
|
272
|
+
{
|
|
273
|
+
key: activeCell.x,
|
|
274
|
+
name: "数值",
|
|
275
|
+
color: activeCell.value === null ? theme.text.secondary : colorAt(activeCell.value),
|
|
276
|
+
value: activeCell.value,
|
|
277
|
+
formatted: activeCell.value === null ? "无数据" : formatNumber(activeCell.value)
|
|
278
|
+
}
|
|
279
|
+
]
|
|
247
280
|
} : null;
|
|
248
281
|
const autoAriaLabel = ariaLabel ?? `热力图:${yLabels.length} 行 × ${xLabels.length} 列`;
|
|
249
|
-
return
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
height,
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
+
return /* @__PURE__ */ jsx(
|
|
283
|
+
"div",
|
|
284
|
+
{
|
|
285
|
+
className: classNames(prefixCls("chart"), className),
|
|
286
|
+
style: { width, height, ...style },
|
|
287
|
+
"data-aura-chart": "heatmap",
|
|
288
|
+
children: /* @__PURE__ */ jsxs(
|
|
289
|
+
"div",
|
|
290
|
+
{
|
|
291
|
+
ref,
|
|
292
|
+
className: prefixCls("chart__plot"),
|
|
293
|
+
onPointerMove: (event) => setActiveCell(cellFromPointer(event.clientX, event.clientY)),
|
|
294
|
+
onPointerLeave: () => setActiveCell(null),
|
|
295
|
+
children: [
|
|
296
|
+
data.length === 0 || size.width === 0 ? /* @__PURE__ */ jsx("div", { className: prefixCls("chart__empty"), children: emptyText }) : /* @__PURE__ */ jsx(
|
|
297
|
+
SvgScene,
|
|
298
|
+
{
|
|
299
|
+
nodes: scene,
|
|
300
|
+
width: size.width,
|
|
301
|
+
height: size.height,
|
|
302
|
+
ariaLabel: autoAriaLabel
|
|
303
|
+
}
|
|
304
|
+
),
|
|
305
|
+
/* @__PURE__ */ jsx(
|
|
306
|
+
Tooltip,
|
|
307
|
+
{
|
|
308
|
+
payload: tooltipPayload,
|
|
309
|
+
x: size.width / 2,
|
|
310
|
+
y: 16,
|
|
311
|
+
containerWidth: size.width,
|
|
312
|
+
containerHeight: size.height,
|
|
313
|
+
theme,
|
|
314
|
+
config: tooltip
|
|
315
|
+
}
|
|
316
|
+
)
|
|
317
|
+
]
|
|
318
|
+
}
|
|
319
|
+
)
|
|
320
|
+
}
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
export {
|
|
324
|
+
HeatmapChart
|
|
325
|
+
};
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
2
|
+
// src/charts/line-chart/index.tsx
|
|
3
|
+
import { useMemo } from "react";
|
|
3
4
|
import { CartesianChart } from "../../internal/CartesianChart";
|
|
4
|
-
import { jsx
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
* 默认曲线为 monotone 而非普通样条:普通样条在极值处会「冲出」数据范围,
|
|
9
|
-
* 折线图一旦画出超过真实最大值的高度,读者会基于错误信息做判断。
|
|
10
|
-
*/
|
|
11
|
-
export function LineChart({
|
|
12
|
-
curve = 'monotone',
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
function LineChart({
|
|
7
|
+
curve = "monotone",
|
|
13
8
|
smooth = false,
|
|
14
9
|
area = false,
|
|
15
10
|
showSymbol,
|
|
@@ -17,17 +12,26 @@ export function LineChart({
|
|
|
17
12
|
series,
|
|
18
13
|
...rest
|
|
19
14
|
}) {
|
|
20
|
-
const merged = useMemo(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
15
|
+
const merged = useMemo(
|
|
16
|
+
() => (series ?? []).map((item) => ({
|
|
17
|
+
type: "line",
|
|
18
|
+
curve: smooth ? "smooth" : curve,
|
|
19
|
+
area,
|
|
20
|
+
showSymbol,
|
|
21
|
+
...item
|
|
22
|
+
})),
|
|
23
|
+
[series, smooth, curve, area, showSymbol]
|
|
24
|
+
);
|
|
25
|
+
return /* @__PURE__ */ jsx(
|
|
26
|
+
CartesianChart,
|
|
27
|
+
{
|
|
28
|
+
...rest,
|
|
29
|
+
series: merged,
|
|
30
|
+
defaultType: "line",
|
|
31
|
+
stack
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
LineChart
|
|
37
|
+
};
|
|
@@ -1 +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;
|
|
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;AAQnD,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,qBA6Uf"}
|