UNPKG

@antv/f2

Version:

Charts for mobile visualization.

133 lines (132 loc) 3.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _tslib = require("tslib"); var _fEngine = require("@antv/f-engine"); var _util = require("@antv/util"); function concatPoints(children) { var result = []; for (var i = 0; i < children.length; i++) { var child = children[i]; result = result.concat(child.points); } return result; } var _default = exports.default = function _default(props) { var records = props.records, coord = props.coord, animation = props.animation, EndView = props.endView, clip = props.clip; var _a = coord, left = _a.left, top = _a.top, width = _a.width, height = _a.height, center = _a.center, startAngle = _a.startAngle, endAngle = _a.endAngle, radius = _a.radius; var appear = coord.isPolar ? { easing: 'quadraticOut', duration: 450, clip: { type: 'sector', property: ['endAngle'], style: { cx: center.x, cy: center.y, startAngle: "".concat(startAngle, "rad"), r: radius }, start: { endAngle: "".concat(startAngle, "rad") }, end: { endAngle: "".concat(endAngle, "rad") } } } : { easing: 'quadraticOut', duration: 450, clip: { type: 'rect', property: ['width'], style: { x: left, y: top, height: height }, start: { width: 0 }, end: { width: width } } }; return (0, _fEngine.jsx)("group", { style: { clip: clip } }, records.map(function (record) { var _a; var key = record.key, children = record.children; var points = concatPoints(children); var ref = (0, _fEngine.createRef)(); return (0, _fEngine.jsx)("group", { key: key }, children.map(function (child) { var points = child.points, color = child.color, size = child.size, shape = child.shape; var fliterPoints = points.filter(function (point) { return !isNaN(point.x) && !isNaN(point.y); }); if (fliterPoints.length === 0) return; return (0, _fEngine.jsx)("polyline", { key: key, ref: ref, style: (0, _tslib.__assign)((0, _tslib.__assign)({ points: fliterPoints.map(function (point) { return [point.x, point.y]; }), stroke: color }, shape), { lineWidth: size || shape.lineWidth }), animation: (0, _util.deepMix)({ update: { easing: 'linear', duration: 450, property: ['points'] }, appear: appear }, animation) }); }), EndView ? (0, _fEngine.jsx)("group", { style: { offset: ref }, animation: (0, _util.deepMix)({ appear: { easing: 'quadraticOut', duration: 450, property: ['offsetDistance'], start: { offsetDistance: 0 }, end: { offsetDistance: 1 } } }, animation) }, (0, _fEngine.jsx)(EndView, { origin: (_a = points[0]) === null || _a === void 0 ? void 0 : _a.origin })) : null); })); };