1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var tslib_1 = require("tslib");
|
4 | var graphics_1 = require("../../../util/graphics");
|
5 | var base_1 = require("../base");
|
6 | var get_style_1 = require("../util/get-style");
|
7 | var util_1 = require("./util");
|
8 | function getArcShapePath(from, to, center) {
|
9 | var sub = (0, util_1.getQPath)(to, center);
|
10 | var path = [['M', from.x, from.y]];
|
11 | path.push(sub);
|
12 | return path;
|
13 | }
|
14 | function getArcShapeWeightPath(points, center) {
|
15 | var arc1 = (0, util_1.getQPath)(points[1], center);
|
16 | var arc2 = (0, util_1.getQPath)(points[3], center);
|
17 | var path = [['M', points[0].x, points[0].y]];
|
18 | path.push(arc2);
|
19 | path.push(['L', points[3].x, points[3].y]);
|
20 | path.push(['L', points[2].x, points[2].y]);
|
21 | path.push(arc1);
|
22 | path.push(['L', points[1].x, points[1].y]);
|
23 | path.push(['L', points[0].x, points[0].y]);
|
24 | path.push(['Z']);
|
25 | return path;
|
26 | }
|
27 |
|
28 | (0, base_1.registerShape)('edge', 'arc', {
|
29 | draw: function (cfg, container) {
|
30 | var style = (0, get_style_1.getStyle)(cfg, true, false, 'lineWidth');
|
31 | var points = cfg.points;
|
32 | var type = points.length > 2 ? 'weight' : 'normal';
|
33 | var path;
|
34 | if (cfg.isInCircle) {
|
35 | var center = { x: 0, y: 1 };
|
36 | if (type === 'normal') {
|
37 | path = getArcShapePath(points[0], points[1], center);
|
38 | }
|
39 | else {
|
40 | style.fill = style.stroke;
|
41 | path = getArcShapeWeightPath(points, center);
|
42 | }
|
43 | path = this.parsePath(path);
|
44 | return container.addShape('path', {
|
45 | attrs: tslib_1.__assign(tslib_1.__assign({}, style), { path: path }),
|
46 | });
|
47 | }
|
48 | else {
|
49 | if (type === 'normal') {
|
50 | points = this.parsePoints(points);
|
51 | path = (0, graphics_1.getArcPath)((points[1].x + points[0].x) / 2, points[0].y, Math.abs(points[1].x - points[0].x) / 2, Math.PI, Math.PI * 2);
|
52 | return container.addShape('path', {
|
53 | attrs: tslib_1.__assign(tslib_1.__assign({}, style), { path: path }),
|
54 | });
|
55 | }
|
56 | else {
|
57 | var c1 = (0, util_1.getCPath)(points[1], points[3]);
|
58 | var c2 = (0, util_1.getCPath)(points[2], points[0]);
|
59 | path = [
|
60 | ['M', points[0].x, points[0].y],
|
61 | ['L', points[1].x, points[1].y],
|
62 | c1,
|
63 | ['L', points[3].x, points[3].y],
|
64 | ['L', points[2].x, points[2].y],
|
65 | c2,
|
66 | ['Z'],
|
67 | ];
|
68 | path = this.parsePath(path);
|
69 | style.fill = style.stroke;
|
70 | return container.addShape('path', {
|
71 | attrs: tslib_1.__assign(tslib_1.__assign({}, style), { path: path }),
|
72 | });
|
73 | }
|
74 | }
|
75 | },
|
76 | getMarker: function (markerCfg) {
|
77 | return {
|
78 | symbol: 'circle',
|
79 | style: {
|
80 | r: 4.5,
|
81 | fill: markerCfg.color,
|
82 | },
|
83 | };
|
84 | },
|
85 | });
|
86 |
|
\ | No newline at end of file |