UNPKG

1.22 kBJavaScriptView Raw
1import { __assign } from "tslib";
2import { jsx } from '@antv/f-engine';
3import { isArray, deepMix } from '@antv/util';
4export default (function (props, context) {
5 var _a = props.theme,
6 theme = _a === void 0 ? {} : _a;
7 var _b = deepMix(__assign({}, theme.line), props),
8 points = _b.points,
9 style = _b.style,
10 offsetX = _b.offsetX,
11 offsetY = _b.offsetY,
12 animation = _b.animation;
13 var checkNaN = points.some(function (d) {
14 return isNaN(d.x) || isNaN(d.y);
15 });
16 if (checkNaN) return;
17 var _c = points[0] || {},
18 x1 = _c.x,
19 y1 = _c.y;
20 var _d = points[1] || {},
21 x2 = _d.x,
22 y2 = _d.y;
23 var offsetXNum = context.px2hd(offsetX);
24 var offsetYNum = context.px2hd(offsetY);
25 var posX1 = x1 + (isArray(offsetXNum) ? offsetXNum[0] || 0 : offsetXNum || 0);
26 var posY1 = y1 + (isArray(offsetYNum) ? offsetYNum[0] || 0 : offsetYNum || 0);
27 var posX2 = x2 + (isArray(offsetXNum) ? offsetXNum[1] || 0 : offsetXNum || 0);
28 var posY2 = y2 + (isArray(offsetYNum) ? offsetYNum[1] || 0 : offsetYNum || 0);
29 return jsx("group", null, jsx("line", {
30 style: __assign({
31 x1: posX1,
32 y1: posY1,
33 x2: posX2,
34 y2: posY2
35 }, style),
36 animation: animation
37 }));
38});
\No newline at end of file