@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, { useMemo } from 'react';
2
- import { classNames, prefixCls } from '@aura-react-comp/shared';
1
+ 'use client';
2
+ // src/charts/sparkline/index.tsx
3
+ import { useMemo } from "react";
4
+ import { classNames, prefixCls } from "@aura-react-comp/shared";
3
5
  import { SvgScene } from "../../scene/svg";
4
6
  import { areaPath, linePath } from "../../core/shape";
5
7
  import { extentOf } from "../../core/scale";
@@ -7,18 +9,10 @@ import { withAlpha } from "../../theme";
7
9
  import { useChartTheme } from "../../hooks/useChartTheme";
8
10
  import { useChartTransition } from "../../hooks/useChartTransition";
9
11
  import { resolveAnimation, staggerProgress } from "../../core/animation";
10
- import { jsx as _jsx } from "react/jsx-runtime";
11
- /**
12
- * 迷你图(Sparkline)。
13
- *
14
- * 没有坐标轴、没有图例、没有 tooltip —— 它的唯一职责是让读者在扫视表格时
15
- * 立刻看出「这条数据是在涨还是在跌」。任何额外装饰都会削弱这个目的。
16
- *
17
- * 因此它也刻意不提供数值精度:需要读数请用折线图。
18
- */
19
- export function Sparkline({
12
+ import { jsx } from "react/jsx-runtime";
13
+ function Sparkline({
20
14
  data = [],
21
- type = 'line',
15
+ type = "line",
22
16
  width = 120,
23
17
  height = 32,
24
18
  color,
@@ -34,15 +28,18 @@ export function Sparkline({
34
28
  }) {
35
29
  const theme = useChartTheme(themeInput, palette);
36
30
  const accent = color ?? theme.emphasis;
37
- const animKey = typeof animation === 'object' ? JSON.stringify(animation) : String(animation);
38
- const animConfig = useMemo(() => resolveAnimation(animation),
39
- // eslint-disable-next-line react-hooks/exhaustive-deps
40
- [animKey]);
31
+ const animKey = typeof animation === "object" ? JSON.stringify(animation) : String(animation);
32
+ const animConfig = useMemo(
33
+ () => resolveAnimation(animation),
34
+ // eslint-disable-next-line react-hooks/exhaustive-deps
35
+ [animKey]
36
+ );
41
37
  const transition = useChartTransition([data], animConfig);
42
38
  const progress = transition.progress;
43
39
  const values = transition.values[0] ?? data;
44
40
  const points = useMemo(() => {
45
- if (!values.length) return [];
41
+ if (!values.length)
42
+ return [];
46
43
  const [min, max] = extentOf(values);
47
44
  const span = max - min || 1;
48
45
  const pad = strokeWidth;
@@ -59,18 +56,24 @@ export function Sparkline({
59
56
  });
60
57
  }, [values, width, height, strokeWidth]);
61
58
  const scene = useMemo(() => {
62
- if (!points.length) return [];
59
+ if (!points.length)
60
+ return [];
63
61
  const nodes = [];
64
- const curve = smooth ? 'smooth' : 'linear';
65
- if (type === 'bar') {
62
+ const curve = smooth ? "smooth" : "linear";
63
+ if (type === "bar") {
66
64
  const slot = width / Math.max(points.length, 1);
67
65
  const barWidth = Math.max(1, slot * 0.6);
68
66
  const bottom = height - strokeWidth / 2;
69
67
  points.forEach((point, index) => {
70
- const local = staggerProgress(progress, index, points.length, animConfig.stagger);
68
+ const local = staggerProgress(
69
+ progress,
70
+ index,
71
+ points.length,
72
+ animConfig.stagger
73
+ );
71
74
  const barHeight = Math.max(1, (bottom - point.y) * local);
72
75
  nodes.push({
73
- kind: 'rect',
76
+ kind: "rect",
74
77
  key: `bar-${index}`,
75
78
  x: point.x - barWidth / 2,
76
79
  y: bottom - barHeight,
@@ -79,73 +82,86 @@ export function Sparkline({
79
82
  radius: 1,
80
83
  fill: accent,
81
84
  opacity: 0.85,
82
- pointerEvents: 'none'
85
+ pointerEvents: "none"
83
86
  });
84
87
  });
85
88
  return nodes;
86
89
  }
87
-
88
- // 动画:进场时按 progress 从底部抬升
89
- // 逐点错峰:线条像被画出,而不是整体从底部抬起
90
90
  const animated = points.map((point, index) => {
91
- const local = staggerProgress(progress, index, points.length, animConfig.stagger);
92
- return {
93
- x: point.x,
94
- y: height + (point.y - height) * local
95
- };
91
+ const local = staggerProgress(
92
+ progress,
93
+ index,
94
+ points.length,
95
+ animConfig.stagger
96
+ );
97
+ return { x: point.x, y: height + (point.y - height) * local };
96
98
  });
97
- if (type === 'area') {
99
+ if (type === "area") {
98
100
  nodes.push({
99
- kind: 'path',
100
- key: 'area',
101
+ kind: "path",
102
+ key: "area",
101
103
  d: areaPath(animated, height, curve),
102
104
  fill: withAlpha(accent, 0.16),
103
- pointerEvents: 'none'
105
+ pointerEvents: "none"
104
106
  });
105
107
  }
106
108
  nodes.push({
107
- kind: 'path',
108
- key: 'line',
109
+ kind: "path",
110
+ key: "line",
109
111
  d: linePath(animated, curve),
110
- fill: 'none',
112
+ fill: "none",
111
113
  stroke: accent,
112
114
  strokeWidth,
113
- linecap: 'round',
114
- linejoin: 'round',
115
- pointerEvents: 'none'
115
+ linecap: "round",
116
+ linejoin: "round",
117
+ pointerEvents: "none"
116
118
  });
117
119
  if (showLast) {
118
120
  const last = animated[animated.length - 1];
119
121
  nodes.push({
120
- kind: 'circle',
121
- key: 'last',
122
+ kind: "circle",
123
+ key: "last",
122
124
  cx: last.x,
123
125
  cy: last.y,
124
126
  r: strokeWidth + 1.2,
125
127
  fill: accent,
126
128
  strokeWidth: 0,
127
- pointerEvents: 'none'
129
+ pointerEvents: "none"
128
130
  });
129
131
  }
130
132
  return nodes;
131
- }, [points, type, width, height, accent, strokeWidth, progress, showLast, smooth, animConfig.stagger]);
132
- if (!data.length) return null;
133
- return /*#__PURE__*/_jsx("div", {
134
- className: classNames(prefixCls('chart'), className),
135
- style: {
136
- width,
137
- height,
138
- ...style
139
- },
140
- "data-aura-chart": "sparkline",
141
- children: /*#__PURE__*/_jsx("div", {
142
- className: prefixCls('chart__plot'),
143
- children: /*#__PURE__*/_jsx(SvgScene, {
144
- nodes: scene,
145
- width: width,
146
- height: height,
147
- ariaLabel: ariaLabel ?? `迷你趋势图,共 ${data.length} 个数据点`
148
- })
149
- })
150
- });
151
- }
133
+ }, [
134
+ points,
135
+ type,
136
+ width,
137
+ height,
138
+ accent,
139
+ strokeWidth,
140
+ progress,
141
+ showLast,
142
+ smooth,
143
+ animConfig.stagger
144
+ ]);
145
+ if (!data.length)
146
+ return null;
147
+ return /* @__PURE__ */ jsx(
148
+ "div",
149
+ {
150
+ className: classNames(prefixCls("chart"), className),
151
+ style: { width, height, ...style },
152
+ "data-aura-chart": "sparkline",
153
+ children: /* @__PURE__ */ jsx("div", { className: prefixCls("chart__plot"), children: /* @__PURE__ */ jsx(
154
+ SvgScene,
155
+ {
156
+ nodes: scene,
157
+ width,
158
+ height,
159
+ ariaLabel: ariaLabel ?? `迷你趋势图,共 ${data.length} 个数据点`
160
+ }
161
+ ) })
162
+ }
163
+ );
164
+ }
165
+ export {
166
+ Sparkline
167
+ };
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import { type HierarchyNode } from '../../core/hierarchy';
3
- import { type ChartThemeInput } from '../../theme';
4
- import type { ChartAnimationInput, TooltipConfig } from '../../types';
2
+ import { type HierarchyNode } from '../../core/hierarchy.js';
3
+ import { type ChartThemeInput } from '../../theme/index.js';
4
+ import type { ChartAnimationInput, TooltipConfig } from '../../types.js';
5
5
  export interface TreeChartProps {
6
6
  data?: HierarchyNode;
7
7
  /** 节点圆点半径 */
@@ -1,31 +1,28 @@
1
- import React, { useMemo, useState } from 'react';
2
- import { classNames, prefixCls } from '@aura-react-comp/shared';
1
+ 'use client';
2
+ // src/charts/tree-chart/index.tsx
3
+ import { useMemo, useState } from "react";
4
+ import { classNames, prefixCls } from "@aura-react-comp/shared";
3
5
  import { SvgScene } from "../../scene/svg";
4
6
  import { formatNumber } from "../../core/format";
5
- import { layoutTree, maxDepth, sumValues, treeLinkPath } from "../../core/hierarchy";
7
+ import {
8
+ layoutTree,
9
+ maxDepth,
10
+ sumValues,
11
+ treeLinkPath
12
+ } from "../../core/hierarchy";
6
13
  import { withAlpha } from "../../theme";
7
14
  import { useChartTheme } from "../../hooks/useChartTheme";
8
15
  import { useElementSize } from "../../hooks/useElementSize";
9
16
  import { useChartTransition } from "../../hooks/useChartTransition";
10
17
  import { resolveAnimation, staggerProgress } from "../../core/animation";
11
18
  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
- * 同一父节点下的兄弟会自然聚成一簇。
22
- */
23
- export function TreeChart({
19
+ import { jsx, jsxs } from "react/jsx-runtime";
20
+ function TreeChart({
24
21
  data,
25
22
  nodeSize = 4,
26
23
  showValue = false,
27
24
  labelSpace = 96,
28
- width = '100%',
25
+ width = "100%",
29
26
  height = 360,
30
27
  theme: themeInput,
31
28
  palette,
@@ -34,23 +31,21 @@ export function TreeChart({
34
31
  className,
35
32
  style,
36
33
  ariaLabel,
37
- emptyText = '暂无数据'
34
+ emptyText = "暂无数据"
38
35
  }) {
36
+ var _a;
39
37
  const theme = useChartTheme(themeInput, palette);
40
- const {
41
- ref,
42
- size
43
- } = useElementSize();
38
+ const { ref, size } = useElementSize();
44
39
  const [activeIndex, setActiveIndex] = 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]);
40
+ const animKey = typeof animation === "object" ? JSON.stringify(animation) : String(animation);
41
+ const animConfig = useMemo(
42
+ () => resolveAnimation(animation),
43
+ // eslint-disable-next-line react-hooks/exhaustive-deps
44
+ [animKey]
45
+ );
49
46
  const layout = useMemo(() => {
50
- if (!data) return {
51
- nodes: [],
52
- depth: 0
53
- };
47
+ if (!data)
48
+ return { nodes: [], depth: 0 };
54
49
  return layoutTree(data, {
55
50
  x: 12,
56
51
  y: 16,
@@ -59,50 +54,61 @@ export function TreeChart({
59
54
  height: Math.max(0, size.height - 32)
60
55
  });
61
56
  }, [data, size.width, size.height, labelSpace]);
62
-
63
- // 用叶子数驱动:结构变化时节点位置平滑过渡
64
- const matrix = useMemo(() => [layout.nodes.map(item => Math.round(item.y))], [layout.nodes]);
57
+ const matrix = useMemo(
58
+ () => [layout.nodes.map((item) => Math.round(item.y))],
59
+ [layout.nodes]
60
+ );
65
61
  const transition = useChartTransition(matrix, animConfig);
66
62
  const progress = transition.progress;
67
63
  const scene = useMemo(() => {
68
- if (!layout.nodes.length || size.width <= 0) return [];
64
+ if (!layout.nodes.length || size.width <= 0)
65
+ return [];
69
66
  const nodes = [];
70
- const depthTotal = Math.max(1, maxDepth(data ?? {
71
- name: ''
72
- }));
73
-
74
- // 先画连线,保证节点压在线上
67
+ const depthTotal = Math.max(1, maxDepth(data ?? { name: "" }));
75
68
  layout.nodes.forEach((item, index) => {
76
- if (item.parent < 0) return;
69
+ var _a2, _b;
70
+ if (item.parent < 0)
71
+ return;
77
72
  const parent = layout.nodes[item.parent];
78
- const local = staggerProgress(progress, item.depth, depthTotal, animConfig.stagger);
73
+ const local = staggerProgress(
74
+ progress,
75
+ item.depth,
76
+ depthTotal,
77
+ animConfig.stagger
78
+ );
79
79
  const animatedParent = {
80
80
  ...parent,
81
- y: transition.values[0]?.[item.parent] ?? parent.y
81
+ y: ((_a2 = transition.values[0]) == null ? void 0 : _a2[item.parent]) ?? parent.y
82
82
  };
83
83
  const animatedChild = {
84
84
  ...item,
85
- y: transition.values[0]?.[index] ?? item.y
85
+ y: ((_b = transition.values[0]) == null ? void 0 : _b[index]) ?? item.y
86
86
  };
87
87
  nodes.push({
88
- kind: 'path',
88
+ kind: "path",
89
89
  key: `link-${index}`,
90
90
  d: treeLinkPath(animatedParent, animatedChild, nodeSize),
91
- fill: 'none',
91
+ fill: "none",
92
92
  stroke: withAlpha(theme.axis.line, 0.9),
93
93
  strokeWidth: 1.2,
94
94
  opacity: local,
95
- pointerEvents: 'none'
95
+ pointerEvents: "none"
96
96
  });
97
97
  });
98
98
  layout.nodes.forEach((item, index) => {
99
- const y = transition.values[0]?.[index] ?? item.y;
99
+ var _a2, _b;
100
+ const y = ((_a2 = transition.values[0]) == null ? void 0 : _a2[index]) ?? item.y;
100
101
  const isActive = activeIndex === index;
101
- const hasChildren = Boolean(item.node.children?.length);
102
- const local = staggerProgress(progress, item.depth, depthTotal, animConfig.stagger);
102
+ const hasChildren = Boolean((_b = item.node.children) == null ? void 0 : _b.length);
103
+ const local = staggerProgress(
104
+ progress,
105
+ item.depth,
106
+ depthTotal,
107
+ animConfig.stagger
108
+ );
103
109
  const color = hasChildren ? theme.emphasis : item.node.color ?? theme.palette[item.depth % theme.palette.length];
104
110
  nodes.push({
105
- kind: 'circle',
111
+ kind: "circle",
106
112
  key: `node-${index}`,
107
113
  cx: item.x,
108
114
  cy: y,
@@ -111,35 +117,45 @@ export function TreeChart({
111
117
  stroke: color,
112
118
  strokeWidth: hasChildren ? 2 : 0,
113
119
  opacity: local,
114
- pointerEvents: 'none'
120
+ pointerEvents: "none"
115
121
  });
116
122
  nodes.push({
117
- kind: 'text',
123
+ kind: "text",
118
124
  key: `label-${index}`,
119
125
  x: item.x + nodeSize + 8,
120
126
  y,
121
- text: showValue && item.node.value !== undefined ? `${item.node.name} ${formatNumber(item.node.value, {
122
- compact: true
123
- })}` : item.node.name,
127
+ text: showValue && item.node.value !== void 0 ? `${item.node.name} ${formatNumber(item.node.value, { compact: true })}` : item.node.name,
124
128
  fill: hasChildren ? theme.text.primary : theme.text.secondary,
125
129
  fontSize: theme.font.size,
126
- fontWeight: hasChildren ? theme.font.weightMedium : undefined,
127
- anchor: 'start',
128
- baseline: 'middle',
130
+ fontWeight: hasChildren ? theme.font.weightMedium : void 0,
131
+ anchor: "start",
132
+ baseline: "middle",
129
133
  opacity: local,
130
134
  fontFamily: theme.font.family
131
135
  });
132
136
  });
133
137
  return nodes;
134
- }, [layout, size.width, data, theme, progress, animConfig.stagger, activeIndex, nodeSize, showValue, transition.values]);
138
+ }, [
139
+ layout,
140
+ size.width,
141
+ data,
142
+ theme,
143
+ progress,
144
+ animConfig.stagger,
145
+ activeIndex,
146
+ nodeSize,
147
+ showValue,
148
+ transition.values
149
+ ]);
135
150
  const nodeFromPointer = (clientX, clientY) => {
136
151
  const element = ref.current;
137
- if (!element) return null;
152
+ if (!element)
153
+ return null;
138
154
  const rect = element.getBoundingClientRect();
139
155
  const x = clientX - rect.left;
140
156
  const y = clientY - rect.top;
141
157
  let nearest = null;
142
- let min = 18; // 命中半径,节点本身只有 4px,必须放宽
158
+ let min = 18;
143
159
  layout.nodes.forEach((item, index) => {
144
160
  const distance = Math.hypot(item.x - x, item.y - y);
145
161
  if (distance < min) {
@@ -153,47 +169,58 @@ export function TreeChart({
153
169
  const tooltipPayload = active ? {
154
170
  label: active.node.name,
155
171
  row: null,
156
- series: [{
157
- key: 'value',
158
- name: active.node.children?.length ? '合计' : '数值',
159
- color: theme.emphasis,
160
- value: sumValues(active.node),
161
- formatted: formatNumber(sumValues(active.node), {
162
- compact: true
163
- })
164
- }]
172
+ series: [
173
+ {
174
+ key: "value",
175
+ name: ((_a = active.node.children) == null ? void 0 : _a.length) ? "合计" : "数值",
176
+ color: theme.emphasis,
177
+ value: sumValues(active.node),
178
+ formatted: formatNumber(sumValues(active.node), { compact: true })
179
+ }
180
+ ]
165
181
  } : null;
166
182
  const autoAriaLabel = ariaLabel ?? `树图:${layout.nodes.length} 个节点`;
167
- return /*#__PURE__*/_jsx("div", {
168
- className: classNames(prefixCls('chart'), className),
169
- style: {
170
- width,
171
- height,
172
- ...style
173
- },
174
- "data-aura-chart": "tree",
175
- children: /*#__PURE__*/_jsxs("div", {
176
- ref: ref,
177
- className: prefixCls('chart__plot'),
178
- onPointerMove: event => setActiveIndex(nodeFromPointer(event.clientX, event.clientY)),
179
- onPointerLeave: () => setActiveIndex(null),
180
- children: [!layout.nodes.length || size.width === 0 ? /*#__PURE__*/_jsx("div", {
181
- className: prefixCls('chart__empty'),
182
- children: emptyText
183
- }) : /*#__PURE__*/_jsx(SvgScene, {
184
- nodes: scene,
185
- width: size.width,
186
- height: size.height,
187
- ariaLabel: autoAriaLabel
188
- }), /*#__PURE__*/_jsx(Tooltip, {
189
- payload: tooltipPayload,
190
- x: active ? active.x : 0,
191
- y: active ? active.y - 12 : 0,
192
- containerWidth: size.width,
193
- containerHeight: size.height,
194
- theme: theme,
195
- config: tooltip
196
- })]
197
- })
198
- });
199
- }
183
+ return /* @__PURE__ */ jsx(
184
+ "div",
185
+ {
186
+ className: classNames(prefixCls("chart"), className),
187
+ style: { width, height, ...style },
188
+ "data-aura-chart": "tree",
189
+ children: /* @__PURE__ */ jsxs(
190
+ "div",
191
+ {
192
+ ref,
193
+ className: prefixCls("chart__plot"),
194
+ onPointerMove: (event) => setActiveIndex(nodeFromPointer(event.clientX, event.clientY)),
195
+ onPointerLeave: () => setActiveIndex(null),
196
+ children: [
197
+ !layout.nodes.length || size.width === 0 ? /* @__PURE__ */ jsx("div", { className: prefixCls("chart__empty"), children: emptyText }) : /* @__PURE__ */ jsx(
198
+ SvgScene,
199
+ {
200
+ nodes: scene,
201
+ width: size.width,
202
+ height: size.height,
203
+ ariaLabel: autoAriaLabel
204
+ }
205
+ ),
206
+ /* @__PURE__ */ jsx(
207
+ Tooltip,
208
+ {
209
+ payload: tooltipPayload,
210
+ x: active ? active.x : 0,
211
+ y: active ? active.y - 12 : 0,
212
+ containerWidth: size.width,
213
+ containerHeight: size.height,
214
+ theme,
215
+ config: tooltip
216
+ }
217
+ )
218
+ ]
219
+ }
220
+ )
221
+ }
222
+ );
223
+ }
224
+ export {
225
+ TreeChart
226
+ };
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import { type HierarchyNode } from '../../core/hierarchy';
3
- import { type ChartThemeInput } from '../../theme';
4
- import type { ChartAnimationInput, TooltipConfig } from '../../types';
2
+ import { type HierarchyNode } from '../../core/hierarchy.js';
3
+ import { type ChartThemeInput } from '../../theme/index.js';
4
+ import type { ChartAnimationInput, TooltipConfig } from '../../types.js';
5
5
  export interface TreemapChartProps {
6
6
  /** 根节点;只渲染它的子孙 */
7
7
  data?: HierarchyNode;