UNPKG

@antv/f2

Version:

Charts for mobile visualization.

38 lines 1.22 kB
import { __assign } from "tslib"; import { jsx } from '@antv/f-engine'; import { isArray, deepMix } from '@antv/util'; export default (function (props, context) { var _a = props.theme, theme = _a === void 0 ? {} : _a; var _b = deepMix(__assign({}, theme.line), props), points = _b.points, style = _b.style, offsetX = _b.offsetX, offsetY = _b.offsetY, animation = _b.animation; var checkNaN = points.some(function (d) { return isNaN(d.x) || isNaN(d.y); }); if (checkNaN) return; var _c = points[0] || {}, x1 = _c.x, y1 = _c.y; var _d = points[1] || {}, x2 = _d.x, y2 = _d.y; var offsetXNum = context.px2hd(offsetX); var offsetYNum = context.px2hd(offsetY); var posX1 = x1 + (isArray(offsetXNum) ? offsetXNum[0] || 0 : offsetXNum || 0); var posY1 = y1 + (isArray(offsetYNum) ? offsetYNum[0] || 0 : offsetYNum || 0); var posX2 = x2 + (isArray(offsetXNum) ? offsetXNum[1] || 0 : offsetXNum || 0); var posY2 = y2 + (isArray(offsetYNum) ? offsetYNum[1] || 0 : offsetYNum || 0); return jsx("group", null, jsx("line", { style: __assign({ x1: posX1, y1: posY1, x2: posX2, y2: posY2 }, style), animation: animation })); });