UNPKG

1.35 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var tslib_1 = require("tslib");
4var util_1 = require("@antv/util");
5var base_1 = require("../base");
6var get_style_1 = require("../util/get-style");
7var CORNER_PERCENT = 1 / 3;
8function getVHVPath(from, to) {
9 var points = [];
10 points.push({
11 x: from.x,
12 y: from.y * (1 - CORNER_PERCENT) + to.y * CORNER_PERCENT,
13 });
14 points.push({
15 x: to.x,
16 y: from.y * (1 - CORNER_PERCENT) + to.y * CORNER_PERCENT,
17 });
18 points.push(to);
19 var path = [['M', from.x, from.y]];
20 (0, util_1.each)(points, function (point) {
21 path.push(['L', point.x, point.y]);
22 });
23 return path;
24}
25(0, base_1.registerShape)('edge', 'vhv', {
26 draw: function (cfg, container) {
27 var style = (0, get_style_1.getStyle)(cfg, true, false, 'lineWidth');
28 var points = cfg.points;
29 var path = this.parsePath(getVHVPath(points[0], points[1]));
30 return container.addShape('path', {
31 attrs: tslib_1.__assign(tslib_1.__assign({}, style), { path: path }),
32 });
33 },
34 getMarker: function (markerCfg) {
35 return {
36 symbol: 'circle',
37 style: {
38 r: 4.5,
39 fill: markerCfg.color,
40 },
41 };
42 },
43});
44//# sourceMappingURL=vhv.js.map
\No newline at end of file