UNPKG

2.25 kBJavaScriptView Raw
1import { __assign } from "tslib";
2import { jsx } from '@antv/f-engine';
3import { deepMix } from '@antv/util';
4export default (function (props) {
5 var records = props.records,
6 animation = props.animation,
7 y0 = props.y0,
8 onClick = props.onClick;
9 return jsx("group", null, records.map(function (record) {
10 var key = record.key,
11 children = record.children;
12 return jsx("group", {
13 key: key
14 }, children.map(function (item) {
15 var key = item.key,
16 xMin = item.xMin,
17 xMax = item.xMax,
18 yMin = item.yMin,
19 yMax = item.yMax,
20 x = item.x,
21 y = item.y,
22 color = item.color,
23 shape = item.shape;
24 if (isNaN(xMin) || isNaN(xMax) || isNaN(yMin) || isNaN(yMax)) {
25 return null;
26 }
27 return jsx("group", null, jsx("line", {
28 key: "".concat(key, "-line"),
29 style: {
30 x1: x,
31 y1: y[2],
32 x2: x,
33 y2: y[3],
34 stroke: color,
35 lineWidth: '2px',
36 lineCap: 'round'
37 },
38 animation: {
39 appear: {
40 easing: 'linear',
41 duration: 300,
42 property: ['y1', 'y2'],
43 // @ts-ignore
44 start: {
45 y1: 0,
46 y2: 0
47 }
48 },
49 update: {
50 easing: 'linear',
51 duration: 300,
52 property: ['x1', 'y1', 'x2', 'y2']
53 }
54 }
55 }), jsx("rect", {
56 key: "".concat(key, "-rect"),
57 style: __assign({
58 x: xMin,
59 y: yMin,
60 // 当 min === max 时,设置 1,否则会出现 0 的情况
61 width: Math.max(xMax - xMin, 1),
62 height: Math.max(yMax - yMin, 1),
63 fill: color,
64 radius: '2px'
65 }, shape),
66 onClick: onClick,
67 animation: deepMix({
68 appear: {
69 easing: 'linear',
70 duration: 300,
71 property: ['y', 'height'],
72 start: {
73 y: y0,
74 height: 0
75 }
76 },
77 update: {
78 easing: 'linear',
79 duration: 300,
80 property: ['x', 'y', 'width', 'height']
81 }
82 }, animation)
83 }));
84 }));
85 }));
86});
\No newline at end of file