@visactor/vrender-components 0.13.0-alpha.0 → 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/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.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/poptip-plugin.d.ts +1 -1
- package/cjs/poptip/poptip-plugin.js +1 -1
- package/cjs/poptip/poptip-plugin.js.map +1 -1
- package/cjs/poptip/poptip.js +3 -3
- package/cjs/poptip/poptip.js.map +1 -1
- package/cjs/poptip/type.d.ts +2 -0
- package/cjs/poptip/type.js.map +1 -1
- 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.js +1 -1
- package/cjs/tag/tag.js.map +1 -1
- package/dist/index.js +114 -51
- package/dist/index.min.js +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.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/poptip-plugin.d.ts +1 -1
- package/es/poptip/poptip-plugin.js +1 -1
- package/es/poptip/poptip-plugin.js.map +1 -1
- package/es/poptip/poptip.js +3 -3
- package/es/poptip/poptip.js.map +1 -1
- package/es/poptip/type.d.ts +2 -0
- package/es/poptip/type.js.map +1 -1
- 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.js +1 -1
- package/es/tag/tag.js.map +1 -1
- package/package.json +7 -7
package/cjs/index.d.ts
CHANGED
package/cjs/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
|
|
|
17
17
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", {
|
|
19
19
|
value: !0
|
|
20
|
-
}), exports.version = void 0, exports.version = "0.13.0
|
|
20
|
+
}), exports.version = void 0, exports.version = "0.13.0", __exportStar(require("./core/base"), exports),
|
|
21
21
|
__exportStar(require("./scrollbar"), exports), __exportStar(require("./tag"), exports),
|
|
22
22
|
__exportStar(require("./poptip"), exports), __exportStar(require("./crosshair"), exports),
|
|
23
23
|
__exportStar(require("./label"), exports), __exportStar(require("./axis"), exports),
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,QAAQ,CAAC;AAEhC,8CAA4B;AAC5B,8CAA4B;AAC5B,wCAAsB;AACtB,2CAAyB;AACzB,8CAA4B;AAC5B,0CAAwB;AACxB,yCAAuB;AACvB,4CAA0B;AAC1B,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,2CAAyB;AACzB,0CAAwB;AACxB,8CAA4B;AAC5B,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,4CAA0B;AAC1B,8CAA4B","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.13.0\";\n\nexport * from './core/base';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './interface';\n"]}
|
package/cjs/marker/area.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IGroup } from '@visactor/vrender';
|
|
1
|
+
import type { IGroup } from '@visactor/vrender';
|
|
2
2
|
import { Marker } from './base';
|
|
3
|
-
import { MarkAreaAttrs } from './type';
|
|
3
|
+
import type { MarkAreaAttrs } from './type';
|
|
4
4
|
export declare class MarkArea extends Marker<MarkAreaAttrs> {
|
|
5
5
|
static defaultAttributes: {
|
|
6
6
|
label: {
|
|
@@ -49,5 +49,6 @@ export declare class MarkArea extends Marker<MarkAreaAttrs> {
|
|
|
49
49
|
y: number;
|
|
50
50
|
};
|
|
51
51
|
protected setLabelPos(): void;
|
|
52
|
-
protected
|
|
52
|
+
protected initMarker(container: IGroup): void;
|
|
53
|
+
protected updateMarker(): void;
|
|
53
54
|
}
|
package/cjs/marker/area.js
CHANGED
|
@@ -41,14 +41,14 @@ class MarkArea extends base_1.Marker {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
setLabelPos() {
|
|
44
|
-
var _a;
|
|
44
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
45
45
|
const {label: label} = this.attribute, labelPosition = null !== (_a = null == label ? void 0 : label.position) && void 0 !== _a ? _a : "middle";
|
|
46
|
-
labelPosition.includes("left") || labelPosition.includes("Left") ? this._label.setAttributes(Object.assign({}, this.getLeftPos())) : labelPosition.includes("right") || labelPosition.includes("Right") ? this._label.setAttributes(Object.assign({}, this.getRightPos())) : labelPosition.includes("top") || labelPosition.includes("Top") ? this._label.setAttributes(Object.assign({}, this.getTopPos())) : labelPosition.includes("bottom") || labelPosition.includes("Bottom") ? this._label.setAttributes(Object.assign({}, this.getBottomPos())) : this._label.setAttributes(Object.assign({}, this.getMiddlePos())),
|
|
47
|
-
this._label.setAttributes({
|
|
46
|
+
labelPosition.includes("left") || labelPosition.includes("Left") ? null === (_b = this._label) || void 0 === _b || _b.setAttributes(Object.assign({}, this.getLeftPos())) : labelPosition.includes("right") || labelPosition.includes("Right") ? null === (_c = this._label) || void 0 === _c || _c.setAttributes(Object.assign({}, this.getRightPos())) : labelPosition.includes("top") || labelPosition.includes("Top") ? null === (_d = this._label) || void 0 === _d || _d.setAttributes(Object.assign({}, this.getTopPos())) : labelPosition.includes("bottom") || labelPosition.includes("Bottom") ? null === (_e = this._label) || void 0 === _e || _e.setAttributes(Object.assign({}, this.getBottomPos())) : null === (_f = this._label) || void 0 === _f || _f.setAttributes(Object.assign({}, this.getMiddlePos())),
|
|
47
|
+
null === (_g = this._label) || void 0 === _g || _g.setAttributes({
|
|
48
48
|
textStyle: Object.assign(Object.assign({}, config_1.DEFAULT_MARK_AREA_TEXT_STYLE_MAP[labelPosition]), label.textStyle)
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
initMarker(container) {
|
|
52
52
|
const {points: points, label: label, areaStyle: areaStyle} = this.attribute, area = (0,
|
|
53
53
|
vrender_1.createPolygon)(Object.assign({
|
|
54
54
|
points: points
|
|
@@ -58,6 +58,14 @@ class MarkArea extends base_1.Marker {
|
|
|
58
58
|
markLabel.name = "mark-area-label", this._label = markLabel, container.add(markLabel),
|
|
59
59
|
this.setLabelPos();
|
|
60
60
|
}
|
|
61
|
+
updateMarker() {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
const {points: points, label: label, areaStyle: areaStyle} = this.attribute;
|
|
64
|
+
null === (_a = this._area) || void 0 === _a || _a.setAttributes(Object.assign({
|
|
65
|
+
points: points
|
|
66
|
+
}, areaStyle)), null === (_b = this._label) || void 0 === _b || _b.setAttributes(Object.assign({}, label)),
|
|
67
|
+
this.setLabelPos();
|
|
68
|
+
}
|
|
61
69
|
}
|
|
62
70
|
|
|
63
71
|
exports.MarkArea = MarkArea, MarkArea.defaultAttributes = config_1.DEFAULT_MARK_AREA_THEME;
|
package/cjs/marker/area.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["marker/area.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["marker/area.ts"],"names":[],"mappings":";;;AACA,+CAAkD;AAClD,6CAAyC;AACzC,gCAA6B;AAC7B,iCAAgC;AAChC,qCAAqF;AAGrF,MAAa,QAAS,SAAQ,aAAqB;IAIjD,YAAY,UAAyB;QACnC,KAAK,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,QAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;IAC3D,CAAC;IAES,UAAU;QAClB,OAAO;YACL,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE;YAC3B,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC;SAC7D,CAAC;IACJ,CAAC;IAES,WAAW;QACnB,OAAO;YACL,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE;YAC3B,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC;SAC7D,CAAC;IACJ,CAAC;IAES,SAAS;QACjB,OAAO;YACL,CAAC,EAAE,CAAC,I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C7C,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;IAES,YAAY;;QACpB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,SAA0B,CAAC;QACrE,MAAA,IAAI,CAAC,KAAK,0CAAE,aAAa,iBACvB,MAAM,EAAE,MAAM,IACX,SAAS,EACZ,CAAC;QACH,MAAA,IAAI,CAAC,MAAM,0CAAE,aAAa,mBACrB,KAAK,EACR,CAAC;QACH,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;;AAxGH,4BAyGC;AAxGQ,0BAAiB,GAAG,gCAAuB,CAAC","file":"area.js","sourcesContent":["import type { IGroup, INode, IPolygon } from '@visactor/vrender';\nimport { createPolygon } from '@visactor/vrender';\nimport { merge } from '@visactor/vutils';\nimport { Tag } from '../tag';\nimport { Marker } from './base';\nimport { DEFAULT_MARK_AREA_TEXT_STYLE_MAP, DEFAULT_MARK_AREA_THEME } from './config';\nimport type { MarkAreaAttrs } from './type';\n\nexport class MarkArea extends Marker<MarkAreaAttrs> {\n static defaultAttributes = DEFAULT_MARK_AREA_THEME;\n private _area!: IPolygon;\n\n constructor(attributes: MarkAreaAttrs) {\n super(merge({}, MarkArea.defaultAttributes, attributes));\n }\n\n protected getLeftPos() {\n return {\n x: this._area.AABBBounds.x1,\n y: (this._area.AABBBounds.y1 + this._area.AABBBounds.y2) / 2\n };\n }\n\n protected getRightPos() {\n return {\n x: this._area.AABBBounds.x2,\n y: (this._area.AABBBounds.y1 + this._area.AABBBounds.y2) / 2\n };\n }\n\n protected getTopPos() {\n return {\n x: (this._area.AABBBounds.x1 + this._area.AABBBounds.x2) / 2,\n y: this._area.AABBBounds.y1\n };\n }\n\n protected getBottomPos() {\n return {\n x: (this._area.AABBBounds.x1 + this._area.AABBBounds.x2) / 2,\n y: this._area.AABBBounds.y2\n };\n }\n\n protected getMiddlePos() {\n return {\n x: (this._area.AABBBounds.x1 + this._area.AABBBounds.x2) / 2,\n y: (this._area.AABBBounds.y1 + this._area.AABBBounds.y2) / 2\n };\n }\n\n protected setLabelPos() {\n const { label } = this.attribute as MarkAreaAttrs;\n const labelPosition = label?.position ?? 'middle';\n if (labelPosition.includes('left') || labelPosition.includes('Left')) {\n this._label?.setAttributes({\n ...this.getLeftPos()\n });\n } else if (labelPosition.includes('right') || labelPosition.includes('Right')) {\n this._label?.setAttributes({\n ...this.getRightPos()\n });\n } else if (labelPosition.includes('top') || labelPosition.includes('Top')) {\n this._label?.setAttributes({\n ...this.getTopPos()\n });\n } else if (labelPosition.includes('bottom') || labelPosition.includes('Bottom')) {\n this._label?.setAttributes({\n ...this.getBottomPos()\n });\n } else {\n this._label?.setAttributes({\n ...this.getMiddlePos()\n });\n }\n this._label?.setAttributes({\n textStyle: {\n ...DEFAULT_MARK_AREA_TEXT_STYLE_MAP[labelPosition],\n ...label.textStyle\n }\n });\n }\n\n protected initMarker(container: IGroup) {\n const { points, label, areaStyle } = this.attribute as MarkAreaAttrs;\n const area = createPolygon({\n points: points,\n ...areaStyle\n });\n area.name = 'mark-area-area';\n this._area = area;\n container.add(area);\n\n const markLabel = new Tag({\n ...label\n });\n markLabel.name = 'mark-area-label';\n this._label = markLabel;\n container.add(markLabel as unknown as INode);\n this.setLabelPos();\n }\n\n protected updateMarker() {\n const { points, label, areaStyle } = this.attribute as MarkAreaAttrs;\n this._area?.setAttributes({\n points: points,\n ...areaStyle\n });\n this._label?.setAttributes({\n ...label\n });\n this.setLabelPos();\n }\n}\n"]}
|
package/cjs/marker/base.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { IGroup } from '@visactor/vrender';
|
|
1
|
+
import type { IGroup } from '@visactor/vrender';
|
|
2
2
|
import { AbstractComponent } from '../core/base';
|
|
3
|
-
import { Tag } from '../tag';
|
|
4
|
-
import { MarkerAttrs } from './type';
|
|
3
|
+
import type { Tag } from '../tag';
|
|
4
|
+
import type { MarkerAttrs } from './type';
|
|
5
5
|
export declare abstract class Marker<T extends MarkerAttrs> extends AbstractComponent<Required<T>> {
|
|
6
6
|
private _container;
|
|
7
7
|
protected _label: Tag;
|
|
8
8
|
protected abstract setLabelPos(): any;
|
|
9
|
-
protected abstract
|
|
9
|
+
protected abstract initMarker(container: IGroup): any;
|
|
10
|
+
protected abstract updateMarker(): any;
|
|
10
11
|
protected render(): void;
|
|
11
12
|
}
|
package/cjs/marker/base.js
CHANGED
|
@@ -9,12 +9,12 @@ const vrender_1 = require("@visactor/vrender"), base_1 = require("../core/base")
|
|
|
9
9
|
class Marker extends base_1.AbstractComponent {
|
|
10
10
|
render() {
|
|
11
11
|
var _a, _b;
|
|
12
|
-
this.removeAllChild();
|
|
13
12
|
const markerVisible = null === (_a = this.attribute.visible) || void 0 === _a || _a;
|
|
14
|
-
null !== (_b = this.attribute.interactive) && void 0 !== _b && _b || (this.setAttribute("pickable", !1),
|
|
15
|
-
this.setAttribute("childrenPickable", !1));
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
if (null !== (_b = this.attribute.interactive) && void 0 !== _b && _b || (this.setAttribute("pickable", !1),
|
|
14
|
+
this.setAttribute("childrenPickable", !1)), markerVisible) if (this._container) this.updateMarker(); else {
|
|
15
|
+
const group = (0, vrender_1.createGroup)({});
|
|
16
|
+
group.name = "marker-container", this.add(group), this._container = group, this.initMarker(group);
|
|
17
|
+
}
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
package/cjs/marker/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["marker/base.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["marker/base.ts"],"names":[],"mappings":";;;AACA,+CAAgD;AAChD,uCAAiD;AAIjD,MAAsB,MAA8B,SAAQ,wBAA8B;IAS9E,MAAM;;QAEd,MAAM,aAAa,GAAG,MAAA,IAAI,CAAC,SAAS,CAAC,OAAO,mCAAI,IAAI,CAAC;QACrD,MAAM,iBAAiB,GAAG,MAAA,IAAI,CAAC,SAAS,CAAC,WAAW,mCAAI,KAAK,CAAC;QAE9D,IAAI,CAAC,iBAAiB,EAAE;YACtB,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;YACrC,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;SAC9C;QAED,IAAI,aAAa,EAAE;YACjB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;gBACpB,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,EAAE,CAAC,CAAC;gBAC9B,KAAK,CAAC,IAAI,GAAG,kBAAkB,CAAC;gBAChC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAChB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;gBACxB,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;aACxB;iBAAM;gBACL,IAAI,CAAC,YAAY,EAAE,CAAC;aACrB;SACF;IACH,CAAC;CACF;AA/BD,wBA+BC","file":"base.js","sourcesContent":["import type { IGroup } from '@visactor/vrender';\nimport { createGroup } from '@visactor/vrender';\nimport { AbstractComponent } from '../core/base';\nimport type { Tag } from '../tag';\nimport type { MarkerAttrs } from './type';\n\nexport abstract class Marker<T extends MarkerAttrs> extends AbstractComponent<Required<T>> {\n private _container!: IGroup;\n\n protected _label!: Tag;\n\n protected abstract setLabelPos(): any;\n protected abstract initMarker(container: IGroup): any;\n protected abstract updateMarker(): any;\n\n protected render() {\n // this.removeAllChild();\n const markerVisible = this.attribute.visible ?? true;\n const markerInteractive = this.attribute.interactive ?? false;\n\n if (!markerInteractive) {\n this.setAttribute('pickable', false);\n this.setAttribute('childrenPickable', false);\n }\n\n if (markerVisible) {\n if (!this._container) {\n const group = createGroup({});\n group.name = 'marker-container';\n this.add(group);\n this._container = group;\n this.initMarker(group);\n } else {\n this.updateMarker();\n }\n }\n }\n}\n"]}
|
package/cjs/marker/line.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { IGroup } from '@visactor/vrender';
|
|
1
|
+
import type { IGroup } from '@visactor/vrender';
|
|
2
2
|
import { Marker } from './base';
|
|
3
|
-
import { MarkLineAttrs } from './type';
|
|
3
|
+
import type { MarkLineAttrs } from './type';
|
|
4
4
|
export declare class MarkLine extends Marker<MarkLineAttrs> {
|
|
5
5
|
static defaultAttributes: Partial<MarkLineAttrs>;
|
|
6
6
|
private _line;
|
|
7
7
|
constructor(attributes: MarkLineAttrs);
|
|
8
8
|
protected setLabelPos(): void;
|
|
9
|
-
protected
|
|
9
|
+
protected initMarker(container: IGroup): void;
|
|
10
|
+
protected updateMarker(): void;
|
|
10
11
|
}
|
package/cjs/marker/line.js
CHANGED
|
@@ -11,23 +11,23 @@ class MarkLine extends base_1.Marker {
|
|
|
11
11
|
super((0, vutils_1.merge)({}, MarkLine.defaultAttributes, attributes));
|
|
12
12
|
}
|
|
13
13
|
setLabelPos() {
|
|
14
|
-
var _a, _b;
|
|
14
|
+
var _a, _b, _c, _d, _e;
|
|
15
15
|
const {points: points, label: label} = this.attribute, labelPosition = null !== (_a = null == label ? void 0 : label.position) && void 0 !== _a ? _a : "end", labelAngle = this._line.getEndAngle(), labelOffsetX = (null == label ? void 0 : label.refX) * Math.cos(labelAngle) + label.refY * Math.cos(labelAngle - Math.PI / 2), labelOffsetY = (null == label ? void 0 : label.refX) * Math.sin(labelAngle) + label.refY * Math.sin(labelAngle - Math.PI / 2);
|
|
16
|
-
labelPosition.includes("start") || labelPosition.includes("Start") ? this._label.setAttributes({
|
|
16
|
+
labelPosition.includes("start") || labelPosition.includes("Start") ? null === (_b = this._label) || void 0 === _b || _b.setAttributes({
|
|
17
17
|
x: points[0].x + labelOffsetX,
|
|
18
18
|
y: points[0].y + labelOffsetY
|
|
19
|
-
}) : labelPosition.includes("middle") || labelPosition.includes("Middle") ? this._label.setAttributes({
|
|
19
|
+
}) : labelPosition.includes("middle") || labelPosition.includes("Middle") ? null === (_c = this._label) || void 0 === _c || _c.setAttributes({
|
|
20
20
|
x: (points[0].x + points[points.length - 1].x) / 2 + labelOffsetX,
|
|
21
21
|
y: (points[0].y + points[points.length - 1].y) / 2 + labelOffsetY
|
|
22
|
-
}) : this._label.setAttributes({
|
|
22
|
+
}) : null === (_d = this._label) || void 0 === _d || _d.setAttributes({
|
|
23
23
|
x: points[points.length - 1].x + labelOffsetX,
|
|
24
24
|
y: points[points.length - 1].y + labelOffsetY
|
|
25
25
|
}), this._label.setAttributes({
|
|
26
|
-
angle: label.autoRotate && labelAngle + (null !== (
|
|
26
|
+
angle: label.autoRotate && labelAngle + (null !== (_e = null == label ? void 0 : label.refAngle) && void 0 !== _e ? _e : 0),
|
|
27
27
|
textStyle: Object.assign(Object.assign({}, config_1.DEFAULT_MARK_LINE_TEXT_STYLE_MAP[labelPosition]), label.textStyle)
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
initMarker(container) {
|
|
31
31
|
const {points: points, startSymbol: startSymbol, endSymbol: endSymbol, label: label, lineStyle: lineStyle} = this.attribute, line = new segment_1.Segment({
|
|
32
32
|
points: points,
|
|
33
33
|
startSymbol: startSymbol,
|
|
@@ -39,6 +39,17 @@ class MarkLine extends base_1.Marker {
|
|
|
39
39
|
markLabel.name = "mark-line-label", this._label = markLabel, container.add(markLabel),
|
|
40
40
|
this.setLabelPos();
|
|
41
41
|
}
|
|
42
|
+
updateMarker() {
|
|
43
|
+
var _a, _b;
|
|
44
|
+
const {points: points, startSymbol: startSymbol, endSymbol: endSymbol, label: label, lineStyle: lineStyle} = this.attribute;
|
|
45
|
+
null === (_a = this._line) || void 0 === _a || _a.setAttributes({
|
|
46
|
+
points: points,
|
|
47
|
+
startSymbol: startSymbol,
|
|
48
|
+
endSymbol: endSymbol,
|
|
49
|
+
lineStyle: lineStyle
|
|
50
|
+
}), null === (_b = this._label) || void 0 === _b || _b.setAttributes(Object.assign({}, label)),
|
|
51
|
+
this.setLabelPos();
|
|
52
|
+
}
|
|
42
53
|
}
|
|
43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A0B,CAAC;QAC7F,MAAM,IAAI,GAAG,IAAI,iBAAO,CAAC;YACvB,MAAM;YACN,WAAW;YACX,SAAS;YACT,SAAS;SACV,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,SAAS,CAAC,GAAG,CAAC,IAAwB,CAAC,CAAC;QAExC,MAAM,SAAS,GAAG,IAAI,SAAG,mBACpB,KAAK,EACR,CAAC;QACH,SAAS,CAAC,IAAI,GAAG,iBAAiB,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,SAAS,CAAC,GAAG,CAAC,SAA6B,CAAC,CAAC;QAC7C,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;IAES,YAAY;;QACpB,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,SAA0B,CAAC;QAC7F,MAAA,IAAI,CAAC,KAAK,0CAAE,aAAa,CAAC;YACxB,MAAM;YACN,WAAW;YACX,SAAS;YACT,SAAS;SACV,CAAC,CAAC;QAEH,MAAA,IAAI,CAAC,MAAM,0CAAE,aAAa,mBACrB,KAAK,EACR,CAAC;QAEH,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;;AA3EH,4BA4EC;AA3EQ,0BAAiB,GAA2B,gCAAuB,CAAC","file":"line.js","sourcesContent":["import type { IGroup, INode } from '@visactor/vrender';\nimport { merge } from '@visactor/vutils';\nimport { Segment } from '../segment';\nimport { Tag } from '../tag';\nimport { Marker } from './base';\nimport { DEFAULT_MARK_LINE_THEME, DEFAULT_MARK_LINE_TEXT_STYLE_MAP } from './config';\nimport type { MarkLineAttrs } from './type';\n\nexport class MarkLine extends Marker<MarkLineAttrs> {\n static defaultAttributes: Partial<MarkLineAttrs> = DEFAULT_MARK_LINE_THEME;\n\n private _line!: Segment;\n\n constructor(attributes: MarkLineAttrs) {\n super(merge({}, MarkLine.defaultAttributes, attributes));\n }\n\n protected setLabelPos() {\n const { points, label } = this.attribute as MarkLineAttrs;\n const labelPosition = label?.position ?? 'end';\n const labelAngle = this._line.getEndAngle();\n const labelOffsetX = label?.refX * Math.cos(labelAngle) + label.refY * Math.cos(labelAngle - Math.PI / 2);\n const labelOffsetY = label?.refX * Math.sin(labelAngle) + label.refY * Math.sin(labelAngle - Math.PI / 2);\n if (labelPosition.includes('start') || labelPosition.includes('Start')) {\n this._label?.setAttributes({\n x: points[0].x + labelOffsetX,\n y: points[0].y + labelOffsetY\n });\n } else if (labelPosition.includes('middle') || labelPosition.includes('Middle')) {\n this._label?.setAttributes({\n x: (points[0].x + points[points.length - 1].x) / 2 + labelOffsetX,\n y: (points[0].y + points[points.length - 1].y) / 2 + labelOffsetY\n });\n } else {\n this._label?.setAttributes({\n x: points[points.length - 1].x + labelOffsetX,\n y: points[points.length - 1].y + labelOffsetY\n });\n }\n this._label.setAttributes({\n angle: label.autoRotate && labelAngle + (label?.refAngle ?? 0),\n textStyle: {\n ...DEFAULT_MARK_LINE_TEXT_STYLE_MAP[labelPosition],\n ...label.textStyle\n }\n });\n }\n\n protected initMarker(container: IGroup) {\n const { points, startSymbol, endSymbol, label, lineStyle } = this.attribute as MarkLineAttrs;\n const line = new Segment({\n points,\n startSymbol,\n endSymbol,\n lineStyle\n });\n line.name = 'mark-line-line';\n this._line = line;\n container.add(line as unknown as INode);\n\n const markLabel = new Tag({\n ...label\n });\n markLabel.name = 'mark-line-label';\n this._label = markLabel;\n container.add(markLabel as unknown as INode);\n this.setLabelPos();\n }\n\n protected updateMarker() {\n const { points, startSymbol, endSymbol, label, lineStyle } = this.attribute as MarkLineAttrs;\n this._line?.setAttributes({\n points,\n startSymbol,\n endSymbol,\n lineStyle\n });\n\n this._label?.setAttributes({\n ...label\n });\n\n this.setLabelPos();\n }\n}\n"]}
|
package/cjs/marker/point.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { IGroup, IImage, ISymbol, IImageGraphicAttribute, IRichText, IRichTextGraphicAttribute
|
|
2
|
-
import { IPointLike } from '@visactor/vutils';
|
|
3
|
-
import { Segment } from '../segment';
|
|
1
|
+
import type { IGroup, IImage, ISymbol, IImageGraphicAttribute, IRichText, IRichTextGraphicAttribute } from '@visactor/vrender';
|
|
2
|
+
import type { IPointLike } from '@visactor/vutils';
|
|
4
3
|
import { Tag } from '../tag';
|
|
5
4
|
import { Marker } from './base';
|
|
6
|
-
import { IItemContent, IItemLine,
|
|
5
|
+
import type { IItemContent, IItemLine, MarkPointAttrs } from './type';
|
|
6
|
+
import { IMarkPointItemPosition } from './type';
|
|
7
7
|
export declare class MarkPoint extends Marker<MarkPointAttrs> {
|
|
8
8
|
static defaultAttributes: {
|
|
9
9
|
itemLine: {
|
|
@@ -69,8 +69,16 @@ export declare class MarkPoint extends Marker<MarkPointAttrs> {
|
|
|
69
69
|
protected setItemAttributes(item: ISymbol | Tag | IImage | IRichText, itemContent: IItemContent, itemPosition: IPointLike, itemType: 'symbol' | 'text' | 'image' | 'richText' | 'custom'): void;
|
|
70
70
|
protected getItemDx(item: ISymbol | Tag | IImage | IRichText, position: IMarkPointItemPosition, style?: IImageGraphicAttribute | IRichTextGraphicAttribute): number;
|
|
71
71
|
protected getItemDy(item: ISymbol | Tag | IImage | IRichText, position: IMarkPointItemPosition, style?: IImageGraphicAttribute | IRichTextGraphicAttribute): number;
|
|
72
|
-
protected
|
|
73
|
-
protected
|
|
74
|
-
protected
|
|
75
|
-
protected
|
|
72
|
+
protected initItem(itemContent: IItemContent, itemPosition: IPointLike): IGroup | Tag | ISymbol | IImage | IRichText;
|
|
73
|
+
protected getItemLineAttr(itemLine: IItemLine, position: IPointLike, itemPosition: IPointLike): IPointLike[];
|
|
74
|
+
protected setItemLineAttr(itemLine: IItemLine, position: IPointLike, itemPosition: IPointLike, visible: boolean): void;
|
|
75
|
+
protected getDecorativeLineAttr(itemLine: IItemLine, itemPosition: IPointLike): {
|
|
76
|
+
startPointOffsetX: number;
|
|
77
|
+
startPointOffsetY: number;
|
|
78
|
+
endPointOffsetX: number;
|
|
79
|
+
endPointOffsetY: number;
|
|
80
|
+
};
|
|
81
|
+
protected setDecorativeLineAttr(itemLine: IItemLine, itemPosition: IPointLike, visible: boolean): void;
|
|
82
|
+
protected initMarker(container: IGroup): void;
|
|
83
|
+
protected updateMarker(): void;
|
|
76
84
|
}
|
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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import {\n createRichText,\n createSymbol,\n createImage,\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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,CAAC,GAAG,CAAC,CAAA,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"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FederatedPointerEvent, IGraphic, IPlugin, IPluginService } from '@visactor/vrender';
|
|
2
2
|
export declare class PopTipPlugin implements IPlugin {
|
|
3
|
-
name: '
|
|
3
|
+
name: 'poptip';
|
|
4
4
|
activeEvent: 'onRegister';
|
|
5
5
|
pluginService: IPluginService;
|
|
6
6
|
_uid: number;
|
|
@@ -14,7 +14,7 @@ const inversify_1 = require("inversify"), vrender_1 = require("@visactor/vrender
|
|
|
14
14
|
|
|
15
15
|
let PopTipPlugin = class {
|
|
16
16
|
constructor() {
|
|
17
|
-
this.name = "
|
|
17
|
+
this.name = "poptip", this.activeEvent = "onRegister", this._uid = vrender_1.Generator.GenAutoIncrementId(),
|
|
18
18
|
this.key = this.name + this._uid, this.poptip = e => {
|
|
19
19
|
const graphic = e.target;
|
|
20
20
|
if (graphic.isContainer || !graphic.attribute || graphic === this.activeGraphic) return void this.unpoptip(e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["poptip/poptip-plugin.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yCAAuC;AAEvC,+CAA8C;AAGvC,IAAM,YAAY,GAAlB,MAAM,YAAY;IAAlB;QACL,SAAI,
|
|
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,CAAwB,EAAE,EAAE;YACpC,MAAM,OAAO,GAAG,CAAC,CAAC,MAAa,CAAC;YAChC,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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"]}
|
package/cjs/poptip/poptip.js
CHANGED
|
@@ -22,7 +22,7 @@ class PopTip extends base_1.AbstractComponent {
|
|
|
22
22
|
}
|
|
23
23
|
render() {
|
|
24
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} = this.attribute, parsedPadding = (0,
|
|
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
26
|
vutils_1.normalizePadding)(padding), group = this.createOrUpdateChild("poptip-content", {
|
|
27
27
|
x: 0,
|
|
28
28
|
y: 0,
|
|
@@ -84,8 +84,8 @@ class PopTip extends base_1.AbstractComponent {
|
|
|
84
84
|
(0, vutils_1.isEmpty)(null == state ? void 0 : state.panel) || (bgRect.states = state.panel);
|
|
85
85
|
}
|
|
86
86
|
group.setAttributes({
|
|
87
|
-
x: -offset[0],
|
|
88
|
-
y: -offset[1]
|
|
87
|
+
x: -offset[0] + dx,
|
|
88
|
+
y: -offset[1] + dy
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
getAngleAndOffset(position, width, height, size) {
|