UNPKG

1.79 kBJavaScriptView Raw
1import { __assign } from "tslib";
2import { jsx } from '@antv/f-engine';
3export default (function (props) {
4 var lineStyle = props.lineStyle,
5 anchorStyle = props.anchorStyle,
6 labels = props.labels,
7 label1OffsetY = props.label1OffsetY,
8 label2OffsetY = props.label2OffsetY,
9 triggerRef = props.triggerRef,
10 onClick = props.onClick;
11 return jsx("group", {
12 ref: triggerRef
13 }, labels.map(function (label) {
14 var origin = label.origin,
15 anchor = label.anchor,
16 side = label.side,
17 color = label.color,
18 label1 = label.label1,
19 label2 = label.label2,
20 points = label.points;
21 var end = points[points.length - 1];
22 return jsx("group", {
23 onClick: onClick ? function () {
24 onClick(label);
25 } : null
26 }, jsx("circle", {
27 attrs: __assign({
28 r: '4px',
29 cx: anchor.x,
30 cy: anchor.y,
31 fill: color
32 }, anchorStyle)
33 }), jsx("polyline", {
34 attrs: __assign({
35 points: points.map(function (d) {
36 return [d.x, d.y];
37 }),
38 lineWidth: '2px',
39 stroke: color
40 }, lineStyle)
41 }), jsx("text", {
42 className: "click",
43 attrs: __assign({
44 x: end.x,
45 y: end.y + label1OffsetY,
46 fontSize: '24px',
47 lineHeight: '24px',
48 fill: color,
49 textBaseline: 'bottom',
50 textAlign: side === 'left' ? 'left' : 'right'
51 }, label1),
52 data: origin
53 }), jsx("text", {
54 className: "click",
55 attrs: __assign({
56 x: end.x,
57 y: end.y + label2OffsetY,
58 fontSize: '24px',
59 lineHeight: '24px',
60 fill: '#808080',
61 textBaseline: 'top',
62 textAlign: side === 'left' ? 'left' : 'right'
63 }, label2),
64 data: origin
65 }));
66 }));
67});
\No newline at end of file