1 | import { __assign } from "tslib";
|
2 | import { jsx } from '@antv/f-engine';
|
3 | export default (function (props // Coord 在 withTreemap 被转成 Coord 类型了,所以这里需要重新定义
|
4 | ) {
|
5 | var nodes = props.nodes,
|
6 | coord = props.coord,
|
7 | onClick = props.onClick,
|
8 | _a = props.label,
|
9 | label = _a === void 0 ? false : _a;
|
10 | if (coord.isPolar) {
|
11 | var center = coord.center;
|
12 | var x_1 = center.x,
|
13 | y_1 = center.y;
|
14 | return jsx("group", null, nodes.map(function (node) {
|
15 | var xMin = node.xMin,
|
16 | xMax = node.xMax,
|
17 | yMin = node.yMin,
|
18 | yMax = node.yMax,
|
19 | color = node.color,
|
20 | style = node.style;
|
21 | return jsx("sector", {
|
22 | style: __assign({
|
23 | cx: x_1,
|
24 | cy: y_1,
|
25 | lineWidth: '1px',
|
26 | stroke: '#fff',
|
27 | startAngle: xMin,
|
28 | endAngle: xMax,
|
29 | r0: yMin,
|
30 | r: yMax,
|
31 | fill: color
|
32 | }, style),
|
33 | onClick: onClick ? function () {
|
34 | return onClick(node);
|
35 | } : null
|
36 | });
|
37 | }));
|
38 | }
|
39 | return jsx("group", null, nodes.map(function (node) {
|
40 | var key = node.key,
|
41 | xMin = node.xMin,
|
42 | xMax = node.xMax,
|
43 | yMin = node.yMin,
|
44 | yMax = node.yMax,
|
45 | color = node.color,
|
46 | style = node.style;
|
47 | return jsx("group", null, jsx("rect", {
|
48 | key: key,
|
49 | style: __assign({
|
50 | x: xMin,
|
51 | y: yMin,
|
52 | width: xMax - xMin,
|
53 | height: yMax - yMin,
|
54 | fill: color,
|
55 | lineWidth: '4px',
|
56 | stroke: '#fff',
|
57 | radius: '8px'
|
58 | }, style),
|
59 | animation: {
|
60 | appear: {
|
61 | easing: 'linear',
|
62 | duration: 450,
|
63 | property: ['fillOpacity', 'strokeOpacity'],
|
64 | start: {
|
65 | fillOpacity: 0,
|
66 | strokeOpacity: 0
|
67 | }
|
68 | },
|
69 | update: {
|
70 | easing: 'linear',
|
71 | duration: 450,
|
72 | property: ['x', 'y', 'width', 'height', 'radius', 'lineWidth', 'fillOpacity', 'strokeOpacity']
|
73 | }
|
74 | },
|
75 | onClick: onClick ? function () {
|
76 | return onClick(node);
|
77 | } : null
|
78 | }), label && jsx("text", {
|
79 | style: __assign({
|
80 | x: (xMin + xMax) / 2,
|
81 | y: (yMin + yMax) / 2,
|
82 | text: node.origin.name,
|
83 | fill: 'white',
|
84 | textAlign: 'center',
|
85 | textBaseline: 'middle'
|
86 | }, label)
|
87 | }));
|
88 | }));
|
89 | }); |
\ | No newline at end of file |