UNPKG

3.26 kBJavaScriptView Raw
1import { __assign } from "tslib";
2import { jsx, Smooth } from '@antv/f-engine';
3import { deepMix } from '@antv/util';
4export default (function (props) {
5 var coord = props.coord,
6 records = props.records,
7 baseY = props.baseY,
8 shape = props.shape,
9 animation = props.animation;
10 var isSmooth = shape === 'smooth';
11 var _a = coord,
12 left = _a.left,
13 top = _a.top,
14 width = _a.width,
15 height = _a.height,
16 center = _a.center,
17 startAngle = _a.startAngle,
18 endAngle = _a.endAngle,
19 radius = _a.radius;
20 var appear = coord.isPolar ? {
21 easing: 'quadraticOut',
22 duration: 450,
23 clip: {
24 type: 'sector',
25 property: ['endAngle'],
26 style: {
27 cx: center.x,
28 cy: center.y,
29 startAngle: "".concat(startAngle, "rad"),
30 r: radius
31 },
32 start: {
33 endAngle: "".concat(startAngle, "rad")
34 },
35 end: {
36 endAngle: "".concat(endAngle, "rad")
37 }
38 }
39 } : {
40 easing: 'quadraticOut',
41 duration: 450,
42 clip: {
43 type: 'rect',
44 property: ['width'],
45 style: {
46 x: left,
47 y: top,
48 height: height
49 },
50 start: {
51 width: 0
52 },
53 end: {
54 width: width
55 }
56 }
57 };
58 return jsx("group", null, records.map(function (record) {
59 var key = record.key,
60 children = record.children;
61 return jsx("group", {
62 key: key
63 }, children.map(function (child) {
64 var points = child.points,
65 topPoints = child.topPoints,
66 bottomPoints = child.bottomPoints,
67 color = child.color,
68 shape = child.shape;
69 if (isSmooth) {
70 var generatePath = function generatePath() {
71 var d = [];
72 var constaint = [[0, 0], [1, 1]];
73 var topSps = Smooth.smooth(topPoints, false, constaint);
74 d.push(['M', topPoints[0].x, topPoints[0].y]);
75 for (var i = 0, n = topSps.length; i < n; i++) {
76 var sp = topSps[i];
77 d.push(['C', sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]]);
78 }
79 if (bottomPoints && bottomPoints.length) {
80 var bottomSps = Smooth.smooth(bottomPoints, false, constaint);
81 d.push(['L', bottomPoints[0].x, bottomPoints[0].y]);
82 for (var i = 0, n = bottomSps.length; i < n; i++) {
83 var sp = bottomSps[i];
84 d.push(['C', sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]]);
85 }
86 } else {
87 d.push(['L', topPoints[topPoints.length - 1].x, baseY]);
88 d.push(['L', topPoints[0].x, baseY]);
89 }
90 return d;
91 };
92 return jsx("path", {
93 style: __assign({
94 path: generatePath(),
95 lineWidth: '2px',
96 fill: color
97 }, shape)
98 });
99 }
100 return jsx("polygon", {
101 style: __assign({
102 points: points.map(function (point) {
103 return [point.x, point.y];
104 }),
105 lineWidth: '2px',
106 fill: color
107 }, shape),
108 animation: deepMix({
109 appear: appear,
110 update: {
111 easing: 'linear',
112 duration: 450,
113 property: ['points']
114 }
115 }, animation)
116 });
117 }));
118 }));
119});
\No newline at end of file