UNPKG

@antv/f2

Version:

Charts for mobile visualization.

32 lines 1 kB
import { __assign } from "tslib"; import { jsx } from '@antv/f-engine'; import { deepMix } from '@antv/util'; export default (function (props, context) { var _a = props.theme, theme = _a === void 0 ? {} : _a; var _b = deepMix(__assign({}, theme.rect), props), points = _b.points, style = _b.style, animation = _b.animation, offsetX = _b.offsetX, offsetY = _b.offsetY; var checkNaN = points.some(function (d) { return isNaN(d.x) || isNaN(d.y); }); if (checkNaN) return null; var start = points[0] || {}; var end = points[1] || {}; var offsetXNum = context.px2hd(offsetX); var offsetYNum = context.px2hd(offsetY); var posX = Math.min(start.x, end.x) + (offsetXNum || 0); var posY = Math.min(start.y, end.y) + (offsetYNum || 0); return jsx("group", null, jsx("rect", { style: __assign({ x: posX, y: posY, width: Math.abs(end.x - start.x), height: Math.abs(start.y - end.y) }, style), animation: animation })); });