@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,5 +1,7 @@
1
- import React, { useCallback, useMemo, useState } from 'react';
2
- import { classNames, prefixCls } from '@aura-react-comp/shared';
1
+ 'use client';
2
+ // src/charts/heatmap-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 { createBandScale } from "../../core/scale";
5
7
  import { formatNumber, estimateTextWidth } from "../../core/format";
@@ -10,32 +12,21 @@ import { useElementSize } from "../../hooks/useElementSize";
10
12
  import { useChartTransition } from "../../hooks/useChartTransition";
11
13
  import { resolveAnimation, staggerProgress } from "../../core/animation";
12
14
  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,避免整片同色看不清边界 */
15
+ import { jsx, jsxs } from "react/jsx-runtime";
16
16
  function normalize(value, min, max) {
17
- if (max === min) return 0.6;
17
+ if (max === min)
18
+ return 0.6;
18
19
  return (value - min) / (max - min);
19
20
  }
20
-
21
- /**
22
- * 热力图。
23
- *
24
- * 用颜色深浅编码二维矩阵里的数值,密度远高于逐格标数字,
25
- * 适合「一眼看出哪块热」——访问时段分布、地域 × 品类销量、相关性矩阵。
26
- *
27
- * 注意:颜色编码的精度低于长度/位置(这是视觉感知的固有限制),
28
- * 需要读出准确数值时必须配合 tooltip 或数字。
29
- */
30
- export function HeatmapChart({
21
+ function HeatmapChart({
31
22
  data = [],
32
23
  xLabels: xLabelsProp,
33
24
  yLabels: yLabelsProp,
34
25
  colorRange,
35
- showValue = 'auto',
26
+ showValue = "auto",
36
27
  cellGap = 3,
37
28
  cellRadius = 3,
38
- width = '100%',
29
+ width = "100%",
39
30
  height = 320,
40
31
  theme: themeInput,
41
32
  palette,
@@ -44,33 +35,31 @@ export function HeatmapChart({
44
35
  className,
45
36
  style,
46
37
  ariaLabel,
47
- emptyText = '暂无数据'
38
+ emptyText = "暂无数据"
48
39
  }) {
49
40
  const theme = useChartTheme(themeInput, palette);
50
- const {
51
- ref,
52
- size
53
- } = useElementSize();
41
+ const { ref, size } = useElementSize();
54
42
  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 : [];
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 : [];
67
52
  if (!xs.length) {
68
- for (const cell of data) if (!xs.includes(cell.x)) xs.push(cell.x);
53
+ for (const cell of data)
54
+ if (!xs.includes(cell.x))
55
+ xs.push(cell.x);
69
56
  }
70
57
  if (!ys.length) {
71
- for (const cell of data) if (!ys.includes(cell.y)) ys.push(cell.y);
58
+ for (const cell of data)
59
+ if (!ys.includes(cell.y))
60
+ ys.push(cell.y);
72
61
  }
73
- const map = new Map();
62
+ const map = /* @__PURE__ */ new Map();
74
63
  let min = Number.POSITIVE_INFINITY;
75
64
  let max = Number.NEGATIVE_INFINITY;
76
65
  for (const cell of data) {
@@ -84,19 +73,28 @@ export function HeatmapChart({
84
73
  xLabels: xs,
85
74
  yLabels: ys,
86
75
  lookup: map,
87
- range: [Number.isFinite(min) ? min : 0, Number.isFinite(max) ? max : 1]
76
+ range: [
77
+ Number.isFinite(min) ? min : 0,
78
+ Number.isFinite(max) ? max : 1
79
+ ]
88
80
  };
89
81
  }, [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]);
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
+ );
96
91
  const transition = useChartTransition(matrix, animConfig);
97
92
  const progress = transition.progress;
98
93
  const geometry = useMemo(() => {
99
- const labelWidth = Math.max(0, ...yLabels.map(label => estimateTextWidth(label, theme.font.size)));
94
+ const labelWidth = Math.max(
95
+ 0,
96
+ ...yLabels.map((label) => estimateTextWidth(label, theme.font.size))
97
+ );
100
98
  const left = Math.ceil(labelWidth) + 8;
101
99
  const top = 8;
102
100
  const bottom = theme.font.size + 12;
@@ -110,48 +108,61 @@ export function HeatmapChart({
110
108
  plotHeight: Math.max(0, size.height - top - bottom)
111
109
  };
112
110
  }, [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]);
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
+ );
119
120
  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]);
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
+ );
125
129
  const cellSize = Math.max(0, xScale.step - cellGap);
126
- const showNumbers = showValue === true || showValue === 'auto' && cellSize >= 42 && rowHeight >= 24;
130
+ const showNumbers = showValue === true || showValue === "auto" && cellSize >= 42 && rowHeight >= 24;
127
131
  const scene = useMemo(() => {
128
- if (!xLabels.length || !yLabels.length || geometry.plotWidth <= 0) return [];
132
+ if (!xLabels.length || !yLabels.length || geometry.plotWidth <= 0)
133
+ return [];
129
134
  const nodes = [];
130
135
  const total = yLabels.length * xLabels.length;
131
136
  yLabels.forEach((yLabel, rowIndex) => {
132
137
  const y = geometry.top + rowIndex * rowHeight;
133
138
  nodes.push({
134
- kind: 'text',
139
+ kind: "text",
135
140
  key: `yl-${yLabel}`,
136
141
  x: geometry.left - 8,
137
142
  y: y + rowHeight / 2,
138
143
  text: yLabel,
139
144
  fill: theme.axis.label,
140
145
  fontSize: theme.font.size,
141
- anchor: 'end',
142
- baseline: 'middle',
146
+ anchor: "end",
147
+ baseline: "middle",
143
148
  fontFamily: theme.font.family
144
149
  });
145
150
  xLabels.forEach((xLabel, columnIndex) => {
151
+ var _a;
146
152
  const x = xScale.scale(xLabel);
147
- if (x === undefined) return;
148
- const raw = transition.values[rowIndex]?.[columnIndex] ?? null;
153
+ if (x === void 0)
154
+ return;
155
+ const raw = ((_a = transition.values[rowIndex]) == null ? void 0 : _a[columnIndex]) ?? null;
149
156
  const flatIndex = rowIndex * xLabels.length + columnIndex;
150
- const local = staggerProgress(progress, flatIndex, total, animConfig.stagger);
157
+ const local = staggerProgress(
158
+ progress,
159
+ flatIndex,
160
+ total,
161
+ animConfig.stagger
162
+ );
151
163
  if (raw === null) {
152
- // 缺失格:画一个极浅的底,让矩阵结构仍然完整
153
164
  nodes.push({
154
- kind: 'rect',
165
+ kind: "rect",
155
166
  key: `empty-${xLabel}-${yLabel}`,
156
167
  x: x + cellGap / 2,
157
168
  y: y + cellGap / 2,
@@ -160,121 +171,155 @@ export function HeatmapChart({
160
171
  radius: cellRadius,
161
172
  fill: withAlpha(theme.axis.line, 0.35),
162
173
  opacity: local,
163
- pointerEvents: 'none'
174
+ pointerEvents: "none"
164
175
  });
165
176
  return;
166
177
  }
167
- const isActive = activeCell?.x === xLabel && activeCell?.y === yLabel;
178
+ const isActive = (activeCell == null ? void 0 : activeCell.x) === xLabel && (activeCell == null ? void 0 : activeCell.y) === yLabel;
168
179
  nodes.push({
169
- kind: 'path',
180
+ kind: "path",
170
181
  key: `cell-${xLabel}-${yLabel}`,
171
- d: roundedRectPath(x + cellGap / 2, y + cellGap / 2, cellSize, Math.max(0, rowHeight - cellGap), cellRadius),
182
+ d: roundedRectPath(
183
+ x + cellGap / 2,
184
+ y + cellGap / 2,
185
+ cellSize,
186
+ Math.max(0, rowHeight - cellGap),
187
+ cellRadius
188
+ ),
172
189
  fill: colorAt(raw),
173
- stroke: isActive ? theme.text.primary : undefined,
190
+ stroke: isActive ? theme.text.primary : void 0,
174
191
  strokeWidth: isActive ? 1.5 : 0,
175
192
  opacity: local,
176
- pointerEvents: 'none'
193
+ pointerEvents: "none"
177
194
  });
178
195
  if (showNumbers) {
179
- // 深色格子用白字,浅色用深字,保证可读
180
196
  const ratio = normalize(raw, range[0], range[1]);
181
197
  nodes.push({
182
- kind: 'text',
198
+ kind: "text",
183
199
  key: `cell-value-${xLabel}-${yLabel}`,
184
200
  x: x + xScale.step / 2,
185
201
  y: y + rowHeight / 2,
186
202
  text: formatNumber(raw),
187
- fill: ratio > 0.55 ? '#fff' : theme.text.primary,
203
+ fill: ratio > 0.55 ? "#fff" : theme.text.primary,
188
204
  fontSize: theme.font.sizeSmall,
189
- anchor: 'middle',
190
- baseline: 'middle',
205
+ anchor: "middle",
206
+ baseline: "middle",
191
207
  opacity: local,
192
208
  fontFamily: theme.font.family
193
209
  });
194
210
  }
195
211
  });
196
212
  });
197
-
198
- // 横轴标签
199
- xLabels.forEach(xLabel => {
213
+ xLabels.forEach((xLabel) => {
200
214
  const x = xScale.scale(xLabel);
201
- if (x === undefined) return;
215
+ if (x === void 0)
216
+ return;
202
217
  nodes.push({
203
- kind: 'text',
218
+ kind: "text",
204
219
  key: `xl-${xLabel}`,
205
220
  x: x + xScale.step / 2,
206
221
  y: geometry.top + geometry.plotHeight + theme.font.size + 4,
207
222
  text: xLabel,
208
223
  fill: theme.axis.label,
209
224
  fontSize: theme.font.size,
210
- anchor: 'middle',
225
+ anchor: "middle",
211
226
  fontFamily: theme.font.family
212
227
  });
213
228
  });
214
229
  return nodes;
215
- }, [xLabels, yLabels, geometry, rowHeight, xScale, cellSize, cellGap, cellRadius, theme, transition.values, progress, animConfig.stagger, range, showNumbers, activeCell, colorAt]);
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
+ ]);
216
248
  const cellFromPointer = (clientX, clientY) => {
217
249
  const element = ref.current;
218
- if (!element || xScale.step <= 0 || rowHeight <= 0) return null;
250
+ if (!element || xScale.step <= 0 || rowHeight <= 0)
251
+ return null;
219
252
  const rect = element.getBoundingClientRect();
220
253
  const localX = clientX - rect.left - geometry.left;
221
254
  const localY = clientY - rect.top - geometry.top;
222
- if (localX < 0 || localY < 0) return null;
255
+ if (localX < 0 || localY < 0)
256
+ return null;
223
257
  const column = Math.floor(localX / xScale.step);
224
258
  const row = Math.floor(localY / rowHeight);
225
259
  const x = xLabels[column];
226
260
  const y = yLabels[row];
227
- if (x === undefined || y === undefined) return null;
261
+ if (x === void 0 || y === void 0)
262
+ return null;
228
263
  const value = lookup.get(`${x}__${y}`);
229
- if (value === undefined) return null;
230
- return {
231
- x,
232
- y,
233
- value
234
- };
264
+ if (value === void 0)
265
+ return null;
266
+ return { x, y, value };
235
267
  };
236
268
  const tooltipPayload = activeCell ? {
237
269
  label: `${activeCell.y} · ${activeCell.x}`,
238
270
  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
- }]
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
+ ]
246
280
  } : null;
247
281
  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
- }
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,6 +1,6 @@
1
1
  import React from 'react';
2
- import type { BaseChartProps } from '../../types';
3
- import type { CurveType } from '../../core/shape';
2
+ import type { BaseChartProps } from '../../types.js';
3
+ import type { CurveType } from '../../core/shape.js';
4
4
  export interface LineChartProps extends BaseChartProps {
5
5
  /** 曲线插值方式,默认 monotone(平滑但不越界) */
6
6
  curve?: CurveType;
@@ -1,14 +1,10 @@
1
- import React, { useMemo } from 'react';
1
+ 'use client';
2
+ // src/charts/line-chart/index.tsx
3
+ import { useMemo } from "react";
2
4
  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',
5
+ import { jsx } from "react/jsx-runtime";
6
+ function LineChart({
7
+ curve = "monotone",
12
8
  smooth = false,
13
9
  area = false,
14
10
  showSymbol,
@@ -16,17 +12,26 @@ export function LineChart({
16
12
  series,
17
13
  ...rest
18
14
  }) {
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
- }
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,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 PieDataItem {
5
5
  name: string;
6
6
  value: number;
@@ -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;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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