@visactor/vrender-components 0.15.0-alpha.23 → 0.15.0-alpha.25
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/label/arc.d.ts +5 -2
- package/cjs/label/arc.js +23 -37
- package/cjs/label/arc.js.map +1 -1
- package/cjs/label/base.js +8 -8
- package/cjs/label/base.js.map +1 -1
- package/cjs/legend/size/size.d.ts +2 -2
- package/cjs/legend/size/size.js.map +1 -1
- package/cjs/link-path/index.js +1 -2
- package/cjs/link-path/link-path.js +1 -1
- package/cjs/link-path/type.js +1 -1
- package/cjs/marker/area.d.ts +20 -1
- package/cjs/marker/area.js +35 -33
- package/cjs/marker/area.js.map +1 -1
- package/cjs/marker/base.d.ts +0 -1
- package/cjs/marker/base.js +17 -24
- package/cjs/marker/base.js.map +1 -1
- package/cjs/marker/config.d.ts +1 -1
- package/cjs/marker/config.js.map +1 -1
- package/cjs/marker/line.js +12 -23
- package/cjs/marker/line.js.map +1 -1
- package/cjs/marker/point.d.ts +7 -7
- package/cjs/marker/point.js +7 -16
- package/cjs/marker/point.js.map +1 -1
- package/cjs/marker/type.d.ts +5 -9
- package/cjs/marker/type.js.map +1 -1
- package/cjs/pager/index.js +2 -1
- package/cjs/pager/pager.js +1 -1
- package/cjs/pager/type.js +1 -1
- package/cjs/segment/segment.d.ts +6 -11
- package/cjs/segment/segment.js +40 -82
- package/cjs/segment/segment.js.map +1 -1
- package/cjs/segment/type.d.ts +3 -5
- package/cjs/segment/type.js.map +1 -1
- package/cjs/util/index.d.ts +1 -1
- package/cjs/util/index.js +1 -1
- package/cjs/util/index.js.map +1 -1
- package/cjs/util/{label-smartInvert.js → labelSmartInvert.js} +1 -1
- package/cjs/util/labelSmartInvert.js.map +1 -0
- package/dist/index.js +163 -297
- 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/label/arc.d.ts +5 -2
- package/es/label/arc.js +23 -36
- package/es/label/arc.js.map +1 -1
- package/es/label/base.js +1 -1
- package/es/label/base.js.map +1 -1
- package/es/legend/size/size.d.ts +2 -2
- package/es/legend/size/size.js.map +1 -1
- package/es/link-path/index.js +1 -2
- package/es/link-path/link-path.js +1 -1
- package/es/link-path/type.js +1 -1
- package/es/marker/area.d.ts +20 -1
- package/es/marker/area.js +34 -34
- package/es/marker/area.js.map +1 -1
- package/es/marker/base.d.ts +0 -1
- package/es/marker/base.js +18 -22
- package/es/marker/base.js.map +1 -1
- package/es/marker/config.d.ts +1 -1
- package/es/marker/config.js.map +1 -1
- package/es/marker/line.js +11 -24
- package/es/marker/line.js.map +1 -1
- package/es/marker/point.d.ts +7 -7
- package/es/marker/point.js +6 -17
- package/es/marker/point.js.map +1 -1
- package/es/marker/type.d.ts +5 -9
- package/es/marker/type.js.map +1 -1
- package/es/pager/index.js +2 -1
- package/es/pager/pager.js +1 -1
- package/es/pager/type.js +1 -1
- package/es/segment/segment.d.ts +6 -11
- package/es/segment/segment.js +41 -81
- package/es/segment/segment.js.map +1 -1
- package/es/segment/type.d.ts +3 -5
- package/es/segment/type.js.map +1 -1
- package/es/util/index.d.ts +1 -1
- package/es/util/index.js +1 -1
- package/es/util/index.js.map +1 -1
- package/es/util/{label-smartInvert.js → labelSmartInvert.js} +1 -1
- package/es/util/labelSmartInvert.js.map +1 -0
- package/package.json +2 -2
- package/cjs/marker/util.d.ts +0 -1
- package/cjs/marker/util.js +0 -3
- package/cjs/marker/util.js.map +0 -1
- package/cjs/util/label-smartInvert.js.map +0 -1
- package/cjs/util/limit-shape.d.ts +0 -3
- package/cjs/util/limit-shape.js +0 -14
- package/cjs/util/limit-shape.js.map +0 -1
- package/es/marker/util.d.ts +0 -1
- package/es/marker/util.js +0 -3
- package/es/marker/util.js.map +0 -1
- package/es/util/label-smartInvert.js.map +0 -1
- package/es/util/limit-shape.d.ts +0 -3
- package/es/util/limit-shape.js +0 -8
- package/es/util/limit-shape.js.map +0 -1
- /package/cjs/util/{label-smartInvert.d.ts → labelSmartInvert.d.ts} +0 -0
- /package/es/util/{label-smartInvert.d.ts → labelSmartInvert.d.ts} +0 -0
package/es/marker/line.js
CHANGED
|
@@ -8,46 +8,33 @@ import { Marker } from "./base";
|
|
|
8
8
|
|
|
9
9
|
import { DEFAULT_MARK_LINE_THEME, DEFAULT_MARK_LINE_TEXT_STYLE_MAP } from "./config";
|
|
10
10
|
|
|
11
|
-
import { limitShapeInBounds } from "../util/limit-shape";
|
|
12
|
-
|
|
13
11
|
export class MarkLine extends Marker {
|
|
14
12
|
constructor(attributes) {
|
|
15
13
|
super(merge({}, MarkLine.defaultAttributes, attributes));
|
|
16
14
|
}
|
|
17
15
|
setLabelPos() {
|
|
18
|
-
var _a, _b;
|
|
19
|
-
const {
|
|
20
|
-
|
|
21
|
-
if (labelPoint = position.includes("start") || position.includes("Start") ? {
|
|
16
|
+
var _a, _b, _c, _d, _e;
|
|
17
|
+
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);
|
|
18
|
+
labelPosition.includes("start") || labelPosition.includes("Start") ? null === (_b = this._label) || void 0 === _b || _b.setAttributes({
|
|
22
19
|
x: points[0].x + labelOffsetX,
|
|
23
20
|
y: points[0].y + labelOffsetY
|
|
24
|
-
} :
|
|
21
|
+
}) : labelPosition.includes("middle") || labelPosition.includes("Middle") ? null === (_c = this._label) || void 0 === _c || _c.setAttributes({
|
|
25
22
|
x: (points[0].x + points[points.length - 1].x) / 2 + labelOffsetX,
|
|
26
23
|
y: (points[0].y + points[points.length - 1].y) / 2 + labelOffsetY
|
|
27
|
-
} : {
|
|
24
|
+
}) : null === (_d = this._label) || void 0 === _d || _d.setAttributes({
|
|
28
25
|
x: points[points.length - 1].x + labelOffsetX,
|
|
29
26
|
y: points[points.length - 1].y + labelOffsetY
|
|
30
|
-
}, this._label.setAttributes(
|
|
31
|
-
angle: label.autoRotate
|
|
32
|
-
textStyle: Object.assign(Object.assign({}, DEFAULT_MARK_LINE_TEXT_STYLE_MAP[
|
|
33
|
-
})
|
|
34
|
-
const {x: x, y: y, width: width, height: height} = limitRect;
|
|
35
|
-
limitShapeInBounds(this._label, {
|
|
36
|
-
x1: x,
|
|
37
|
-
y1: y,
|
|
38
|
-
x2: x + width,
|
|
39
|
-
y2: y + height
|
|
40
|
-
});
|
|
41
|
-
}
|
|
27
|
+
}), this._label.setAttributes({
|
|
28
|
+
angle: label.autoRotate && labelAngle + (null !== (_e = null == label ? void 0 : label.refAngle) && void 0 !== _e ? _e : 0),
|
|
29
|
+
textStyle: Object.assign(Object.assign({}, DEFAULT_MARK_LINE_TEXT_STYLE_MAP[labelPosition]), label.textStyle)
|
|
30
|
+
});
|
|
42
31
|
}
|
|
43
32
|
initMarker(container) {
|
|
44
|
-
const {points: points, startSymbol: startSymbol, endSymbol: endSymbol, label: label, lineStyle: lineStyle
|
|
33
|
+
const {points: points, startSymbol: startSymbol, endSymbol: endSymbol, label: label, lineStyle: lineStyle} = this.attribute, line = new Segment({
|
|
45
34
|
points: points,
|
|
46
35
|
startSymbol: startSymbol,
|
|
47
36
|
endSymbol: endSymbol,
|
|
48
|
-
lineStyle: lineStyle
|
|
49
|
-
mainSegmentIndex: mainSegmentIndex,
|
|
50
|
-
multiSegment: multiSegment
|
|
37
|
+
lineStyle: lineStyle
|
|
51
38
|
});
|
|
52
39
|
line.name = "mark-line-line", this._line = line, container.add(line);
|
|
53
40
|
const markLabel = new Tag(Object.assign({}, label));
|
package/es/marker/line.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":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YAC9D,SAAS,kCACJ,gCAAgC,CAAC,aAAa,CAAC,GAC/C,KAAK,CAAC,SAAS,CACnB;SACF,CAAC,CAAC;IACL,CAAC;IAES,UAAU,CAAC,SAAiB;QACpC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,SAA0B,CAAC;QAC7F,MAAM,IAAI,GAAG,IAAI,OAAO,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,GAAG,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;;AA1EM,0BAAiB,GAA2B,uBAAuB,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/es/marker/point.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { IGroup, IImage, ISymbol, IImageGraphicAttribute, IRichText, IRichTextGraphicAttribute } from '@visactor/vrender';
|
|
2
|
+
import type { IPointLike } from '@visactor/vutils';
|
|
2
3
|
import { Tag } from '../tag';
|
|
3
4
|
import { Marker } from './base';
|
|
4
5
|
import type { IItemContent, IItemLine, MarkPointAttrs } from './type';
|
|
5
6
|
import { IMarkPointItemPosition } from './type';
|
|
6
|
-
import type { Point } from '../core/type';
|
|
7
7
|
export declare class MarkPoint extends Marker<MarkPointAttrs> {
|
|
8
8
|
static defaultAttributes: {
|
|
9
9
|
itemLine: {
|
|
@@ -66,19 +66,19 @@ export declare class MarkPoint extends Marker<MarkPointAttrs> {
|
|
|
66
66
|
private _decorativeLine;
|
|
67
67
|
constructor(attributes: MarkPointAttrs);
|
|
68
68
|
protected setLabelPos(): void;
|
|
69
|
-
protected setItemAttributes(item: ISymbol | Tag | IImage | IRichText, itemContent: IItemContent, itemPosition:
|
|
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 initItem(itemContent: IItemContent, itemPosition:
|
|
73
|
-
protected getItemLineAttr(itemLine: IItemLine, position:
|
|
74
|
-
protected setItemLineAttr(itemLine: IItemLine, position:
|
|
75
|
-
protected getDecorativeLineAttr(itemLine: IItemLine, itemPosition:
|
|
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
76
|
startPointOffsetX: number;
|
|
77
77
|
startPointOffsetY: number;
|
|
78
78
|
endPointOffsetX: number;
|
|
79
79
|
endPointOffsetY: number;
|
|
80
80
|
};
|
|
81
|
-
protected setDecorativeLineAttr(itemLine: IItemLine, itemPosition:
|
|
81
|
+
protected setDecorativeLineAttr(itemLine: IItemLine, itemPosition: IPointLike, visible: boolean): void;
|
|
82
82
|
protected initMarker(container: IGroup): void;
|
|
83
83
|
protected updateMarker(): void;
|
|
84
84
|
}
|
package/es/marker/point.js
CHANGED
|
@@ -12,38 +12,27 @@ import { DEFAULT_MARK_POINT_TEXT_STYLE_MAP, DEFAULT_MARK_POINT_THEME } from "./c
|
|
|
12
12
|
|
|
13
13
|
import { IMarkPointItemPosition } from "./type";
|
|
14
14
|
|
|
15
|
-
import { limitShapeInBounds } from "../util/limit-shape";
|
|
16
|
-
|
|
17
15
|
export class MarkPoint extends Marker {
|
|
18
16
|
constructor(attributes) {
|
|
19
17
|
super(merge({}, MarkPoint.defaultAttributes, attributes));
|
|
20
18
|
}
|
|
21
19
|
setLabelPos() {}
|
|
22
20
|
setItemAttributes(item, itemContent, itemPosition, itemType) {
|
|
23
|
-
var _a
|
|
24
|
-
if (!item) return;
|
|
21
|
+
var _a;
|
|
25
22
|
const {autoRotate: autoRotate = !0, refX: refX = 0, refY: refY = 0, refAngle: refAngle = 0, textStyle: textStyle, richTextStyle: richTextStyle, imageStyle: imageStyle, position: position = 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);
|
|
26
|
-
|
|
23
|
+
"text" === itemType ? null == item || item.setAttributes(Object.assign(Object.assign({}, textStyle), {
|
|
27
24
|
textStyle: Object.assign(Object.assign({}, DEFAULT_MARK_POINT_TEXT_STYLE_MAP[(null == itemContent ? void 0 : itemContent.position) || "end"]), null == textStyle ? void 0 : textStyle.textStyle)
|
|
28
|
-
})) : "richText" === itemType ? item.setAttributes({
|
|
25
|
+
})) : "richText" === itemType ? null == item || item.setAttributes({
|
|
29
26
|
dx: this.getItemDx(item, position, richTextStyle) + ((null == richTextStyle ? void 0 : richTextStyle.dx) || 0),
|
|
30
27
|
dy: this.getItemDy(item, position, richTextStyle) + ((null == richTextStyle ? void 0 : richTextStyle.dy) || 0)
|
|
31
|
-
}) : "image" === itemType && item.setAttributes({
|
|
28
|
+
}) : "image" === itemType && (null == item || item.setAttributes({
|
|
32
29
|
dx: this.getItemDx(item, position, imageStyle) + ((null == imageStyle ? void 0 : imageStyle.dx) || 0),
|
|
33
30
|
dy: this.getItemDy(item, position, imageStyle) + ((null == imageStyle ? void 0 : imageStyle.dy) || 0)
|
|
34
|
-
}), item.setAttributes({
|
|
31
|
+
})), null == item || item.setAttributes({
|
|
35
32
|
x: itemPosition.x + (itemOffsetX || 0),
|
|
36
33
|
y: itemPosition.y + (itemOffsetY || 0),
|
|
37
34
|
angle: autoRotate && itemAngle + refAngle
|
|
38
|
-
})
|
|
39
|
-
const {x: x, y: y, width: width, height: height} = this.attribute.limitRect;
|
|
40
|
-
limitShapeInBounds(item, {
|
|
41
|
-
x1: x,
|
|
42
|
-
y1: y,
|
|
43
|
-
x2: x + width,
|
|
44
|
-
y2: y + height
|
|
45
|
-
});
|
|
46
|
-
}
|
|
35
|
+
});
|
|
47
36
|
}
|
|
48
37
|
getItemDx(item, position, style) {
|
|
49
38
|
var _a, _b;
|
package/es/marker/point.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/marker/point.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG1F,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,iCAAiC,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAGvF,OAAO,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,OAAO,SAAU,SAAQ,MAAsB;IASnD,YAAY,UAA0B;QACpC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,SAAS,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;IAC5D,CAAC;IAES,WAAW;IAErB,CAAC;IAES,iBAAiB,CACzB,IAAwC,EACxC,WAAyB,EACzB,YAAmB,EACnB,QAA6D;;QAE7D,IAAI,CAAC,IAAI,EAAE;YACT,OAAO;SACR;QACD,MAAM,EACJ,UAAU,GAAG,IAAI,EACjB,IAAI,GAAG,CAAC,EACR,IAAI,GAAG,CAAC,EACR,QAAQ,GAAG,CAAC,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,QAAQ,GAAG,sBAAsB,CAAC,MAAM,EACzC,GAAG,WAAW,CAAC;QAChB,MAAM,SAAS,GAAG,CAAA,MAAA,IAAI,CAAC,KAAK,0CAA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I,CAAC,CAAC;IACtE,CAAC;;AAjQM,2BAAiB,GAAG,wBAAwB,CAAC","file":"point.js","sourcesContent":["import type {\n IGroup,\n IImage,\n INode,\n ISymbol,\n IImageGraphicAttribute,\n IRichText,\n IRichTextGraphicAttribute,\n ILine,\n ILineGraphicAttribute\n} from '@visactor/vrender';\n// eslint-disable-next-line no-duplicate-imports\nimport { createRichText, createSymbol, createImage, createLine } from '@visactor/vrender';\nimport type { IPointLike } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\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';\n// eslint-disable-next-line no-duplicate-imports\nimport { IMarkPointItemPosition } from './type';\nimport type { Point } from '../core/type';\nimport { limitShapeInBounds } from '../util/limit-shape';\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: Point,\n itemType: 'symbol' | 'text' | 'image' | 'richText' | 'custom'\n ) {\n if (!item) {\n return;\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 if (this.attribute.limitRect && this.attribute.itemContent?.confine) {\n const { x, y, width, height } = this.attribute.limitRect;\n limitShapeInBounds(item, {\n x1: x,\n y1: y,\n x2: x + width,\n y2: y + height\n });\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 }\n 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 }\n if (position.includes('middle') || position.includes('Middle')) {\n return -height / 2;\n }\n return 0;\n }\n\n protected initItem(itemContent: IItemContent, itemPosition: Point) {\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: Point, itemPosition: Point) {\n let points: Point[] = [];\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: Point, itemPosition: Point, 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: Point) {\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: Point, 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 ] as IPointLike[],\n ...(lineStyle as Partial<ILineGraphicAttribute>),\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
|
+
{"version":3,"sources":["../src/marker/point.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,C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CAAC,GAAG,CAAC,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,KAAI,CAAC,CAAC;YAC3C,CAAC,EAAE,QAAQ,CAAC,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;;AAlPM,2BAAiB,GAAG,wBAAwB,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"]}
|
package/es/marker/type.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IGroup, IGroupGraphicAttribute, IImageGraphicAttribute, IPolygonAttribute, IRichTextGraphicAttribute, ISymbolGraphicAttribute } from '@visactor/vrender';
|
|
2
|
+
import type { IPointLike } from '@visactor/vutils';
|
|
2
3
|
import type { SegmentAttributes, SymbolAttributes } from '../segment';
|
|
3
4
|
import type { TagAttributes } from '../tag';
|
|
4
|
-
import type { Point } from '../core/type';
|
|
5
5
|
export declare enum IMarkLineLabelPosition {
|
|
6
6
|
start = "start",
|
|
7
7
|
middle = "middle",
|
|
@@ -50,8 +50,7 @@ export interface MarkerAttrs extends IGroupGraphicAttribute {
|
|
|
50
50
|
type?: 'line' | 'area' | 'point';
|
|
51
51
|
interactive?: boolean;
|
|
52
52
|
visible?: boolean;
|
|
53
|
-
|
|
54
|
-
limitRect?: {
|
|
53
|
+
clipRange?: {
|
|
55
54
|
x: number;
|
|
56
55
|
y: number;
|
|
57
56
|
width: number;
|
|
@@ -60,18 +59,16 @@ export interface MarkerAttrs extends IGroupGraphicAttribute {
|
|
|
60
59
|
}
|
|
61
60
|
export interface MarkLineAttrs extends MarkerAttrs, SegmentAttributes {
|
|
62
61
|
type?: 'line';
|
|
63
|
-
points:
|
|
62
|
+
points: IPointLike[];
|
|
64
63
|
label?: {
|
|
65
64
|
position?: keyof typeof IMarkLineLabelPosition;
|
|
66
|
-
confine?: boolean;
|
|
67
65
|
} & IMarkRef & IMarkLabel;
|
|
68
66
|
}
|
|
69
67
|
export interface MarkAreaAttrs extends MarkerAttrs {
|
|
70
68
|
type?: 'area';
|
|
71
|
-
points:
|
|
69
|
+
points: IPointLike[];
|
|
72
70
|
label?: {
|
|
73
71
|
position?: IMarkAreaLabelPosition;
|
|
74
|
-
confine?: boolean;
|
|
75
72
|
} & IMarkLabel;
|
|
76
73
|
areaStyle?: IPolygonAttribute;
|
|
77
74
|
}
|
|
@@ -85,7 +82,6 @@ export interface IItemContent extends IMarkRef {
|
|
|
85
82
|
textStyle?: IMarkLabel;
|
|
86
83
|
richTextStyle?: IRichTextGraphicAttribute;
|
|
87
84
|
renderCustomCallback?: () => IGroup;
|
|
88
|
-
confine?: boolean;
|
|
89
85
|
}
|
|
90
86
|
export type IItemLine = {
|
|
91
87
|
type?: 'type-s' | 'type-do' | 'type-po' | 'type-op';
|
|
@@ -96,7 +92,7 @@ export type IItemLine = {
|
|
|
96
92
|
};
|
|
97
93
|
} & Omit<SegmentAttributes, 'points'>;
|
|
98
94
|
export interface MarkPointAttrs extends Omit<MarkerAttrs, 'labelStyle'> {
|
|
99
|
-
position:
|
|
95
|
+
position: IPointLike;
|
|
100
96
|
itemLine?: IItemLine;
|
|
101
97
|
itemContent?: IItemContent;
|
|
102
98
|
}
|
package/es/marker/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/marker/type.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/marker/type.ts"],"names":[],"mappings":"AAaA,MAAM,CAAN,IAAY,sBAUX;AAVD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,2CAAiB,CAAA;IACjB,qCAAW,CAAA;IACX,2DAAiC,CAAA;IACjC,iEAAuC,CAAA;IACvC,6DAAmC,CAAA;IACnC,mEAAyC,CAAA;IACzC,uDAA6B,CAAA;IAC7B,6DAAmC,CAAA;AACrC,CAAC,EAVW,sBAAsB,KAAtB,sBAAsB,QAUjC;AAED,MAAM,CAAN,IAAY,sBAUX;AAVD,WAAY,sBAAsB;IAChC,uCAAa,CAAA;IACb,yCAAe,CAAA;IACf,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;IACjB,mDAAyB,CAAA;IACzB,qDAA2B,CAAA;IAC3B,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;AAC/B,CAAC,EAVW,sBAAsB,KAAtB,sBAAsB,QAUjC;AAED,MAAM,CAAN,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IAChC,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;IACjB,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;IAC7B,uDAA6B,CAAA;AAC/B,CAAC,EAPW,sBAAsB,KAAtB,sBAAsB,QAOjC","file":"type.js","sourcesContent":["import type {\n IGroup,\n IGroupGraphicAttribute,\n IImageGraphicAttribute,\n IPolygonAttribute,\n IRichTextGraphicAttribute,\n ISymbolGraphicAttribute\n} from '@visactor/vrender';\nimport { IGraphic } from '@visactor/vrender';\nimport type { Dict, IPointLike } from '@visactor/vutils';\nimport type { SegmentAttributes, SymbolAttributes } from '../segment';\nimport type { TagAttributes } from '../tag';\n\nexport enum IMarkLineLabelPosition {\n start = 'start',\n middle = 'middle',\n end = 'end',\n insideStartTop = 'insideStartTop',\n insideStartBottom = 'insideStartBottom',\n insideMiddleTop = 'insideMiddleTop',\n insideMiddleBottom = 'insideMiddleBottom',\n insideEndTop = 'insideEndTop',\n insideEndBottom = 'insideEndBottom'\n}\n\nexport enum IMarkAreaLabelPosition {\n left = 'left',\n right = 'right',\n top = 'top',\n bottom = 'bottom',\n middle = 'middle',\n insideLeft = 'insideLeft',\n insideRight = 'insideRight',\n insideTop = 'insideTop',\n insideBottom = 'insideBottom'\n}\n\nexport enum IMarkPointItemPosition {\n top = 'top',\n bottom = 'bottom',\n middle = 'middle',\n insideTop = 'insideTop',\n insideBottom = 'insideBottom',\n insideMiddle = 'insideMiddle'\n}\n\nexport type IMarkBackgroundAttributes = {\n /**\n * 是否绘制背景层\n */\n visible: boolean;\n /**\n * TODO: 根据文字宽度进行背景 panel size自适应\n */\n autoHeight?: boolean;\n /**\n * TODO: 根据文高度度进行背景 panel size自适应\n */\n autoWidth?: boolean;\n} & Partial<SymbolAttributes>;\n\nexport interface IMarkLabel extends Omit<TagAttributes, 'x' | 'y' | 'panel'> {\n /**\n * 标签的背景面板配置\n */\n panel?: IMarkBackgroundAttributes;\n}\n\nexport interface IMarkRef {\n /**\n * 自动旋转,沿着线的方向,默认 true\n */\n autoRotate?: boolean;\n /**\n * label 相对line平行方向上的偏移\n */\n refX?: number;\n /**\n * label 相对line正交方向上的偏移\n */\n refY?: number;\n /**\n * label 相对默认角度的偏移 (label跟随line的角度做自动旋转时,默认按照line的平行向量作为初始角度)\n */\n refAngle?: number;\n}\n\nexport interface MarkerAttrs extends IGroupGraphicAttribute {\n type?: 'line' | 'area' | 'point';\n /**\n * 是否支持交互\n * @default false\n */\n interactive?: boolean;\n /**\n * 是否显示marker组件\n * @default true\n */\n visible?: boolean;\n /**\n * clip范围配置\n */\n clipRange?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n}\n\nexport interface MarkLineAttrs extends MarkerAttrs, SegmentAttributes {\n type?: 'line';\n /**\n * 构成line的点: 如果是两个点,则为直线;多个点则为曲线\n */\n points: IPointLike[];\n /**\n * 标签\n */\n label?: {\n /**\n * label 相对line的位置\n */\n position?: keyof typeof IMarkLineLabelPosition;\n } & IMarkRef &\n IMarkLabel;\n}\n\nexport interface MarkAreaAttrs extends MarkerAttrs {\n type?: 'area';\n /**\n * 构成area的点\n */\n points: IPointLike[];\n /**\n * 标签\n */\n label?: {\n position?: IMarkAreaLabelPosition;\n } & IMarkLabel;\n /**\n * area的样式\n */\n areaStyle?: IPolygonAttribute;\n}\n\nexport interface IItemContent extends IMarkRef {\n /**\n * 标注类型\n */\n type?: 'symbol' | 'text' | 'image' | 'richText' | 'custom';\n position?: IMarkPointItemPosition;\n /**\n * x 方向偏移量\n */\n offsetX?: number;\n /**\n * y 方向偏移量\n */\n offsetY?: number;\n /**\n * type为symbol时, symbol的样式\n */\n symbolStyle?: ISymbolGraphicAttribute;\n /**\n * type为image时, image的样式\n */\n imageStyle?: IImageGraphicAttribute;\n /**\n * type为text时, text的配置\n */\n textStyle?: IMarkLabel;\n /**\n * type为rich text时, rich text的样式\n */\n richTextStyle?: IRichTextGraphicAttribute;\n /**\n * type为custom时,允许以callback的方式传入需要render的item\n */\n renderCustomCallback?: () => IGroup;\n}\n\nexport type IItemLine = {\n /** TODO:'type-opo' */\n type?: 'type-s' | 'type-do' | 'type-po' | 'type-op';\n visible?: boolean;\n /**\n * 垂直于引导线的装饰线,参考案例: https://observablehq.com/@mikelotis/edmonton-population-history-line-chart\n */\n decorativeLine?: {\n visible?: boolean;\n length?: number;\n };\n} & Omit<SegmentAttributes, 'points'>;\n\nexport interface MarkPointAttrs extends Omit<MarkerAttrs, 'labelStyle'> {\n /**\n * markPoint的位置(也是path的起点)\n */\n position: IPointLike;\n /**\n * 标注引导线\n */\n itemLine?: IItemLine;\n\n /**\n * 标注内容\n */\n itemContent?: IItemContent;\n}\n"]}
|
package/es/pager/index.js
CHANGED
package/es/pager/pager.js
CHANGED
package/es/pager/type.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { };
|
|
2
|
-
//# sourceMappingURL=type.js.map
|
|
2
|
+
//# sourceMappingURL=type.js.map
|
package/es/segment/segment.d.ts
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
import type { ISymbol } from '@visactor/vrender';
|
|
1
|
+
import type { ILine, ISymbol } from '@visactor/vrender';
|
|
2
2
|
import { AbstractComponent } from '../core/base';
|
|
3
3
|
import type { SegmentAttributes } from './type';
|
|
4
|
-
import type { Point } from '../core/type';
|
|
5
4
|
export declare class Segment extends AbstractComponent<Required<SegmentAttributes>> {
|
|
6
5
|
name: string;
|
|
6
|
+
line: ILine;
|
|
7
7
|
startSymbol?: ISymbol;
|
|
8
8
|
endSymbol?: ISymbol;
|
|
9
9
|
private _startAngle;
|
|
10
|
-
getStartAngle(): number;
|
|
11
10
|
private _endAngle;
|
|
12
|
-
getEndAngle(): number;
|
|
13
|
-
private _mainSegmentPoints;
|
|
14
|
-
getMainSegmentPoints(): Point[];
|
|
15
11
|
static defaultAttributes: Partial<SegmentAttributes>;
|
|
16
12
|
constructor(attributes: SegmentAttributes);
|
|
13
|
+
protected computeLineAngle(): void;
|
|
17
14
|
protected render(): void;
|
|
18
|
-
private
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
private _computeLineAngle;
|
|
22
|
-
private _reset;
|
|
15
|
+
private renderSymbol;
|
|
16
|
+
getStartAngle(): number;
|
|
17
|
+
getEndAngle(): number;
|
|
23
18
|
}
|
package/es/segment/segment.js
CHANGED
|
@@ -1,114 +1,74 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isEmpty, merge } from "@visactor/vutils";
|
|
2
2
|
|
|
3
3
|
import { createSymbol, createLine } from "@visactor/vrender";
|
|
4
4
|
|
|
5
5
|
import { AbstractComponent } from "../core/base";
|
|
6
6
|
|
|
7
7
|
export class Segment extends AbstractComponent {
|
|
8
|
-
getStartAngle() {
|
|
9
|
-
return this._startAngle;
|
|
10
|
-
}
|
|
11
|
-
getEndAngle() {
|
|
12
|
-
return this._endAngle;
|
|
13
|
-
}
|
|
14
|
-
getMainSegmentPoints() {
|
|
15
|
-
return this._mainSegmentPoints;
|
|
16
|
-
}
|
|
17
8
|
constructor(attributes) {
|
|
18
9
|
super(merge({}, Segment.defaultAttributes, attributes)), this.name = "segment";
|
|
19
10
|
}
|
|
11
|
+
computeLineAngle() {
|
|
12
|
+
const {points: points} = this.attribute, start = points[0], startInside = points[1], endInside = points[points.length - 2], end = points[points.length - 1], startVector = [ start.x - startInside.x, start.y - startInside.y ], startAngle = Math.atan2(startVector[1], startVector[0]), endVector = [ end.x - endInside.x, end.y - endInside.y ], endAngle = Math.atan2(endVector[1], endVector[0]);
|
|
13
|
+
this._startAngle = startAngle, this._endAngle = endAngle;
|
|
14
|
+
}
|
|
20
15
|
render() {
|
|
21
|
-
this.removeAllChild()
|
|
22
|
-
const {startSymbol: startSymbol, endSymbol: endSymbol, lineStyle: lineStyle, state: state, visible: visible = !0
|
|
16
|
+
this.removeAllChild();
|
|
17
|
+
const {points: points, startSymbol: startSymbol, endSymbol: endSymbol, lineStyle: lineStyle, state: state, visible: visible = !0} = this.attribute;
|
|
23
18
|
if (!visible) return;
|
|
24
|
-
this.
|
|
25
|
-
const startSymbolShape = this.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}));
|
|
42
|
-
} else {
|
|
43
|
-
const line = createLine(Object.assign(Object.assign({
|
|
44
|
-
points: this._clipPoints(this.attribute.points)
|
|
45
|
-
}, array(lineStyle)[0]), {
|
|
46
|
-
fill: !1
|
|
47
|
-
}));
|
|
48
|
-
line.name = `${this.name}-line`, line.id = this._getNodeId("line"), isEmpty(null == state ? void 0 : state.line) || (line.states = [].concat(state.line)[0]),
|
|
49
|
-
this.add(line);
|
|
19
|
+
points.length > 1 && this.computeLineAngle();
|
|
20
|
+
const startSymbolShape = this.renderSymbol(startSymbol, "start"), endSymbolShape = this.renderSymbol(endSymbol, "end");
|
|
21
|
+
this.startSymbol = startSymbolShape, this.endSymbol = endSymbolShape;
|
|
22
|
+
let pointsAfterClip = points;
|
|
23
|
+
if (null == startSymbol ? void 0 : startSymbol.visible) {
|
|
24
|
+
const startSize = (null == startSymbol ? void 0 : startSymbol.clip) ? (null == startSymbol ? void 0 : startSymbol.size) || 10 : 0;
|
|
25
|
+
pointsAfterClip = [ {
|
|
26
|
+
x: points[0].x - startSize / 2 * (Math.cos(this._startAngle) || 0),
|
|
27
|
+
y: points[0].y - startSize / 2 * (Math.sin(this._startAngle) || 0)
|
|
28
|
+
}, ...pointsAfterClip.slice(1) ];
|
|
29
|
+
}
|
|
30
|
+
if (null == endSymbol ? void 0 : endSymbol.visible) {
|
|
31
|
+
const endSize = (null == endSymbol ? void 0 : endSymbol.clip) ? (null == endSymbol ? void 0 : endSymbol.size) || 10 : 0, pointsEnd = {
|
|
32
|
+
x: points[points.length - 1].x - endSize / 2 * (Math.cos(this._endAngle) || 0),
|
|
33
|
+
y: points[points.length - 1].y - endSize / 2 * (Math.sin(this._endAngle) || 0)
|
|
34
|
+
};
|
|
35
|
+
pointsAfterClip = [ ...pointsAfterClip.slice(0, pointsAfterClip.length - 1), pointsEnd ];
|
|
50
36
|
}
|
|
37
|
+
const line = createLine(Object.assign({
|
|
38
|
+
points: pointsAfterClip,
|
|
39
|
+
fill: !1
|
|
40
|
+
}, lineStyle));
|
|
41
|
+
line.name = "line", line.id = this._getNodeId("line"), isEmpty(null == state ? void 0 : state.line) || (line.states = state.line),
|
|
42
|
+
this.line = line, this.add(line);
|
|
51
43
|
}
|
|
52
|
-
|
|
53
|
-
const points = this._getMainSegmentPoints();
|
|
54
|
-
if (!points.length) return;
|
|
44
|
+
renderSymbol(attribute, dim) {
|
|
55
45
|
const {autoRotate: autoRotate = !0} = attribute;
|
|
56
46
|
let symbol;
|
|
57
47
|
if (null == attribute ? void 0 : attribute.visible) {
|
|
58
|
-
const startAngle = this._startAngle, endAngle = this._endAngle, {state: state} = this.attribute, start = points[0], end = points[points.length - 1], {refX: refX = 0, refY: refY = 0, refAngle: refAngle = 0, style: style, symbolType: symbolType, size: size = 12} = attribute;
|
|
48
|
+
const startAngle = this._startAngle, endAngle = this._endAngle, {points: points, state: state} = this.attribute, start = points[0], end = points[points.length - 1], {refX: refX = 0, refY: refY = 0, refAngle: refAngle = 0, style: style, symbolType: symbolType, size: size = 12} = attribute;
|
|
59
49
|
let position, rotate;
|
|
60
50
|
"start" === dim ? (position = {
|
|
61
|
-
x: start.x + (
|
|
62
|
-
y: start.y + (
|
|
51
|
+
x: start.x + (startAngle ? refX * Math.cos(startAngle) + refY * Math.cos(startAngle - Math.PI / 2) : 0),
|
|
52
|
+
y: start.y + (startAngle ? refX * Math.sin(startAngle) + refY * Math.sin(startAngle - Math.PI / 2) : 0)
|
|
63
53
|
}, rotate = startAngle + Math.PI / 2) : (position = {
|
|
64
|
-
x: end.x + (
|
|
65
|
-
y: end.y + (
|
|
54
|
+
x: end.x + (endAngle ? refX * Math.cos(endAngle) + refY * Math.cos(endAngle - Math.PI / 2) : 0),
|
|
55
|
+
y: end.y + (endAngle ? refX * Math.sin(endAngle) + refY * Math.sin(endAngle - Math.PI / 2) : 0)
|
|
66
56
|
}, rotate = endAngle + Math.PI / 2), symbol = createSymbol(Object.assign(Object.assign(Object.assign({}, position), {
|
|
67
57
|
symbolType: symbolType,
|
|
68
58
|
size: size,
|
|
69
59
|
angle: autoRotate ? rotate + refAngle : 0,
|
|
70
60
|
strokeBoundsBuffer: 0
|
|
71
|
-
}), style)), symbol.name = `${
|
|
61
|
+
}), style)), symbol.name = `${dim}-symbol`, symbol.id = this._getNodeId(`${dim}-symbol`),
|
|
72
62
|
isEmpty(null == state ? void 0 : state.symbol) || (symbol.states = state.symbol),
|
|
73
63
|
this.add(symbol);
|
|
74
64
|
}
|
|
75
65
|
return symbol;
|
|
76
66
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const {points: originPoints, multiSegment: multiSegment, mainSegmentIndex: mainSegmentIndex} = this.attribute;
|
|
80
|
-
let points;
|
|
81
|
-
return points = multiSegment ? isValidNumber(mainSegmentIndex) ? originPoints[mainSegmentIndex] : flattenArray(originPoints) : originPoints,
|
|
82
|
-
this._mainSegmentPoints = points, points;
|
|
83
|
-
}
|
|
84
|
-
_clipPoints(points) {
|
|
85
|
-
const {startSymbol: startSymbol, endSymbol: endSymbol} = this.attribute;
|
|
86
|
-
let pointsAfterClip = points;
|
|
87
|
-
if (null == startSymbol ? void 0 : startSymbol.visible) {
|
|
88
|
-
const startSize = (null == startSymbol ? void 0 : startSymbol.clip) ? (null == startSymbol ? void 0 : startSymbol.size) || 10 : 0;
|
|
89
|
-
pointsAfterClip = [ {
|
|
90
|
-
x: points[0].x - startSize / 2 * (Math.cos(this._startAngle) || 0),
|
|
91
|
-
y: points[0].y - startSize / 2 * (Math.sin(this._startAngle) || 0)
|
|
92
|
-
}, ...pointsAfterClip.slice(1) ];
|
|
93
|
-
}
|
|
94
|
-
if (null == endSymbol ? void 0 : endSymbol.visible) {
|
|
95
|
-
const endSize = (null == endSymbol ? void 0 : endSymbol.clip) ? (null == endSymbol ? void 0 : endSymbol.size) || 10 : 0, pointsEnd = {
|
|
96
|
-
x: points[points.length - 1].x - endSize / 2 * (Math.cos(this._endAngle) || 0),
|
|
97
|
-
y: points[points.length - 1].y - endSize / 2 * (Math.sin(this._endAngle) || 0)
|
|
98
|
-
};
|
|
99
|
-
pointsAfterClip = [ ...pointsAfterClip.slice(0, pointsAfterClip.length - 1), pointsEnd ];
|
|
100
|
-
}
|
|
101
|
-
return pointsAfterClip;
|
|
102
|
-
}
|
|
103
|
-
_computeLineAngle() {
|
|
104
|
-
const points = this._getMainSegmentPoints();
|
|
105
|
-
if (points.length <= 1) return;
|
|
106
|
-
const start = points[0], startInside = points[1], endInside = points[points.length - 2], end = points[points.length - 1], startVector = [ start.x - startInside.x, start.y - startInside.y ], startAngle = Math.atan2(startVector[1], startVector[0]), endVector = [ end.x - endInside.x, end.y - endInside.y ], endAngle = Math.atan2(endVector[1], endVector[0]);
|
|
107
|
-
this._startAngle = startAngle, this._endAngle = endAngle;
|
|
67
|
+
getStartAngle() {
|
|
68
|
+
return this._startAngle;
|
|
108
69
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
this._mainSegmentPoints = null;
|
|
70
|
+
getEndAngle() {
|
|
71
|
+
return this._endAngle;
|
|
112
72
|
}
|
|
113
73
|
}
|
|
114
74
|
|