@visactor/vrender-components 0.12.3 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/axis/base.d.ts +2 -1
- package/cjs/axis/base.js +8 -6
- package/cjs/axis/base.js.map +1 -1
- package/cjs/axis/circle.d.ts +3 -2
- package/cjs/axis/circle.js +1 -0
- package/cjs/axis/circle.js.map +1 -1
- package/cjs/axis/line.d.ts +3 -2
- package/cjs/axis/line.js +26 -4
- package/cjs/axis/line.js.map +1 -1
- package/cjs/axis/overlap/auto-hide.d.ts +9 -0
- package/cjs/axis/overlap/auto-hide.js +62 -0
- package/cjs/axis/overlap/auto-hide.js.map +1 -0
- package/cjs/axis/overlap/auto-limit.d.ts +8 -0
- package/cjs/axis/overlap/auto-limit.js +21 -0
- package/cjs/axis/overlap/auto-limit.js.map +1 -0
- package/cjs/axis/overlap/auto-rotate.d.ts +7 -0
- package/cjs/axis/overlap/auto-rotate.js +103 -0
- package/cjs/axis/overlap/auto-rotate.js.map +1 -0
- package/cjs/axis/type.d.ts +20 -11
- package/cjs/axis/type.js.map +1 -1
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +10 -9
- package/cjs/index.js.map +1 -1
- package/cjs/legend/discrete/discrete.js +1 -1
- package/cjs/legend/discrete/discrete.js.map +1 -1
- package/cjs/marker/area.d.ts +4 -3
- package/cjs/marker/area.js +12 -4
- package/cjs/marker/area.js.map +1 -1
- package/cjs/marker/base.d.ts +5 -4
- package/cjs/marker/base.js +5 -5
- package/cjs/marker/base.js.map +1 -1
- package/cjs/marker/line.d.ts +4 -3
- package/cjs/marker/line.js +17 -6
- package/cjs/marker/line.js.map +1 -1
- package/cjs/marker/point.d.ts +16 -8
- package/cjs/marker/point.js +54 -26
- package/cjs/marker/point.js.map +1 -1
- package/cjs/poptip/contribution.d.ts +6 -0
- package/cjs/poptip/contribution.js +34 -0
- package/cjs/poptip/contribution.js.map +1 -0
- package/cjs/poptip/index.d.ts +3 -0
- package/cjs/poptip/index.js +22 -0
- package/cjs/poptip/index.js.map +1 -0
- package/cjs/poptip/poptip-plugin.d.ts +14 -0
- package/cjs/poptip/poptip-plugin.js +43 -0
- package/cjs/poptip/poptip-plugin.js.map +1 -0
- package/cjs/poptip/poptip.d.ts +13 -0
- package/cjs/poptip/poptip.js +201 -0
- package/cjs/poptip/poptip.js.map +1 -0
- package/cjs/poptip/register.d.ts +3 -0
- package/cjs/poptip/register.js +17 -0
- package/cjs/poptip/register.js.map +1 -0
- package/cjs/poptip/type.d.ts +29 -0
- package/cjs/poptip/type.js +6 -0
- package/cjs/poptip/type.js.map +1 -0
- package/cjs/segment/segment.d.ts +2 -2
- package/cjs/segment/segment.js +3 -1
- package/cjs/segment/segment.js.map +1 -1
- package/cjs/segment/type.d.ts +3 -2
- package/cjs/segment/type.js.map +1 -1
- package/cjs/tag/tag.d.ts +1 -1
- package/cjs/tag/tag.js +1 -1
- package/cjs/tag/tag.js.map +1 -1
- package/cjs/tooltip/tooltip.js +29 -15
- package/cjs/tooltip/tooltip.js.map +1 -1
- package/cjs/tooltip/type.d.ts +5 -2
- package/cjs/tooltip/type.js.map +1 -1
- package/cjs/tooltip/util.d.ts +3 -1
- package/cjs/tooltip/util.js +18 -1
- package/cjs/tooltip/util.js.map +1 -1
- package/cjs/util/text.d.ts +3 -2
- package/cjs/util/text.js.map +1 -1
- package/dist/index.js +761 -74
- package/dist/index.min.js +1 -1
- package/es/axis/base.d.ts +2 -1
- package/es/axis/base.js +7 -6
- package/es/axis/base.js.map +1 -1
- package/es/axis/circle.d.ts +3 -2
- package/es/axis/circle.js +1 -0
- package/es/axis/circle.js.map +1 -1
- package/es/axis/line.d.ts +3 -2
- package/es/axis/line.js +32 -4
- package/es/axis/line.js.map +1 -1
- package/es/axis/overlap/auto-hide.d.ts +9 -0
- package/es/axis/overlap/auto-hide.js +53 -0
- package/es/axis/overlap/auto-hide.js.map +1 -0
- package/es/axis/overlap/auto-limit.d.ts +8 -0
- package/es/axis/overlap/auto-limit.js +13 -0
- package/es/axis/overlap/auto-limit.js.map +1 -0
- package/es/axis/overlap/auto-rotate.d.ts +7 -0
- package/es/axis/overlap/auto-rotate.js +95 -0
- package/es/axis/overlap/auto-rotate.js.map +1 -0
- package/es/axis/type.d.ts +20 -11
- package/es/axis/type.js.map +1 -1
- package/es/index.d.ts +2 -1
- package/es/index.js +3 -1
- package/es/index.js.map +1 -1
- package/es/legend/discrete/discrete.js +1 -1
- package/es/legend/discrete/discrete.js.map +1 -1
- package/es/marker/area.d.ts +4 -3
- package/es/marker/area.js +12 -4
- package/es/marker/area.js.map +1 -1
- package/es/marker/base.d.ts +5 -4
- package/es/marker/base.js +5 -5
- package/es/marker/base.js.map +1 -1
- package/es/marker/line.d.ts +4 -3
- package/es/marker/line.js +17 -6
- package/es/marker/line.js.map +1 -1
- package/es/marker/point.d.ts +16 -8
- package/es/marker/point.js +54 -26
- package/es/marker/point.js.map +1 -1
- package/es/poptip/contribution.d.ts +6 -0
- package/es/poptip/contribution.js +31 -0
- package/es/poptip/contribution.js.map +1 -0
- package/es/poptip/index.d.ts +3 -0
- package/es/poptip/index.js +6 -0
- package/es/poptip/index.js.map +1 -0
- package/es/poptip/poptip-plugin.d.ts +14 -0
- package/es/poptip/poptip-plugin.js +41 -0
- package/es/poptip/poptip-plugin.js.map +1 -0
- package/es/poptip/poptip.d.ts +13 -0
- package/es/poptip/poptip.js +194 -0
- package/es/poptip/poptip.js.map +1 -0
- package/es/poptip/register.d.ts +3 -0
- package/es/poptip/register.js +17 -0
- package/es/poptip/register.js.map +1 -0
- package/es/poptip/type.d.ts +29 -0
- package/es/poptip/type.js +2 -0
- package/es/poptip/type.js.map +1 -0
- package/es/segment/segment.d.ts +2 -2
- package/es/segment/segment.js +3 -1
- package/es/segment/segment.js.map +1 -1
- package/es/segment/type.d.ts +3 -2
- package/es/segment/type.js.map +1 -1
- package/es/tag/tag.d.ts +1 -1
- package/es/tag/tag.js +1 -1
- package/es/tag/tag.js.map +1 -1
- package/es/tooltip/tooltip.js +30 -15
- package/es/tooltip/tooltip.js.map +1 -1
- package/es/tooltip/type.d.ts +5 -2
- package/es/tooltip/type.js.map +1 -1
- package/es/tooltip/util.d.ts +3 -1
- package/es/tooltip/util.js +16 -1
- package/es/tooltip/util.js.map +1 -1
- package/es/util/text.d.ts +3 -2
- package/es/util/text.js.map +1 -1
- package/package.json +8 -7
package/cjs/marker/point.js
CHANGED
|
@@ -14,15 +14,15 @@ class MarkPoint extends base_1.Marker {
|
|
|
14
14
|
setItemAttributes(item, itemContent, itemPosition, itemType) {
|
|
15
15
|
var _a;
|
|
16
16
|
const {autoRotate: autoRotate = !0, refX: refX = 0, refY: refY = 0, refAngle: refAngle = 0, textStyle: textStyle, richTextStyle: richTextStyle, imageStyle: imageStyle, position: position = type_1.IMarkPointItemPosition.middle} = itemContent, itemAngle = (null === (_a = this._line) || void 0 === _a ? void 0 : _a.getEndAngle()) || 0, itemOffsetX = refX * Math.cos(itemAngle) + refY * Math.cos(itemAngle - Math.PI / 2), itemOffsetY = refX * Math.sin(itemAngle) + refY * Math.sin(itemAngle - Math.PI / 2);
|
|
17
|
-
"text" === itemType ? item.setAttributes(Object.assign(Object.assign({}, textStyle), {
|
|
17
|
+
"text" === itemType ? null == item || item.setAttributes(Object.assign(Object.assign({}, textStyle), {
|
|
18
18
|
textStyle: Object.assign(Object.assign({}, config_1.DEFAULT_MARK_POINT_TEXT_STYLE_MAP[(null == itemContent ? void 0 : itemContent.position) || "end"]), null == textStyle ? void 0 : textStyle.textStyle)
|
|
19
|
-
})) : "richText" === itemType ? item.setAttributes({
|
|
19
|
+
})) : "richText" === itemType ? null == item || item.setAttributes({
|
|
20
20
|
dx: this.getItemDx(item, position, richTextStyle) + ((null == richTextStyle ? void 0 : richTextStyle.dx) || 0),
|
|
21
21
|
dy: this.getItemDy(item, position, richTextStyle) + ((null == richTextStyle ? void 0 : richTextStyle.dy) || 0)
|
|
22
|
-
}) : "image" === itemType && item.setAttributes({
|
|
22
|
+
}) : "image" === itemType && (null == item || item.setAttributes({
|
|
23
23
|
dx: this.getItemDx(item, position, imageStyle) + ((null == imageStyle ? void 0 : imageStyle.dx) || 0),
|
|
24
24
|
dy: this.getItemDy(item, position, imageStyle) + ((null == imageStyle ? void 0 : imageStyle.dy) || 0)
|
|
25
|
-
}), item.setAttributes({
|
|
25
|
+
})), null == item || item.setAttributes({
|
|
26
26
|
x: itemPosition.x + (itemOffsetX || 0),
|
|
27
27
|
y: itemPosition.y + (itemOffsetY || 0),
|
|
28
28
|
angle: autoRotate && itemAngle + refAngle
|
|
@@ -38,7 +38,7 @@ class MarkPoint extends base_1.Marker {
|
|
|
38
38
|
const height = null !== (_b = null === (_a = null == item ? void 0 : item.AABBBounds) || void 0 === _a ? void 0 : _a.height()) && void 0 !== _b ? _b : (null == style ? void 0 : style.height) || 0;
|
|
39
39
|
return position.includes("top") || position.includes("Top") ? -height : position.includes("middle") || position.includes("Middle") ? -height / 2 : 0;
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
initItem(itemContent, itemPosition) {
|
|
42
42
|
const {type: type = "text", symbolStyle: symbolStyle, richTextStyle: richTextStyle, imageStyle: imageStyle, renderCustomCallback: renderCustomCallback} = itemContent;
|
|
43
43
|
let item;
|
|
44
44
|
return "symbol" === type ? item = (0, vrender_1.createSymbol)(Object.assign(Object.assign({}, itemPosition), symbolStyle)) : "text" === type ? item = new tag_1.Tag(Object.assign({}, itemPosition)) : "richText" === type ? item = (0,
|
|
@@ -46,10 +46,10 @@ class MarkPoint extends base_1.Marker {
|
|
|
46
46
|
vrender_1.createImage)(Object.assign(Object.assign({}, itemPosition), imageStyle)) : "custom" === type && renderCustomCallback && (item = renderCustomCallback()),
|
|
47
47
|
this.setItemAttributes(item, itemContent, itemPosition, type), item;
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
const {startSymbol: startSymbol, endSymbol: endSymbol, lineStyle: lineStyle, type: type = "type-s"} = itemLine;
|
|
49
|
+
getItemLineAttr(itemLine, position, itemPosition) {
|
|
51
50
|
let points = [];
|
|
52
|
-
|
|
51
|
+
const {type: type = "type-s"} = itemLine;
|
|
52
|
+
return points = "type-do" === type ? [ position, {
|
|
53
53
|
x: (position.x + itemPosition.x) / 2,
|
|
54
54
|
y: itemPosition.y
|
|
55
55
|
}, itemPosition ] : "type-po" === type ? [ position, {
|
|
@@ -58,18 +58,33 @@ class MarkPoint extends base_1.Marker {
|
|
|
58
58
|
}, itemPosition ] : "type-op" === type ? [ position, {
|
|
59
59
|
x: position.x,
|
|
60
60
|
y: itemPosition.y
|
|
61
|
-
}, itemPosition ] : [ position, itemPosition ];
|
|
62
|
-
|
|
61
|
+
}, itemPosition ] : [ position, itemPosition ], points;
|
|
62
|
+
}
|
|
63
|
+
setItemLineAttr(itemLine, position, itemPosition, visible) {
|
|
64
|
+
var _a;
|
|
65
|
+
const {startSymbol: startSymbol, endSymbol: endSymbol, lineStyle: lineStyle} = itemLine, points = this.getItemLineAttr(itemLine, position, itemPosition);
|
|
66
|
+
null === (_a = this._line) || void 0 === _a || _a.setAttributes({
|
|
63
67
|
points: points,
|
|
64
68
|
startSymbol: startSymbol,
|
|
65
69
|
endSymbol: endSymbol,
|
|
66
|
-
lineStyle: lineStyle
|
|
70
|
+
lineStyle: lineStyle,
|
|
71
|
+
visible: visible
|
|
67
72
|
});
|
|
68
73
|
}
|
|
69
|
-
|
|
74
|
+
getDecorativeLineAttr(itemLine, itemPosition) {
|
|
70
75
|
var _a;
|
|
71
|
-
const
|
|
72
|
-
return
|
|
76
|
+
const decorativeLength = (null === (_a = null == itemLine ? void 0 : itemLine.decorativeLine) || void 0 === _a ? void 0 : _a.length) || 10, itemAngle = this._line.getEndAngle() || 0;
|
|
77
|
+
return {
|
|
78
|
+
startPointOffsetX: decorativeLength / 2 * Math.cos(itemAngle - Math.PI / 2),
|
|
79
|
+
startPointOffsetY: decorativeLength / 2 * Math.sin(itemAngle - Math.PI / 2),
|
|
80
|
+
endPointOffsetX: -decorativeLength / 2 * Math.cos(itemAngle - Math.PI / 2),
|
|
81
|
+
endPointOffsetY: -decorativeLength / 2 * Math.sin(itemAngle - Math.PI / 2)
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
setDecorativeLineAttr(itemLine, itemPosition, visible) {
|
|
85
|
+
var _a;
|
|
86
|
+
const {lineStyle: lineStyle} = itemLine, {startPointOffsetX: startPointOffsetX, startPointOffsetY: startPointOffsetY, endPointOffsetX: endPointOffsetX, endPointOffsetY: endPointOffsetY} = this.getDecorativeLineAttr(itemLine, itemPosition);
|
|
87
|
+
null === (_a = this._decorativeLine) || void 0 === _a || _a.setAttributes(Object.assign(Object.assign({
|
|
73
88
|
points: [ {
|
|
74
89
|
x: itemPosition.x + startPointOffsetX,
|
|
75
90
|
y: itemPosition.y + startPointOffsetY
|
|
@@ -77,25 +92,38 @@ class MarkPoint extends base_1.Marker {
|
|
|
77
92
|
x: itemPosition.x + endPointOffsetX,
|
|
78
93
|
y: itemPosition.y + endPointOffsetY
|
|
79
94
|
} ]
|
|
80
|
-
}, lineStyle)
|
|
95
|
+
}, lineStyle), {
|
|
96
|
+
visible: visible
|
|
97
|
+
}));
|
|
81
98
|
}
|
|
82
|
-
|
|
99
|
+
initMarker(container) {
|
|
83
100
|
var _a;
|
|
84
101
|
const {position: position, itemLine: itemLine, itemContent: itemContent} = this.attribute, itemPosition = {
|
|
85
102
|
x: position.x + ((null == itemContent ? void 0 : itemContent.offsetX) || 0),
|
|
86
103
|
y: position.y + ((null == itemContent ? void 0 : itemContent.offsetY) || 0)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
104
|
+
}, line = new segment_1.Segment({
|
|
105
|
+
points: []
|
|
106
|
+
});
|
|
107
|
+
line.name = "mark-point-line", this._line = line, container.add(line);
|
|
108
|
+
const decorativeLine = (0, vrender_1.createLine)({
|
|
109
|
+
points: []
|
|
110
|
+
});
|
|
111
|
+
decorativeLine.name = "mark-point-decorativeLine", this._decorativeLine = decorativeLine,
|
|
112
|
+
container.add(decorativeLine), this.setItemLineAttr(itemLine, position, itemPosition, null == itemLine ? void 0 : itemLine.visible),
|
|
113
|
+
this.setDecorativeLineAttr(itemLine, itemPosition, null === (_a = null == itemLine ? void 0 : itemLine.decorativeLine) || void 0 === _a ? void 0 : _a.visible);
|
|
114
|
+
const item = this.initItem(itemContent, itemPosition);
|
|
97
115
|
this._item = item, container.add(item);
|
|
98
116
|
}
|
|
117
|
+
updateMarker() {
|
|
118
|
+
var _a;
|
|
119
|
+
const {position: position, itemLine: itemLine, itemContent: itemContent} = this.attribute, {type: type = "text"} = itemContent, itemPosition = {
|
|
120
|
+
x: position.x + ((null == itemContent ? void 0 : itemContent.offsetX) || 0),
|
|
121
|
+
y: position.y + ((null == itemContent ? void 0 : itemContent.offsetY) || 0)
|
|
122
|
+
};
|
|
123
|
+
this.setItemLineAttr(itemLine, position, itemPosition, null == itemLine ? void 0 : itemLine.visible),
|
|
124
|
+
this.setDecorativeLineAttr(itemLine, itemPosition, null === (_a = null == itemLine ? void 0 : itemLine.decorativeLine) || void 0 === _a ? void 0 : _a.visible),
|
|
125
|
+
this.setItemAttributes(this._item, itemContent, itemPosition, type);
|
|
126
|
+
}
|
|
99
127
|
}
|
|
100
128
|
|
|
101
129
|
exports.MarkPoint = MarkPoint, MarkPoint.defaultAttributes = config_1.DEFAULT_MARK_POINT_THEME;
|
package/cjs/marker/point.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["marker/point.ts"],"names":[],"mappings":";;;AAAA,+CAa2B;AAC3B,6CAAqD;AACrD,wCAAqC;AACrC,gCAA6B;AAC7B,iCAAgC;AAChC,qCAAuF;AACvF,iCAAyF;AAEzF,MAAa,SAAU,SAAQ,aAAsB;IASnD,YAAY,UAA0B;QACpC,KAAK,CAAC,IAAA,cAAK,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age,\n createLine,\n IGroup,\n IImage,\n INode,\n ISymbol,\n IImageGraphicAttribute,\n IRichText,\n IRichTextGraphicAttribute,\n ILine\n} from '@visactor/vrender';\nimport { IPointLike, merge } from '@visactor/vutils';\nimport { Segment } from '../segment';\nimport { Tag } from '../tag';\nimport { Marker } from './base';\nimport { DEFAULT_MARK_POINT_TEXT_STYLE_MAP, DEFAULT_MARK_POINT_THEME } from './config';\nimport { IItemContent, IItemLine, IMarkPointItemPosition, MarkPointAttrs } from './type';\n\nexport class MarkPoint extends Marker<MarkPointAttrs> {\n static defaultAttributes = DEFAULT_MARK_POINT_THEME;\n\n private _item!: ISymbol | Tag | IImage | IRichText;\n\n private _line?: Segment;\n\n private _decorativeLine!: ILine;\n\n constructor(attributes: MarkPointAttrs) {\n super(merge({}, MarkPoint.defaultAttributes, attributes));\n }\n\n protected setLabelPos() {\n //do nothing\n }\n\n protected setItemAttributes(\n item: ISymbol | Tag | IImage | IRichText,\n itemContent: IItemContent,\n itemPosition: IPointLike,\n itemType: 'symbol' | 'text' | 'image' | 'richText' | 'custom'\n ) {\n const {\n autoRotate = true,\n refX = 0,\n refY = 0,\n refAngle = 0,\n textStyle,\n richTextStyle,\n imageStyle,\n position = IMarkPointItemPosition.middle\n } = itemContent;\n const itemAngle = this._line?.getEndAngle() || 0;\n const itemOffsetX = refX * Math.cos(itemAngle) + refY * Math.cos(itemAngle - Math.PI / 2);\n const itemOffsetY = refX * Math.sin(itemAngle) + refY * Math.sin(itemAngle - Math.PI / 2);\n if (itemType === 'text') {\n item.setAttributes({\n ...textStyle,\n textStyle: {\n ...DEFAULT_MARK_POINT_TEXT_STYLE_MAP[itemContent?.position || 'end'],\n ...textStyle?.textStyle\n }\n });\n } else if (itemType === 'richText') {\n item.setAttributes({\n dx: this.getItemDx(item, position, richTextStyle) + (richTextStyle?.dx || 0),\n dy: this.getItemDy(item, position, richTextStyle) + (richTextStyle?.dy || 0)\n });\n } else if (itemType === 'image') {\n item.setAttributes({\n dx: this.getItemDx(item, position, imageStyle) + (imageStyle?.dx || 0),\n dy: this.getItemDy(item, position, imageStyle) + (imageStyle?.dy || 0)\n });\n }\n item.setAttributes({\n x: itemPosition.x + (itemOffsetX || 0),\n y: itemPosition.y + (itemOffsetY || 0),\n angle: autoRotate && itemAngle + refAngle\n });\n }\n\n protected getItemDx(\n item: ISymbol | Tag | IImage | IRichText,\n position: IMarkPointItemPosition,\n style?: IImageGraphicAttribute | IRichTextGraphicAttribute\n ) {\n const width = (item as IGroup)?.AABBBounds?.width() ?? (style?.width || 0);\n if (position.includes('inside')) {\n return -width;\n } else if (position === 'insideTop') {\n return 0;\n }\n return 0;\n }\n\n protected getItemDy(\n item: ISymbol | Tag | IImage | IRichText,\n position: IMarkPointItemPosition,\n style?: IImageGraphicAttribute | IRichTextGraphicAttribute\n ) {\n const height = (item as IGroup)?.AABBBounds?.height() ?? (style?.height || 0);\n if (position.includes('top') || position.includes('Top')) {\n return -height;\n } else if (position.includes('middle') || position.includes('Middle')) {\n return -height / 2;\n }\n return 0;\n }\n\n protected renderItem(itemContent: IItemContent, itemPosition: IPointLike) {\n const { type = 'text', symbolStyle, richTextStyle, imageStyle, renderCustomCallback } = itemContent;\n let item: ISymbol | Tag | IImage | IRichText | IGroup;\n if (type === 'symbol') {\n item = createSymbol({\n ...itemPosition,\n ...symbolStyle\n });\n } else if (type === 'text') {\n item = new Tag({\n ...itemPosition\n });\n } else if (type === 'richText') {\n item = createRichText({\n ...itemPosition,\n ...richTextStyle\n });\n } else if (type === 'image') {\n item = createImage({\n ...itemPosition,\n ...imageStyle\n });\n } else if (type === 'custom' && renderCustomCallback) {\n item = renderCustomCallback();\n }\n this.setItemAttributes(item, itemContent, itemPosition, type);\n return item;\n }\n\n protected renderItemLine(itemLine: IItemLine, position: IPointLike, itemPosition: IPointLike) {\n const { startSymbol, endSymbol, lineStyle, type = 'type-s' } = itemLine;\n let points: IPointLike[] = [];\n if (type === 'type-do') {\n points = [\n position,\n {\n x: (position.x + itemPosition.x) / 2,\n y: itemPosition.y\n },\n itemPosition\n ];\n } else if (type === 'type-po') {\n points = [\n position,\n {\n x: itemPosition.x,\n y: position.y\n },\n itemPosition\n ];\n } else if (type === 'type-op') {\n points = [\n position,\n {\n x: position.x,\n y: itemPosition.y\n },\n itemPosition\n ];\n } else {\n points = [position, itemPosition];\n }\n\n const line = new Segment({\n points,\n startSymbol,\n endSymbol,\n lineStyle\n });\n return line;\n }\n\n protected renderDecorativeLine(itemLine: IItemLine, itemPosition: IPointLike) {\n const { lineStyle } = itemLine;\n const decorativeLength = itemLine?.decorativeLine?.length || 10;\n const itemAngle = this._line.getEndAngle() || 0;\n const startPointOffsetX = (decorativeLength / 2) * Math.cos(itemAngle - Math.PI / 2);\n const startPointOffsetY = (decorativeLength / 2) * Math.sin(itemAngle - Math.PI / 2);\n const endPointOffsetX = (-decorativeLength / 2) * Math.cos(itemAngle - Math.PI / 2);\n const endPointOffsetY = (-decorativeLength / 2) * Math.sin(itemAngle - Math.PI / 2);\n return createLine({\n points: [\n {\n x: itemPosition.x + startPointOffsetX,\n y: itemPosition.y + startPointOffsetY\n },\n {\n x: itemPosition.x + endPointOffsetX,\n y: itemPosition.y + endPointOffsetY\n }\n ],\n ...lineStyle\n });\n }\n\n protected renderMarker(container: IGroup) {\n const { position, itemLine, itemContent } = this.attribute as MarkPointAttrs;\n const itemPosition = {\n x: position.x + (itemContent?.offsetX || 0),\n y: position.y + (itemContent?.offsetY || 0)\n };\n\n if (itemLine?.visible) {\n const line = this.renderItemLine(itemLine, position, itemPosition);\n line.name = 'mark-point-line';\n this._line = line;\n container.add(line as unknown as INode);\n\n if (itemLine?.decorativeLine?.visible) {\n const decorativeLine = this.renderDecorativeLine(itemLine, itemPosition);\n decorativeLine.name = 'mark-point-decorativeLine';\n this._decorativeLine = decorativeLine;\n container.add(decorativeLine as unknown as INode);\n }\n }\n\n const item = this.renderItem(itemContent as any, itemPosition);\n this._item = item;\n container.add(item as unknown as INode);\n }\n}\n"]}
|
|
1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WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,KAAI,CAAC,CAAC;SAC5C,CAAC;QACF,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,CAAC,CAAC;QAC1E,IAAI,CAAC,qBAAqB,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,cAAc,0CAAE,OAAO,CAAC,CAAC;QACtF,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;IACtE,CAAC;;AAnPH,8BAoPC;AAnPQ,2BAAiB,GAAG,iCAAwB,CAAC","file":"point.js","sourcesContent":["import type {\n IGroup,\n IImage,\n INode,\n ISymbol,\n IImageGraphicAttribute,\n IRichText,\n IRichTextGraphicAttribute,\n ILine\n} from '@visactor/vrender';\nimport { createRichText, createSymbol, createImage, createLine } from '@visactor/vrender';\nimport type { IPointLike } from '@visactor/vutils';\nimport { merge } from '@visactor/vutils';\nimport { Segment } from '../segment';\nimport { Tag } from '../tag';\nimport { Marker } from './base';\nimport { DEFAULT_MARK_POINT_TEXT_STYLE_MAP, DEFAULT_MARK_POINT_THEME } from './config';\nimport type { IItemContent, IItemLine, MarkPointAttrs } from './type';\nimport { IMarkPointItemPosition } from './type';\n\nexport class MarkPoint extends Marker<MarkPointAttrs> {\n static defaultAttributes = DEFAULT_MARK_POINT_THEME;\n\n private _item!: ISymbol | Tag | IImage | IRichText;\n\n private _line?: Segment;\n\n private _decorativeLine!: ILine;\n\n constructor(attributes: MarkPointAttrs) {\n super(merge({}, MarkPoint.defaultAttributes, attributes));\n }\n\n protected setLabelPos() {\n //do nothing\n }\n\n protected setItemAttributes(\n item: ISymbol | Tag | IImage | IRichText,\n itemContent: IItemContent,\n itemPosition: IPointLike,\n itemType: 'symbol' | 'text' | 'image' | 'richText' | 'custom'\n ) {\n const {\n autoRotate = true,\n refX = 0,\n refY = 0,\n refAngle = 0,\n textStyle,\n richTextStyle,\n imageStyle,\n position = IMarkPointItemPosition.middle\n } = itemContent;\n const itemAngle = this._line?.getEndAngle() || 0;\n const itemOffsetX = refX * Math.cos(itemAngle) + refY * Math.cos(itemAngle - Math.PI / 2);\n const itemOffsetY = refX * Math.sin(itemAngle) + refY * Math.sin(itemAngle - Math.PI / 2);\n if (itemType === 'text') {\n item?.setAttributes({\n ...textStyle,\n textStyle: {\n ...DEFAULT_MARK_POINT_TEXT_STYLE_MAP[itemContent?.position || 'end'],\n ...textStyle?.textStyle\n }\n });\n } else if (itemType === 'richText') {\n item?.setAttributes({\n dx: this.getItemDx(item, position, richTextStyle) + (richTextStyle?.dx || 0),\n dy: this.getItemDy(item, position, richTextStyle) + (richTextStyle?.dy || 0)\n });\n } else if (itemType === 'image') {\n item?.setAttributes({\n dx: this.getItemDx(item, position, imageStyle) + (imageStyle?.dx || 0),\n dy: this.getItemDy(item, position, imageStyle) + (imageStyle?.dy || 0)\n });\n }\n item?.setAttributes({\n x: itemPosition.x + (itemOffsetX || 0),\n y: itemPosition.y + (itemOffsetY || 0),\n angle: autoRotate && itemAngle + refAngle\n });\n }\n\n protected getItemDx(\n item: ISymbol | Tag | IImage | IRichText,\n position: IMarkPointItemPosition,\n style?: IImageGraphicAttribute | IRichTextGraphicAttribute\n ) {\n const width = (item as IGroup)?.AABBBounds?.width() ?? (style?.width || 0);\n if (position.includes('inside')) {\n return -width;\n } else if (position === 'insideTop') {\n return 0;\n }\n return 0;\n }\n\n protected getItemDy(\n item: ISymbol | Tag | IImage | IRichText,\n position: IMarkPointItemPosition,\n style?: IImageGraphicAttribute | IRichTextGraphicAttribute\n ) {\n const height = (item as IGroup)?.AABBBounds?.height() ?? (style?.height || 0);\n if (position.includes('top') || position.includes('Top')) {\n return -height;\n } else if (position.includes('middle') || position.includes('Middle')) {\n return -height / 2;\n }\n return 0;\n }\n\n protected initItem(itemContent: IItemContent, itemPosition: IPointLike) {\n const { type = 'text', symbolStyle, richTextStyle, imageStyle, renderCustomCallback } = itemContent;\n let item: ISymbol | Tag | IImage | IRichText | IGroup;\n if (type === 'symbol') {\n item = createSymbol({\n ...itemPosition,\n ...symbolStyle\n });\n } else if (type === 'text') {\n item = new Tag({\n ...itemPosition\n });\n } else if (type === 'richText') {\n item = createRichText({\n ...itemPosition,\n ...richTextStyle\n });\n } else if (type === 'image') {\n item = createImage({\n ...itemPosition,\n ...imageStyle\n });\n } else if (type === 'custom' && renderCustomCallback) {\n item = renderCustomCallback();\n }\n this.setItemAttributes(item, itemContent, itemPosition, type);\n return item;\n }\n\n protected getItemLineAttr(itemLine: IItemLine, position: IPointLike, itemPosition: IPointLike) {\n let points: IPointLike[] = [];\n const { type = 'type-s' } = itemLine;\n if (type === 'type-do') {\n points = [\n position,\n {\n x: (position.x + itemPosition.x) / 2,\n y: itemPosition.y\n },\n itemPosition\n ];\n } else if (type === 'type-po') {\n points = [\n position,\n {\n x: itemPosition.x,\n y: position.y\n },\n itemPosition\n ];\n } else if (type === 'type-op') {\n points = [\n position,\n {\n x: position.x,\n y: itemPosition.y\n },\n itemPosition\n ];\n } else {\n points = [position, itemPosition];\n }\n return points;\n }\n\n protected setItemLineAttr(itemLine: IItemLine, position: IPointLike, itemPosition: IPointLike, visible: boolean) {\n const { startSymbol, endSymbol, lineStyle } = itemLine;\n const points = this.getItemLineAttr(itemLine, position, itemPosition);\n this._line?.setAttributes({\n points,\n startSymbol,\n endSymbol,\n lineStyle,\n visible\n });\n }\n\n protected getDecorativeLineAttr(itemLine: IItemLine, itemPosition: IPointLike) {\n const decorativeLength = itemLine?.decorativeLine?.length || 10;\n const itemAngle = this._line.getEndAngle() || 0;\n const startPointOffsetX = (decorativeLength / 2) * Math.cos(itemAngle - Math.PI / 2);\n const startPointOffsetY = (decorativeLength / 2) * Math.sin(itemAngle - Math.PI / 2);\n const endPointOffsetX = (-decorativeLength / 2) * Math.cos(itemAngle - Math.PI / 2);\n const endPointOffsetY = (-decorativeLength / 2) * Math.sin(itemAngle - Math.PI / 2);\n return {\n startPointOffsetX,\n startPointOffsetY,\n endPointOffsetX,\n endPointOffsetY\n };\n }\n\n protected setDecorativeLineAttr(itemLine: IItemLine, itemPosition: IPointLike, visible: boolean) {\n const { lineStyle } = itemLine;\n const { startPointOffsetX, startPointOffsetY, endPointOffsetX, endPointOffsetY } = this.getDecorativeLineAttr(\n itemLine,\n itemPosition\n );\n this._decorativeLine?.setAttributes({\n points: [\n {\n x: itemPosition.x + startPointOffsetX,\n y: itemPosition.y + startPointOffsetY\n },\n {\n x: itemPosition.x + endPointOffsetX,\n y: itemPosition.y + endPointOffsetY\n }\n ],\n ...lineStyle,\n visible\n });\n }\n\n protected initMarker(container: IGroup) {\n const { position, itemLine, itemContent } = this.attribute as MarkPointAttrs;\n const itemPosition = {\n x: position.x + (itemContent?.offsetX || 0),\n y: position.y + (itemContent?.offsetY || 0)\n };\n\n const line = new Segment({\n points: []\n });\n line.name = 'mark-point-line';\n this._line = line;\n container.add(line as unknown as INode);\n\n const decorativeLine = createLine({\n points: []\n });\n decorativeLine.name = 'mark-point-decorativeLine';\n this._decorativeLine = decorativeLine;\n container.add(decorativeLine as unknown as INode);\n\n this.setItemLineAttr(itemLine, position, itemPosition, itemLine?.visible);\n this.setDecorativeLineAttr(itemLine, itemPosition, itemLine?.decorativeLine?.visible);\n\n const item = this.initItem(itemContent as any, itemPosition);\n this._item = item;\n container.add(item as unknown as INode);\n }\n\n protected updateMarker() {\n const { position, itemLine, itemContent } = this.attribute as MarkPointAttrs;\n const { type = 'text' } = itemContent;\n const itemPosition = {\n x: position.x + (itemContent?.offsetX || 0),\n y: position.y + (itemContent?.offsetY || 0)\n };\n this.setItemLineAttr(itemLine, position, itemPosition, itemLine?.visible);\n this.setDecorativeLineAttr(itemLine, itemPosition, itemLine?.decorativeLine?.visible);\n this.setItemAttributes(this._item, itemContent, itemPosition, type);\n }\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IContext2d, IGraphic, IGraphicAttribute, IInteractiveSubRenderContribution, IThemeAttribute, IDrawContext } from '@visactor/vrender';
|
|
2
|
+
import { PopTip } from './poptip';
|
|
3
|
+
export declare class PopTipRenderContribution implements IInteractiveSubRenderContribution {
|
|
4
|
+
poptipComponent: PopTip;
|
|
5
|
+
render(graphic: IGraphic<Partial<IGraphicAttribute>>, context: IContext2d, x: number, y: number, doFill: boolean, doStroke: boolean, fVisible: boolean, sVisible: boolean, graphicAttribute: Required<IGraphicAttribute>, drawContext: IDrawContext, fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, options?: any): void;
|
|
6
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
|
|
4
|
+
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
5
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
|
+
value: !0
|
|
11
|
+
}), exports.PopTipRenderContribution = void 0;
|
|
12
|
+
|
|
13
|
+
const inversify_1 = require("inversify"), poptip_1 = require("./poptip");
|
|
14
|
+
|
|
15
|
+
let PopTipRenderContribution = class {
|
|
16
|
+
render(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, options) {
|
|
17
|
+
if (graphic._showPoptip) {
|
|
18
|
+
const {visible: visible, visibleCb: visibleCb} = graphic.attribute.poptip;
|
|
19
|
+
if (!1 === visible || visibleCb && !1 === visibleCb(graphic)) return;
|
|
20
|
+
this.poptipComponent || (this.poptipComponent = new poptip_1.PopTip(graphic.attribute.poptip)),
|
|
21
|
+
this.poptipComponent.setAttributes(Object.assign(Object.assign({}, graphic.attribute.poptip), {
|
|
22
|
+
x: 0,
|
|
23
|
+
y: 0,
|
|
24
|
+
postMatrix: graphic.globalTransMatrix
|
|
25
|
+
}));
|
|
26
|
+
const interactiveLayer = drawContext.stage.getLayer("_builtin_interactive");
|
|
27
|
+
interactiveLayer && interactiveLayer.add(this.poptipComponent);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
PopTipRenderContribution = __decorate([ (0, inversify_1.injectable)() ], PopTipRenderContribution),
|
|
33
|
+
exports.PopTipRenderContribution = PopTipRenderContribution;
|
|
34
|
+
//# sourceMappingURL=contribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["poptip/contribution.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yCAAuC;AASvC,qCAAkC;AAG3B,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAEnC,MAAM,CACJ,OAA6C,EAC7C,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,gBAA6C,EAC7C,WAAyB,EACzB,MAAiH,EACjH,QAAmH,EACnH,OAAa;QAEb,IAAI,OAAO,CAAC,WAAW,EAAE;YACvB,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAI,OAAO,CAAC,SAAiB,CAAC,MAAM,CAAC;YACjE,IAAI,OAAO,KAAK,KAAK,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,OAAO,CAAC,KAAK,KAAK,CAAC,EAAE;gBACpE,OAAO;aACR;YACD,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;gBACzB,IAAI,CAAC,eAAe,GAAG,IAAI,eAAM,CAAE,OAAO,CAAC,SAAiB,CAAC,MAAM,CAAC,CAAC;aACtE;YACD,IAAI,CAAC,eAAe,CAAC,aAAa,iCAC5B,OAAO,CAAC,SAAiB,CAAC,MAAM,KACpC,CAAC,EAAE,CAAC,EACJ,CAAC,EAAE,CAAC,EACJ,UAAU,EAAE,OAAO,CAAC,iBAAiB,IACrC,CAAC;YAEH,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC;YAC5E,IAAI,gBAAgB,EAAE;gBACpB,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;aAC5C;SACF;IACH,CAAC;CACF,CAAA;AAtCY,wBAAwB;IADpC,IAAA,sBAAU,GAAE;GACA,wBAAwB,CAsCpC;AAtCY,4DAAwB","file":"contribution.js","sourcesContent":["import { injectable } from 'inversify';\nimport type {\n IContext2d,\n IGraphic,\n IGraphicAttribute,\n IInteractiveSubRenderContribution,\n IThemeAttribute,\n IDrawContext\n} from '@visactor/vrender';\nimport { PopTip } from './poptip';\n\n@injectable()\nexport class PopTipRenderContribution implements IInteractiveSubRenderContribution {\n declare poptipComponent: PopTip;\n render(\n graphic: IGraphic<Partial<IGraphicAttribute>>,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ): void {\n if (graphic._showPoptip) {\n const { visible, visibleCb } = (graphic.attribute as any).poptip;\n if (visible === false || (visibleCb && visibleCb(graphic) === false)) {\n return;\n }\n if (!this.poptipComponent) {\n this.poptipComponent = new PopTip((graphic.attribute as any).poptip);\n }\n this.poptipComponent.setAttributes({\n ...(graphic.attribute as any).poptip,\n x: 0,\n y: 0,\n postMatrix: graphic.globalTransMatrix\n });\n // 添加到交互层中\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n interactiveLayer.add(this.poptipComponent);\n }\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
4
|
+
void 0 === k2 && (k2 = k);
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
desc && !("get" in desc ? !m.__esModule : desc.writable || desc.configurable) || (desc = {
|
|
7
|
+
enumerable: !0,
|
|
8
|
+
get: function() {
|
|
9
|
+
return m[k];
|
|
10
|
+
}
|
|
11
|
+
}), Object.defineProperty(o, k2, desc);
|
|
12
|
+
} : function(o, m, k, k2) {
|
|
13
|
+
void 0 === k2 && (k2 = k), o[k2] = m[k];
|
|
14
|
+
}), __exportStar = this && this.__exportStar || function(m, exports) {
|
|
15
|
+
for (var p in m) "default" === p || Object.prototype.hasOwnProperty.call(exports, p) || __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
Object.defineProperty(exports, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), __exportStar(require("./poptip"), exports), __exportStar(require("./type"), exports),
|
|
21
|
+
__exportStar(require("./register"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["poptip/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,yCAAuB;AACvB,6CAA2B","file":"index.js","sourcesContent":["export * from './poptip';\nexport * from './type';\nexport * from './register';\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FederatedPointerEvent, IGraphic, IPlugin, IPluginService } from '@visactor/vrender';
|
|
2
|
+
export declare class PopTipPlugin implements IPlugin {
|
|
3
|
+
name: 'poptip';
|
|
4
|
+
activeEvent: 'onRegister';
|
|
5
|
+
pluginService: IPluginService;
|
|
6
|
+
_uid: number;
|
|
7
|
+
key: string;
|
|
8
|
+
activeGraphic: IGraphic;
|
|
9
|
+
activate(context: IPluginService): void;
|
|
10
|
+
poptip: (e: FederatedPointerEvent) => void;
|
|
11
|
+
unpoptip: (e: FederatedPointerEvent) => void;
|
|
12
|
+
setActiveGraphic(graphic: any | null, rerender?: boolean): void;
|
|
13
|
+
deactivate(context: IPluginService): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
|
|
4
|
+
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
5
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
|
+
value: !0
|
|
11
|
+
}), exports.PopTipPlugin = void 0;
|
|
12
|
+
|
|
13
|
+
const inversify_1 = require("inversify"), vrender_1 = require("@visactor/vrender");
|
|
14
|
+
|
|
15
|
+
let PopTipPlugin = class {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.name = "poptip", this.activeEvent = "onRegister", this._uid = vrender_1.Generator.GenAutoIncrementId(),
|
|
18
|
+
this.key = this.name + this._uid, this.poptip = e => {
|
|
19
|
+
const graphic = e.target;
|
|
20
|
+
if (graphic.isContainer || !graphic.attribute || graphic === this.activeGraphic) return void this.unpoptip(e);
|
|
21
|
+
const {poptip: poptip} = graphic.attribute;
|
|
22
|
+
poptip && (graphic._showPoptip = !0), this.activeGraphic && (this.activeGraphic._showPoptip = !1),
|
|
23
|
+
this.setActiveGraphic(graphic, !0);
|
|
24
|
+
}, this.unpoptip = e => {
|
|
25
|
+
this.activeGraphic && (this.activeGraphic._showPoptip = !1, this.setActiveGraphic(null, !0));
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
activate(context) {
|
|
29
|
+
this.pluginService = context;
|
|
30
|
+
const {stage: stage} = this.pluginService;
|
|
31
|
+
stage.addEventListener("pointerover", this.poptip);
|
|
32
|
+
}
|
|
33
|
+
setActiveGraphic(graphic, rerender) {
|
|
34
|
+
this.activeGraphic = graphic, this.pluginService.stage.renderNextFrame();
|
|
35
|
+
}
|
|
36
|
+
deactivate(context) {
|
|
37
|
+
const {stage: stage} = this.pluginService;
|
|
38
|
+
stage.removeEventListener("pointerover", this.poptip);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
PopTipPlugin = __decorate([ (0, inversify_1.injectable)() ], PopTipPlugin), exports.PopTipPlugin = PopTipPlugin;
|
|
43
|
+
//# sourceMappingURL=poptip-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["poptip/poptip-plugin.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yCAAuC;AAEvC,+CAA8C;AAGvC,IAAM,YAAY,GAAlB,MAAM,YAAY;IAAlB;QACL,SAAI,GAAa,QAAQ,CAAC;QAC1B,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,mBAAS,CAAC,kBAAkB,EAAE,CAAC;QAC9C,QAAG,GAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QASpC,WAAM,GAAG,CAAC,C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AG,IAAI,CAAC,aAAa,CAAC;QACrC,KAAK,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;CACF,CAAA;AAlDY,YAAY;IADxB,IAAA,sBAAU,GAAE;GACA,YAAY,CAkDxB;AAlDY,oCAAY","file":"poptip-plugin.js","sourcesContent":["import { injectable } from 'inversify';\nimport type { FederatedPointerEvent, IGraphic, IPlugin, IPluginService } from '@visactor/vrender';\nimport { Generator } from '@visactor/vrender';\n\n@injectable()\nexport class PopTipPlugin implements IPlugin {\n name: 'poptip' = 'poptip';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n activeGraphic: IGraphic;\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n const { stage } = this.pluginService;\n\n stage.addEventListener('pointerover', this.poptip);\n }\n poptip = (e: FederatedPointerEvent) => {\n const graphic = e.target as any;\n if (graphic.isContainer || !graphic.attribute || graphic === this.activeGraphic) {\n this.unpoptip(e);\n return;\n }\n const { poptip } = graphic.attribute;\n if (poptip) {\n graphic._showPoptip = true;\n }\n\n if (this.activeGraphic) {\n this.activeGraphic._showPoptip = false;\n }\n // console.log(graphic)\n this.setActiveGraphic(graphic, true);\n };\n\n unpoptip = (e: FederatedPointerEvent) => {\n if (!this.activeGraphic) {\n return;\n }\n this.activeGraphic._showPoptip = false;\n this.setActiveGraphic(null, true);\n };\n\n setActiveGraphic(graphic: any | null, rerender?: boolean) {\n this.activeGraphic = graphic;\n // 触发重绘\n this.pluginService.stage.renderNextFrame();\n }\n\n deactivate(context: IPluginService): void {\n const { stage } = this.pluginService;\n stage.removeEventListener('pointerover', this.poptip);\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AbstractComponent } from '../core/base';
|
|
2
|
+
import type { PopTipAttributes } from './type';
|
|
3
|
+
export declare class PopTip extends AbstractComponent<Required<PopTipAttributes>> {
|
|
4
|
+
name: string;
|
|
5
|
+
static defaultAttributes: Partial<PopTipAttributes>;
|
|
6
|
+
constructor(attributes: PopTipAttributes);
|
|
7
|
+
protected render(): void;
|
|
8
|
+
getAngleAndOffset(position: string, width: number, height: number, size: [number, number]): {
|
|
9
|
+
angle: number;
|
|
10
|
+
offset: [number, number];
|
|
11
|
+
rectOffset: [number, number];
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __rest = this && this.__rest || function(s, e) {
|
|
4
|
+
var t = {};
|
|
5
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
|
|
6
|
+
if (null != s && "function" == typeof Object.getOwnPropertySymbols) {
|
|
7
|
+
var i = 0;
|
|
8
|
+
for (p = Object.getOwnPropertySymbols(s); i < p.length; i++) e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
Object.defineProperty(exports, "__esModule", {
|
|
14
|
+
value: !0
|
|
15
|
+
}), exports.PopTip = void 0;
|
|
16
|
+
|
|
17
|
+
const vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base");
|
|
18
|
+
|
|
19
|
+
class PopTip extends base_1.AbstractComponent {
|
|
20
|
+
constructor(attributes) {
|
|
21
|
+
super((0, vutils_1.merge)({}, PopTip.defaultAttributes, attributes)), this.name = "poptip";
|
|
22
|
+
}
|
|
23
|
+
render() {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
const {title: title = "", titleStyle: titleStyle = {}, position: position, content: content = "", contentStyle: contentStyle = {}, panel: panel = {}, space: space = 4, minWidth: minWidth = 0, maxWidth: maxWidth = 1 / 0, padding: padding = 4, visible: visible, state: state, dx: dx = 0, dy: dy = 0} = this.attribute, parsedPadding = (0,
|
|
26
|
+
vutils_1.normalizePadding)(padding), group = this.createOrUpdateChild("poptip-content", {
|
|
27
|
+
x: 0,
|
|
28
|
+
y: 0,
|
|
29
|
+
zIndex: 1
|
|
30
|
+
}, "group"), maxLineWidth = maxWidth - parsedPadding[1] - parsedPadding[3], titleVisible = (0,
|
|
31
|
+
vutils_1.isValid)(title) && !1 !== visible, titleAttrs = Object.assign(Object.assign({
|
|
32
|
+
text: title,
|
|
33
|
+
visible: titleVisible
|
|
34
|
+
}, titleStyle), {
|
|
35
|
+
x: parsedPadding[3],
|
|
36
|
+
y: parsedPadding[0],
|
|
37
|
+
maxLineWidth: maxLineWidth,
|
|
38
|
+
textAlign: "left",
|
|
39
|
+
textBaseline: "top"
|
|
40
|
+
}), titleShape = group.createOrUpdateChild("poptip-title", titleAttrs, "text");
|
|
41
|
+
(0, vutils_1.isEmpty)(null == state ? void 0 : state.title) || (titleShape.states = state.title);
|
|
42
|
+
const titleBounds = titleShape.AABBBounds, titleHeight = titleBounds.height(), titleWidth = titleBounds.width();
|
|
43
|
+
let height = titleHeight + space;
|
|
44
|
+
titleVisible || (height = 0);
|
|
45
|
+
const contentVisible = (0, vutils_1.isValid)(content) && !1 !== visible, contentAttrs = Object.assign(Object.assign({
|
|
46
|
+
text: content,
|
|
47
|
+
visible: contentVisible
|
|
48
|
+
}, contentStyle), {
|
|
49
|
+
x: parsedPadding[3],
|
|
50
|
+
y: parsedPadding[0] + height,
|
|
51
|
+
maxLineWidth: maxLineWidth,
|
|
52
|
+
textAlign: "left",
|
|
53
|
+
textBaseline: "top"
|
|
54
|
+
}), contentShape = group.createOrUpdateChild("poptip-content", contentAttrs, "text");
|
|
55
|
+
(0, vutils_1.isEmpty)(null == state ? void 0 : state.content) || (contentShape.states = state.content);
|
|
56
|
+
const contentBounds = contentShape.AABBBounds, contentHeight = contentBounds.height(), contentWidth = contentBounds.width();
|
|
57
|
+
contentVisible && (height += contentHeight);
|
|
58
|
+
let popTipWidth = (0, vutils_1.max)(titleWidth + parsedPadding[1] + parsedPadding[3], contentWidth + parsedPadding[1] + parsedPadding[3]);
|
|
59
|
+
popTipWidth > maxWidth ? popTipWidth = maxWidth : popTipWidth < minWidth && (popTipWidth = minWidth);
|
|
60
|
+
const poptipHeight = parsedPadding[0] + parsedPadding[2] + height, {visible: bgVisible} = panel, backgroundStyle = __rest(panel, [ "visible" ]), symbolSize = null !== (_a = backgroundStyle.size) && void 0 !== _a ? _a : 12, lineWidth = null !== (_b = backgroundStyle.lineWidth) && void 0 !== _b ? _b : 1, {angle: angle, offset: offset, rectOffset: rectOffset} = this.getAngleAndOffset(position, popTipWidth, poptipHeight, (0,
|
|
61
|
+
vutils_1.isArray)(symbolSize) ? symbolSize : [ symbolSize, symbolSize - lineWidth ]);
|
|
62
|
+
if ((0, vutils_1.isBoolean)(bgVisible)) {
|
|
63
|
+
const offsetX = ((0, vutils_1.isArray)(symbolSize) ? symbolSize[0] : symbolSize) / 4, bgSymbol = group.createOrUpdateChild("poptip-symbol-panel", Object.assign(Object.assign({}, backgroundStyle), {
|
|
64
|
+
visible: bgVisible && (contentVisible || titleVisible),
|
|
65
|
+
x: offsetX,
|
|
66
|
+
y: 0,
|
|
67
|
+
anchor: [ 0, 0 ],
|
|
68
|
+
symbolType: "arrow2Left",
|
|
69
|
+
angle: angle,
|
|
70
|
+
dx: offset[0],
|
|
71
|
+
dy: offset[1],
|
|
72
|
+
size: symbolSize,
|
|
73
|
+
zIndex: -9
|
|
74
|
+
}), "symbol");
|
|
75
|
+
(0, vutils_1.isEmpty)(null == state ? void 0 : state.panel) || (bgSymbol.states = state.panel);
|
|
76
|
+
const bgRect = group.createOrUpdateChild("poptip-rect-panel", Object.assign(Object.assign({}, backgroundStyle), {
|
|
77
|
+
visible: bgVisible && (contentVisible || titleVisible),
|
|
78
|
+
x: 0,
|
|
79
|
+
y: 0,
|
|
80
|
+
width: popTipWidth,
|
|
81
|
+
height: poptipHeight,
|
|
82
|
+
zIndex: -10
|
|
83
|
+
}), "rect");
|
|
84
|
+
(0, vutils_1.isEmpty)(null == state ? void 0 : state.panel) || (bgRect.states = state.panel);
|
|
85
|
+
}
|
|
86
|
+
group.setAttributes({
|
|
87
|
+
x: -offset[0] + dx,
|
|
88
|
+
y: -offset[1] + dy
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
getAngleAndOffset(position, width, height, size) {
|
|
92
|
+
const sizeH = size[1] / 2;
|
|
93
|
+
switch (position) {
|
|
94
|
+
case "tl":
|
|
95
|
+
return {
|
|
96
|
+
angle: vutils_1.pi / 2 * 3,
|
|
97
|
+
offset: [ width / 4, height + sizeH ],
|
|
98
|
+
rectOffset: [ -width / 4, -height - size[1] ]
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
case "top":
|
|
102
|
+
return {
|
|
103
|
+
angle: vutils_1.pi / 2 * 3,
|
|
104
|
+
offset: [ width / 2, height + sizeH ],
|
|
105
|
+
rectOffset: [ 0, -height - size[1] ]
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
case "tr":
|
|
109
|
+
return {
|
|
110
|
+
angle: vutils_1.pi / 2 * 3,
|
|
111
|
+
offset: [ width / 4 * 3, height + sizeH ],
|
|
112
|
+
rectOffset: [ width / 4 * 3, -height - size[1] ]
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
case "rt":
|
|
116
|
+
return {
|
|
117
|
+
angle: 0,
|
|
118
|
+
offset: [ -sizeH, height / 5 ],
|
|
119
|
+
rectOffset: [ width / 4 * 3, -height - size[1] ]
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
case "right":
|
|
123
|
+
return {
|
|
124
|
+
angle: 0,
|
|
125
|
+
offset: [ -sizeH, height / 2 ],
|
|
126
|
+
rectOffset: [ width / 4 * 3, -height - size[1] ]
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
case "rb":
|
|
130
|
+
return {
|
|
131
|
+
angle: 0,
|
|
132
|
+
offset: [ -sizeH, height / 5 * 4 ],
|
|
133
|
+
rectOffset: [ width / 4 * 3, -height - size[1] ]
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
case "bl":
|
|
137
|
+
return {
|
|
138
|
+
angle: vutils_1.pi / 2,
|
|
139
|
+
offset: [ width / 4, -sizeH ],
|
|
140
|
+
rectOffset: [ -width / 4, -height - size[1] ]
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
case "bottom":
|
|
144
|
+
return {
|
|
145
|
+
angle: vutils_1.pi / 2,
|
|
146
|
+
offset: [ width / 2, -sizeH ],
|
|
147
|
+
rectOffset: [ 0, -height - size[1] ]
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
case "br":
|
|
151
|
+
return {
|
|
152
|
+
angle: vutils_1.pi / 2,
|
|
153
|
+
offset: [ width / 4 * 3, -sizeH ],
|
|
154
|
+
rectOffset: [ width / 4 * 3, -height - size[1] ]
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
case "lt":
|
|
158
|
+
return {
|
|
159
|
+
angle: vutils_1.pi,
|
|
160
|
+
offset: [ width + sizeH, height / 5 ],
|
|
161
|
+
rectOffset: [ -width / 4, -height - size[1] ]
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
case "left":
|
|
165
|
+
return {
|
|
166
|
+
angle: vutils_1.pi,
|
|
167
|
+
offset: [ width + sizeH, height / 2 ],
|
|
168
|
+
rectOffset: [ 0, -height - size[1] ]
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
case "lb":
|
|
172
|
+
return {
|
|
173
|
+
angle: vutils_1.pi,
|
|
174
|
+
offset: [ width + sizeH, height / 5 * 4 ],
|
|
175
|
+
rectOffset: [ width / 4 * 3, -height - size[1] ]
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
exports.PopTip = PopTip, PopTip.defaultAttributes = {
|
|
182
|
+
position: "rt",
|
|
183
|
+
visible: !0,
|
|
184
|
+
title: null,
|
|
185
|
+
content: null,
|
|
186
|
+
titleStyle: {
|
|
187
|
+
fontSize: 12,
|
|
188
|
+
fill: "#000",
|
|
189
|
+
textAlign: "left",
|
|
190
|
+
textBaseline: "top"
|
|
191
|
+
},
|
|
192
|
+
contentStyle: {
|
|
193
|
+
fontSize: 12,
|
|
194
|
+
fill: "#000",
|
|
195
|
+
textAlign: "left",
|
|
196
|
+
textBaseline: "top"
|
|
197
|
+
},
|
|
198
|
+
space: 8,
|
|
199
|
+
padding: 10
|
|
200
|
+
};
|
|
201
|
+
//# sourceMappingURL=poptip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["poptip/poptip.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAaA,6CAA0G;AAC1G,uCAAiD;AAIjD,MAAa,MAAO,SAAQ,wBAA6C;IAwBvE,YAAY,UAA4B;QACtC,KAAK,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,MAAM,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAxBzD,SAAI,GAAG,QAAQ,CAAC;IAyBhB,CAAC;IAES,MAAM;;QACd,MAAM,EACJ,KAAK,GAAG,EAAE,EACV,UAAU,GAAG,EAA2B,EACxC,QAAQ,EACR,OAAO,GAAG,EAAE,EACZ,YAAY,GAAG,EAA2B,EAC1C,KAAK,GAAG,EAAoD,EAC5D,KAAK,GAAG,CAAC,EACT,QAAQ,GAAG,CAAC,EACZ,QAAQ,GAAG,QAAQ,EACnB,OAAO,GAAG,CAAC,EACX,OAAO,EACP,KAAK,EACL,EAAE,GAAG,CAAC,EACN,EAAE,GAAG,CAAC,EACP,GAAG,IAAI,CAAC,SAA6B,CAAC;QAEvC,MAAM,aAAa,GAAG,IAAA,yBAAgB,EAAC,OAAO,CAAC,CAAC;QAEhD,MAAM,KAAK,GAAG,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EA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,IAAI,CAAC,CAAC,CAAC,CAAC;iBACjD,CAAC;SACL;IACH,CAAC;;AAzNH,wBA0NC;AAvNQ,wBAAiB,GAA8B;IACpD,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,IAAI;IACX,OAAO,EAAE,IAAI;IACb,UAAU,EAAE;QACV,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,KAAK;KACpB;IACD,YAAY,EAAE;QACZ,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,KAAK;KACpB;IACD,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,EAAE;CACZ,CAAC","file":"poptip.js","sourcesContent":["/**\n * @description PopTip组件\n */\nimport type {\n IGroup,\n IRect,\n ISymbol,\n ISymbolGraphicAttribute,\n IText,\n ITextGraphicAttribute,\n TextAlignType,\n TextBaselineType\n} from '@visactor/vrender';\nimport { isArray, isBoolean, isEmpty, isValid, max, merge, normalizePadding, pi } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { BackgroundAttributes } from '../interface';\nimport type { PopTipAttributes } from './type';\n\nexport class PopTip extends AbstractComponent<Required<PopTipAttributes>> {\n name = 'poptip';\n\n static defaultAttributes: Partial<PopTipAttributes> = {\n position: 'rt',\n visible: true,\n title: null,\n content: null,\n titleStyle: {\n fontSize: 12,\n fill: '#000',\n textAlign: 'left',\n textBaseline: 'top'\n },\n contentStyle: {\n fontSize: 12,\n fill: '#000',\n textAlign: 'left',\n textBaseline: 'top'\n },\n space: 8,\n padding: 10\n };\n\n constructor(attributes: PopTipAttributes) {\n super(merge({}, PopTip.defaultAttributes, attributes));\n }\n\n protected render() {\n const {\n title = '',\n titleStyle = {} as ITextGraphicAttribute,\n position,\n content = '',\n contentStyle = {} as ITextGraphicAttribute,\n panel = {} as BackgroundAttributes & ISymbolGraphicAttribute,\n space = 4,\n minWidth = 0,\n maxWidth = Infinity,\n padding = 4,\n visible,\n state,\n dx = 0,\n dy = 0\n } = this.attribute as PopTipAttributes;\n\n const parsedPadding = normalizePadding(padding);\n\n const group = this.createOrUpdateChild('poptip-content', { x: 0, y: 0, zIndex: 1 }, 'group') as IGroup;\n\n const maxLineWidth = maxWidth - parsedPadding[1] - parsedPadding[3];\n\n const titleVisible = isValid(title) && visible !== false;\n const titleAttrs = {\n text: title,\n visible: titleVisible,\n ...titleStyle,\n x: parsedPadding[3],\n y: parsedPadding[0],\n maxLineWidth,\n textAlign: 'left' as TextAlignType,\n textBaseline: 'top' as TextBaselineType\n };\n\n const titleShape = group.createOrUpdateChild('poptip-title', titleAttrs, 'text') as IText;\n if (!isEmpty(state?.title)) {\n titleShape.states = state.title;\n }\n\n const titleBounds = titleShape.AABBBounds;\n const titleHeight = titleBounds.height();\n const titleWidth = titleBounds.width();\n let height = titleHeight + space;\n if (!titleVisible) {\n height = 0;\n }\n\n const contentVisible = isValid(content) && visible !== false;\n const contentAttrs = {\n text: content,\n visible: contentVisible,\n ...contentStyle,\n x: parsedPadding[3],\n y: parsedPadding[0] + height,\n maxLineWidth,\n textAlign: 'left' as TextAlignType,\n textBaseline: 'top' as TextBaselineType\n };\n\n const contentShape = group.createOrUpdateChild('poptip-content', contentAttrs, 'text') as IText;\n if (!isEmpty(state?.content)) {\n contentShape.states = state.content;\n }\n\n const contentBounds = contentShape.AABBBounds;\n const contentHeight = contentBounds.height();\n const contentWidth = contentBounds.width();\n\n if (contentVisible) {\n height += contentHeight;\n }\n\n // 计算整个popTip的宽高\n let popTipWidth = max(\n titleWidth + parsedPadding[1] + parsedPadding[3],\n contentWidth + parsedPadding[1] + parsedPadding[3]\n );\n if (popTipWidth > maxWidth) {\n popTipWidth = maxWidth;\n } else if (popTipWidth < minWidth) {\n popTipWidth = minWidth;\n }\n const poptipHeight = parsedPadding[0] + parsedPadding[2] + height;\n\n // 绘制背景层\n const { visible: bgVisible, ...backgroundStyle } = panel;\n const symbolSize = backgroundStyle.size ?? 12;\n const lineWidth = backgroundStyle.lineWidth ?? 1;\n const { angle, offset, rectOffset } = this.getAngleAndOffset(\n position,\n popTipWidth,\n poptipHeight,\n isArray(symbolSize) ? symbolSize : [symbolSize, symbolSize - lineWidth]\n );\n if (isBoolean(bgVisible)) {\n const offsetX = (isArray(symbolSize) ? symbolSize[0] : symbolSize) / 4;\n const bgSymbol = group.createOrUpdateChild(\n 'poptip-symbol-panel',\n {\n ...backgroundStyle,\n visible: bgVisible && (contentVisible || titleVisible),\n x: offsetX,\n y: 0,\n anchor: [0, 0],\n symbolType: 'arrow2Left',\n angle: angle,\n dx: offset[0],\n dy: offset[1],\n size: symbolSize,\n zIndex: -9\n },\n 'symbol'\n ) as ISymbol;\n if (!isEmpty(state?.panel)) {\n bgSymbol.states = state.panel;\n }\n\n const bgRect = group.createOrUpdateChild(\n 'poptip-rect-panel',\n {\n ...backgroundStyle,\n visible: bgVisible && (contentVisible || titleVisible),\n x: 0,\n y: 0,\n width: popTipWidth,\n height: poptipHeight,\n zIndex: -10\n },\n 'rect'\n ) as IRect;\n if (!isEmpty(state?.panel)) {\n bgRect.states = state.panel;\n }\n }\n\n group.setAttributes({\n x: -offset[0] + dx,\n y: -offset[1] + dy\n });\n }\n\n getAngleAndOffset(\n position: string,\n width: number,\n height: number,\n size: [number, number]\n ): { angle: number; offset: [number, number]; rectOffset: [number, number] } {\n // const sizeW = size[0];\n const sizeH = size[1] / 2;\n switch (position) {\n case 'tl':\n return {\n angle: (pi / 2) * 3,\n offset: [width / 4, height + sizeH],\n rectOffset: [-width / 4, -height - size[1]]\n };\n case 'top':\n return { angle: (pi / 2) * 3, offset: [width / 2, height + sizeH], rectOffset: [0, -height - size[1]] };\n case 'tr':\n return {\n angle: (pi / 2) * 3,\n offset: [(width / 4) * 3, height + sizeH],\n rectOffset: [(width / 4) * 3, -height - size[1]]\n };\n case 'rt':\n return { angle: 0, offset: [-sizeH, height / 5], rectOffset: [(width / 4) * 3, -height - size[1]] };\n case 'right':\n return { angle: 0, offset: [-sizeH, height / 2], rectOffset: [(width / 4) * 3, -height - size[1]] };\n case 'rb':\n return { angle: 0, offset: [-sizeH, (height / 5) * 4], rectOffset: [(width / 4) * 3, -height - size[1]] };\n case 'bl':\n return { angle: pi / 2, offset: [width / 4, -sizeH], rectOffset: [-width / 4, -height - size[1]] };\n case 'bottom':\n return { angle: pi / 2, offset: [width / 2, -sizeH], rectOffset: [0, -height - size[1]] };\n case 'br':\n return { angle: pi / 2, offset: [(width / 4) * 3, -sizeH], rectOffset: [(width / 4) * 3, -height - size[1]] };\n case 'lt':\n return { angle: pi, offset: [width + sizeH, height / 5], rectOffset: [-width / 4, -height - size[1]] };\n case 'left':\n return { angle: pi, offset: [width + sizeH, height / 2], rectOffset: [0, -height - size[1]] };\n case 'lb':\n return {\n angle: pi,\n offset: [width + sizeH, (height / 5) * 4],\n rectOffset: [(width / 4) * 3, -height - size[1]]\n };\n }\n }\n}\n"]}
|