| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- "use strict";
- var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.Vector = void 0;
- const d3_path_1 = require("d3-path");
- const g_1 = require("@antv/g");
- const utils_1 = require("../utils");
- const selection_1 = require("../../utils/selection");
- /**
- * Connect 2 points with a single line with arrow.
- * ----->
- */
- const Vector = (options) => {
- const { arrow = true, arrowSize = '40%' } = options, style = __rest(options, ["arrow", "arrowSize"]);
- return (points, value, coordinate, theme) => {
- const { mark, shape, defaultShape, transform } = value;
- const _a = (0, utils_1.getShapeTheme)(theme, mark, shape, defaultShape), { defaultColor } = _a, shapeTheme = __rest(_a, ["defaultColor"]);
- const { color = defaultColor } = value;
- const [from, to] = points;
- // Draw line
- const path = (0, d3_path_1.path)();
- path.moveTo(...from);
- path.lineTo(...to);
- // Draw 2 arrows.
- if (arrow) {
- // Calculate arrow end point.
- const [arrow1, arrow2] = (0, utils_1.arrowPoints)(from, to, { arrowSize });
- path.moveTo(...to);
- path.lineTo(...arrow1);
- path.moveTo(...to);
- path.lineTo(...arrow2);
- }
- return (0, selection_1.select)(new g_1.Path())
- .call(utils_1.applyStyle, shapeTheme)
- .style('d', path.toString())
- .style('stroke', color || defaultColor)
- .style('transform', transform)
- .call(utils_1.applyStyle, style)
- .node();
- };
- };
- exports.Vector = Vector;
- exports.Vector.props = {
- defaultMarker: 'line',
- defaultEnterAnimation: 'fadeIn',
- defaultUpdateAnimation: 'morphing',
- defaultExitAnimation: 'fadeOut',
- };
- //# sourceMappingURL=vector.js.map
|