@visactor/vrender-components 0.18.10-alpha.1 → 0.18.10-alpha.3
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 +2 -2
- package/cjs/label/base.d.ts +2 -2
- package/{es/marker/polar/area.d.ts → cjs/marker/arc-area.d.ts} +15 -9
- package/cjs/marker/arc-area.js +123 -0
- package/cjs/marker/arc-area.js.map +1 -0
- package/cjs/marker/arc-line.d.ts +23 -0
- package/cjs/marker/arc-line.js +103 -0
- package/cjs/marker/arc-line.js.map +1 -0
- package/cjs/marker/{cartesian/area.d.ts → area.d.ts} +13 -8
- package/cjs/marker/{cartesian/area.js → area.js} +16 -17
- package/cjs/marker/area.js.map +1 -0
- package/cjs/marker/base-line.d.ts +2 -2
- package/cjs/marker/base-line.js +4 -18
- package/cjs/marker/base-line.js.map +1 -1
- package/cjs/marker/config.d.ts +55 -12
- package/cjs/marker/config.js +54 -43
- package/cjs/marker/config.js.map +1 -1
- package/cjs/marker/index.d.ts +4 -4
- package/cjs/marker/index.js +3 -3
- package/cjs/marker/index.js.map +1 -1
- package/cjs/marker/line.d.ts +28 -0
- package/cjs/marker/line.js +153 -0
- package/cjs/marker/line.js.map +1 -0
- package/cjs/marker/point.d.ts +1 -1
- package/cjs/marker/register.d.ts +4 -5
- package/cjs/marker/register.js +8 -12
- package/cjs/marker/register.js.map +1 -1
- package/cjs/marker/type.d.ts +30 -38
- package/cjs/marker/type.js +21 -21
- package/cjs/marker/type.js.map +1 -1
- package/cjs/tag/tag.d.ts +5 -0
- package/cjs/tag/tag.js +11 -2
- package/cjs/tag/tag.js.map +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 +2 -2
- package/es/label/base.d.ts +2 -2
- package/{cjs/marker/polar/area.d.ts → es/marker/arc-area.d.ts} +15 -9
- package/es/marker/arc-area.js +133 -0
- package/es/marker/arc-area.js.map +1 -0
- package/es/marker/arc-line.d.ts +23 -0
- package/es/marker/arc-line.js +109 -0
- package/es/marker/arc-line.js.map +1 -0
- package/es/marker/{cartesian/area.d.ts → area.d.ts} +13 -8
- package/es/marker/{cartesian/area.js → area.js} +20 -21
- package/es/marker/area.js.map +1 -0
- package/es/marker/base-line.d.ts +2 -2
- package/es/marker/base-line.js +2 -20
- package/es/marker/base-line.js.map +1 -1
- package/es/marker/config.d.ts +55 -12
- package/es/marker/config.js +54 -43
- package/es/marker/config.js.map +1 -1
- package/es/marker/index.d.ts +4 -4
- package/es/marker/index.js +4 -4
- package/es/marker/index.js.map +1 -1
- package/es/marker/line.d.ts +28 -0
- package/es/marker/line.js +159 -0
- package/es/marker/line.js.map +1 -0
- package/es/marker/point.d.ts +1 -1
- package/es/marker/register.d.ts +4 -5
- package/es/marker/register.js +4 -8
- package/es/marker/register.js.map +1 -1
- package/es/marker/type.d.ts +30 -38
- package/es/marker/type.js +22 -22
- package/es/marker/type.js.map +1 -1
- package/es/tag/tag.d.ts +5 -0
- package/es/tag/tag.js +11 -2
- package/es/tag/tag.js.map +1 -1
- package/package.json +3 -3
- package/cjs/marker/cartesian/area.js.map +0 -1
- package/cjs/marker/cartesian/line.d.ts +0 -14
- package/cjs/marker/cartesian/line.js +0 -57
- package/cjs/marker/cartesian/line.js.map +0 -1
- package/cjs/marker/polar/arc-line.d.ts +0 -11
- package/cjs/marker/polar/arc-line.js +0 -50
- package/cjs/marker/polar/arc-line.js.map +0 -1
- package/cjs/marker/polar/area.js +0 -117
- package/cjs/marker/polar/area.js.map +0 -1
- package/cjs/marker/polar/line.d.ts +0 -1
- package/cjs/marker/polar/line.js +0 -3
- package/cjs/marker/polar/line.js.map +0 -1
- package/es/marker/cartesian/area.js.map +0 -1
- package/es/marker/cartesian/line.d.ts +0 -14
- package/es/marker/cartesian/line.js +0 -61
- package/es/marker/cartesian/line.js.map +0 -1
- package/es/marker/polar/arc-line.d.ts +0 -11
- package/es/marker/polar/arc-line.js +0 -54
- package/es/marker/polar/arc-line.js.map +0 -1
- package/es/marker/polar/area.js +0 -127
- package/es/marker/polar/area.js.map +0 -1
- package/es/marker/polar/line.d.ts +0 -1
- package/es/marker/polar/line.js +0 -3
- package/es/marker/polar/line.js.map +0 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { graphicCreator } from "@visactor/vrender-core";
|
|
2
|
+
|
|
3
|
+
import { merge } from "@visactor/vutils";
|
|
4
|
+
|
|
5
|
+
import { Tag } from "../tag";
|
|
6
|
+
|
|
7
|
+
import { Marker } from "./base";
|
|
8
|
+
|
|
9
|
+
import { DEFAULT_MARK_ARC_AREA_THEME } from "./config";
|
|
10
|
+
|
|
11
|
+
import { IMarkCommonArcLabelPosition } from "./type";
|
|
12
|
+
|
|
13
|
+
import { limitShapeInBounds } from "../util/limit-shape";
|
|
14
|
+
|
|
15
|
+
import { loadMarkArcAreaComponent } from "./register";
|
|
16
|
+
|
|
17
|
+
import { DEFAULT_STATES } from "../constant";
|
|
18
|
+
|
|
19
|
+
loadMarkArcAreaComponent();
|
|
20
|
+
|
|
21
|
+
export class MarkArcArea extends Marker {
|
|
22
|
+
getArea() {
|
|
23
|
+
return this._area;
|
|
24
|
+
}
|
|
25
|
+
getLabel() {
|
|
26
|
+
return this._label;
|
|
27
|
+
}
|
|
28
|
+
constructor(attributes, options) {
|
|
29
|
+
super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, MarkArcArea.defaultAttributes, attributes)),
|
|
30
|
+
this.name = "polarMarkArea";
|
|
31
|
+
}
|
|
32
|
+
getPositionByDirection(direction) {
|
|
33
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
34
|
+
const {center: center, innerRadius: innerRadius, outerRadius: outerRadius, startAngle: startAngle, endAngle: endAngle, label: label} = this.attribute, {refX: refX = 0, refY: refY = 0} = label, labelRectHeight = Math.abs((null !== (_b = null === (_a = this._label.getTextShape().AABBBounds) || void 0 === _a ? void 0 : _a.y2) && void 0 !== _b ? _b : 0) - (null !== (_d = null === (_c = this._label.getTextShape()) || void 0 === _c ? void 0 : _c.AABBBounds.y1) && void 0 !== _d ? _d : 0)), labelTextHeight = Math.abs((null !== (_f = null === (_e = this._label.getBgRect().AABBBounds) || void 0 === _e ? void 0 : _e.y2) && void 0 !== _f ? _f : 0) - (null !== (_h = null === (_g = this._label.getBgRect()) || void 0 === _g ? void 0 : _g.AABBBounds.y1) && void 0 !== _h ? _h : 0)), labelHeight = Math.max(labelRectHeight, labelTextHeight);
|
|
35
|
+
let radius, angle, orthogonalOffsetDirection;
|
|
36
|
+
switch (direction) {
|
|
37
|
+
case IMarkCommonArcLabelPosition.center:
|
|
38
|
+
radius = (innerRadius + outerRadius) / 2, angle = (startAngle + endAngle) / 2, orthogonalOffsetDirection = 0;
|
|
39
|
+
break;
|
|
40
|
+
|
|
41
|
+
case IMarkCommonArcLabelPosition.arcInnerStart:
|
|
42
|
+
radius = innerRadius, angle = startAngle, orthogonalOffsetDirection = -1;
|
|
43
|
+
break;
|
|
44
|
+
|
|
45
|
+
case IMarkCommonArcLabelPosition.arcOuterStart:
|
|
46
|
+
radius = outerRadius, angle = startAngle, orthogonalOffsetDirection = 1;
|
|
47
|
+
break;
|
|
48
|
+
|
|
49
|
+
case IMarkCommonArcLabelPosition.arcInnerEnd:
|
|
50
|
+
radius = innerRadius, angle = endAngle, orthogonalOffsetDirection = -1;
|
|
51
|
+
break;
|
|
52
|
+
|
|
53
|
+
case IMarkCommonArcLabelPosition.arcOuterEnd:
|
|
54
|
+
radius = outerRadius, angle = endAngle, orthogonalOffsetDirection = 1;
|
|
55
|
+
break;
|
|
56
|
+
|
|
57
|
+
case IMarkCommonArcLabelPosition.arcInnerMiddle:
|
|
58
|
+
radius = innerRadius, angle = (startAngle + endAngle) / 2, orthogonalOffsetDirection = -1;
|
|
59
|
+
break;
|
|
60
|
+
|
|
61
|
+
case IMarkCommonArcLabelPosition.arcOuterMiddle:
|
|
62
|
+
radius = outerRadius, angle = (startAngle + endAngle) / 2, orthogonalOffsetDirection = 1;
|
|
63
|
+
break;
|
|
64
|
+
|
|
65
|
+
default:
|
|
66
|
+
radius = innerRadius, angle = (startAngle + endAngle) / 2, orthogonalOffsetDirection = -1;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
position: {
|
|
70
|
+
x: center.x + (radius + orthogonalOffsetDirection * labelHeight / 2 + refY) * Math.cos(angle) + refX * Math.cos(angle - Math.PI / 2),
|
|
71
|
+
y: center.y + (radius + orthogonalOffsetDirection * labelHeight / 2 + refY) * Math.sin(angle) + refX * Math.sin(angle - Math.PI / 2)
|
|
72
|
+
},
|
|
73
|
+
angle: angle
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
setLabelPos() {
|
|
77
|
+
var _a;
|
|
78
|
+
if (this._label && this._area) {
|
|
79
|
+
const {label: label = {}} = this.attribute, {position: labelPosition = "arcInnerMiddle", autoRotate: autoRotate = !0} = label, labelAttr = this.getPositionByDirection(labelPosition);
|
|
80
|
+
if (this._label.setAttributes(Object.assign(Object.assign({}, labelAttr.position), {
|
|
81
|
+
angle: autoRotate ? labelAttr.angle - Math.PI / 2 + (null !== (_a = label.refAngle) && void 0 !== _a ? _a : 0) : 0
|
|
82
|
+
})), this.attribute.limitRect && label.confine) {
|
|
83
|
+
const {x: x, y: y, width: width, height: height} = this.attribute.limitRect;
|
|
84
|
+
limitShapeInBounds(this._label, {
|
|
85
|
+
x1: x,
|
|
86
|
+
y1: y,
|
|
87
|
+
x2: x + width,
|
|
88
|
+
y2: y + height
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
initMarker(container) {
|
|
94
|
+
const {center: center, innerRadius: innerRadius, outerRadius: outerRadius, startAngle: startAngle, endAngle: endAngle, areaStyle: areaStyle, label: label, state: state} = this.attribute, area = graphicCreator.arc(Object.assign({
|
|
95
|
+
x: center.x,
|
|
96
|
+
y: center.y,
|
|
97
|
+
innerRadius: innerRadius,
|
|
98
|
+
outerRadius: outerRadius,
|
|
99
|
+
startAngle: startAngle,
|
|
100
|
+
endAngle: endAngle
|
|
101
|
+
}, areaStyle));
|
|
102
|
+
area.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.area), area.name = "polar-mark-area-area",
|
|
103
|
+
this._area = area, container.add(area);
|
|
104
|
+
const markLabel = new Tag(Object.assign(Object.assign({}, label), {
|
|
105
|
+
state: {
|
|
106
|
+
panel: merge({}, DEFAULT_STATES, null == state ? void 0 : state.labelBackground),
|
|
107
|
+
text: merge({}, DEFAULT_STATES, null == state ? void 0 : state.label)
|
|
108
|
+
}
|
|
109
|
+
}));
|
|
110
|
+
markLabel.name = "mark-area-label", this._label = markLabel, container.add(markLabel),
|
|
111
|
+
this.setLabelPos();
|
|
112
|
+
}
|
|
113
|
+
updateMarker() {
|
|
114
|
+
const {center: center, innerRadius: innerRadius, outerRadius: outerRadius, startAngle: startAngle, endAngle: endAngle, areaStyle: areaStyle, label: label} = this.attribute;
|
|
115
|
+
this._area && this._area.setAttributes(Object.assign({
|
|
116
|
+
x: center.x,
|
|
117
|
+
y: center.y,
|
|
118
|
+
innerRadius: innerRadius,
|
|
119
|
+
outerRadius: outerRadius,
|
|
120
|
+
startAngle: startAngle,
|
|
121
|
+
endAngle: endAngle
|
|
122
|
+
}, areaStyle)), this._area && this._label.setAttributes(Object.assign({
|
|
123
|
+
dx: 0,
|
|
124
|
+
dy: 0
|
|
125
|
+
}, label)), this.setLabelPos();
|
|
126
|
+
}
|
|
127
|
+
isValidPoints() {
|
|
128
|
+
return !0;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
MarkArcArea.defaultAttributes = DEFAULT_MARK_ARC_AREA_THEME;
|
|
133
|
+
//# sourceMappingURL=arc-area.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/marker/arc-area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L,SAAS,EACZ,CAAC;SACJ;QACD,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,aAAa,iBACvB,EAAE,EAAE,CAAC,EACL,EAAE,EAAE,CAAC,IACD,KAAuB,EAC3B,CAAC;SACJ;QACD,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;IAES,aAAa;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;;AA1KM,6BAAiB,GAAG,2BAA2B,CAAC","file":"arc-area.js","sourcesContent":["import type { IArc, IGroup, INode } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { graphicCreator } from '@visactor/vrender-core';\nimport { merge } from '@visactor/vutils';\nimport type { TagAttributes } from '../tag';\n// eslint-disable-next-line no-duplicate-imports\nimport { Tag } from '../tag';\nimport { Marker } from './base';\nimport { DEFAULT_MARK_ARC_AREA_THEME } from './config';\nimport { IMarkCommonArcLabelPosition, type MarkArcAreaAttrs } from './type';\nimport { limitShapeInBounds } from '../util/limit-shape';\nimport type { ComponentOptions } from '../interface';\nimport { loadMarkArcAreaComponent } from './register';\nimport { DEFAULT_STATES } from '../constant';\n\nloadMarkArcAreaComponent();\nexport class MarkArcArea extends Marker<MarkArcAreaAttrs> {\n name = 'polarMarkArea';\n static defaultAttributes = DEFAULT_MARK_ARC_AREA_THEME;\n private _area!: IArc;\n\n getArea() {\n return this._area;\n }\n\n getLabel() {\n return this._label;\n }\n\n constructor(attributes: MarkArcAreaAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, MarkArcArea.defaultAttributes, attributes));\n }\n\n protected getPositionByDirection(direction: string) {\n const { center, innerRadius, outerRadius, startAngle, endAngle, label } = this.attribute as MarkArcAreaAttrs;\n const { refX = 0, refY = 0 } = label;\n // eslint-disable-next-line max-len\n const labelRectHeight = Math.abs(\n (this._label.getTextShape().AABBBounds?.y2 ?? 0) - (this._label.getTextShape()?.AABBBounds.y1 ?? 0)\n );\n // eslint-disable-next-line max-len\n const labelTextHeight = Math.abs(\n (this._label.getBgRect().AABBBounds?.y2 ?? 0) - (this._label.getBgRect()?.AABBBounds.y1 ?? 0)\n );\n const labelHeight = Math.max(labelRectHeight, labelTextHeight);\n\n let radius;\n let angle;\n // tag在正交方向是向内偏移,还是向外偏移\n // 不偏移: 0, 内: -1, 外: 1\n let orthogonalOffsetDirection;\n\n switch (direction) {\n case IMarkCommonArcLabelPosition.center:\n radius = (innerRadius + outerRadius) / 2;\n angle = (startAngle + endAngle) / 2;\n orthogonalOffsetDirection = 0;\n break;\n case IMarkCommonArcLabelPosition.arcInnerStart:\n radius = innerRadius;\n angle = startAngle;\n orthogonalOffsetDirection = -1;\n break;\n case IMarkCommonArcLabelPosition.arcOuterStart:\n radius = outerRadius;\n angle = startAngle;\n orthogonalOffsetDirection = 1;\n break;\n case IMarkCommonArcLabelPosition.arcInnerEnd:\n radius = innerRadius;\n angle = endAngle;\n orthogonalOffsetDirection = -1;\n break;\n case IMarkCommonArcLabelPosition.arcOuterEnd:\n radius = outerRadius;\n angle = endAngle;\n orthogonalOffsetDirection = 1;\n break;\n case IMarkCommonArcLabelPosition.arcInnerMiddle:\n radius = innerRadius;\n angle = (startAngle + endAngle) / 2;\n orthogonalOffsetDirection = -1;\n break;\n case IMarkCommonArcLabelPosition.arcOuterMiddle:\n radius = outerRadius;\n angle = (startAngle + endAngle) / 2;\n orthogonalOffsetDirection = 1;\n break;\n default: // default arcInnerMiddle\n radius = innerRadius;\n angle = (startAngle + endAngle) / 2;\n orthogonalOffsetDirection = -1;\n }\n\n return {\n position: {\n x:\n center.x +\n (radius + (orthogonalOffsetDirection * labelHeight) / 2 + refY) * Math.cos(angle) +\n refX * Math.cos(angle - Math.PI / 2),\n y:\n center.y +\n (radius + (orthogonalOffsetDirection * labelHeight) / 2 + refY) * Math.sin(angle) +\n refX * Math.sin(angle - Math.PI / 2)\n },\n angle\n };\n }\n\n protected setLabelPos() {\n if (this._label && this._area) {\n const { label = {} } = this.attribute as MarkArcAreaAttrs;\n const { position: labelPosition = 'arcInnerMiddle', autoRotate = true } = label;\n const labelAttr = this.getPositionByDirection(labelPosition);\n\n this._label.setAttributes({\n ...labelAttr.position,\n angle: autoRotate ? labelAttr.angle - Math.PI / 2 + (label.refAngle ?? 0) : 0\n });\n\n if (this.attribute.limitRect && label.confine) {\n const { x, y, width, height } = this.attribute.limitRect;\n limitShapeInBounds(this._label, {\n x1: x,\n y1: y,\n x2: x + width,\n y2: y + height\n });\n }\n }\n }\n\n protected initMarker(container: IGroup) {\n const { center, innerRadius, outerRadius, startAngle, endAngle, areaStyle, label, state } = this\n .attribute as MarkArcAreaAttrs;\n const area = graphicCreator.arc({\n x: center.x,\n y: center.y,\n innerRadius,\n outerRadius,\n startAngle,\n endAngle,\n ...areaStyle\n });\n area.states = merge({}, DEFAULT_STATES, state?.area);\n area.name = 'polar-mark-area-area';\n this._area = area;\n container.add(area);\n\n const markLabel = new Tag({\n ...(label as TagAttributes),\n state: {\n panel: merge({}, DEFAULT_STATES, state?.labelBackground),\n text: merge({}, DEFAULT_STATES, state?.label)\n }\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 { center, innerRadius, outerRadius, startAngle, endAngle, areaStyle, label } = this\n .attribute as MarkArcAreaAttrs;\n if (this._area) {\n this._area.setAttributes({\n x: center.x,\n y: center.y,\n innerRadius,\n outerRadius,\n startAngle,\n endAngle,\n ...areaStyle\n });\n }\n if (this._area) {\n this._label.setAttributes({\n dx: 0,\n dy: 0, // 需要进行复位\n ...(label as TagAttributes)\n });\n }\n this.setLabelPos();\n }\n\n protected isValidPoints() {\n return true;\n }\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ArcSegment } from '../segment';
|
|
2
|
+
import { BaseMarkLine } from './base-line';
|
|
3
|
+
import type { ComponentOptions } from '../interface';
|
|
4
|
+
import type { IArcGraphicAttribute } from '@visactor/vrender-core';
|
|
5
|
+
import { IMarkCommonArcLabelPosition } from './type';
|
|
6
|
+
import type { MarkArcLineAttrs } from './type';
|
|
7
|
+
export declare class MarkArcLine extends BaseMarkLine<IArcGraphicAttribute, IMarkCommonArcLabelPosition> {
|
|
8
|
+
name: string;
|
|
9
|
+
static defaultAttributes: Partial<MarkArcLineAttrs>;
|
|
10
|
+
protected _line: ArcSegment;
|
|
11
|
+
constructor(attributes: MarkArcLineAttrs, options?: ComponentOptions);
|
|
12
|
+
protected isValidPoints(): boolean;
|
|
13
|
+
protected getPositionByDirection(direction: IMarkCommonArcLabelPosition): {
|
|
14
|
+
position: {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
};
|
|
18
|
+
angle: number;
|
|
19
|
+
};
|
|
20
|
+
protected setLabelPos(): void;
|
|
21
|
+
protected createSegment(): ArcSegment;
|
|
22
|
+
protected setLineAttributes(): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { merge } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
import { ArcSegment } from "../segment";
|
|
4
|
+
|
|
5
|
+
import { loadMarkArcLineComponent } from "./register";
|
|
6
|
+
|
|
7
|
+
import { DEFAULT_STATES } from "../constant";
|
|
8
|
+
|
|
9
|
+
import { BaseMarkLine } from "./base-line";
|
|
10
|
+
|
|
11
|
+
import { IMarkCommonArcLabelPosition } from "./type";
|
|
12
|
+
|
|
13
|
+
import { DEFAULT_MARK_ARC_LINE_THEME } from "./config";
|
|
14
|
+
|
|
15
|
+
loadMarkArcLineComponent();
|
|
16
|
+
|
|
17
|
+
export class MarkArcLine extends BaseMarkLine {
|
|
18
|
+
constructor(attributes, options) {
|
|
19
|
+
super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, MarkArcLine.defaultAttributes, attributes)),
|
|
20
|
+
this.name = "polarMarkArcLine";
|
|
21
|
+
}
|
|
22
|
+
isValidPoints() {
|
|
23
|
+
return !0;
|
|
24
|
+
}
|
|
25
|
+
getPositionByDirection(direction) {
|
|
26
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
27
|
+
const {center: center, radius: radius, startAngle: startAngle, endAngle: endAngle, label: label} = this.attribute, {refX: refX = 0, refY: refY = 0} = label, labelRectHeight = Math.abs((null !== (_b = null === (_a = this._label.getTextShape().AABBBounds) || void 0 === _a ? void 0 : _a.y2) && void 0 !== _b ? _b : 0) - (null !== (_d = null === (_c = this._label.getTextShape()) || void 0 === _c ? void 0 : _c.AABBBounds.y1) && void 0 !== _d ? _d : 0)), labelTextHeight = Math.abs((null !== (_f = null === (_e = this._label.getBgRect().AABBBounds) || void 0 === _e ? void 0 : _e.y2) && void 0 !== _f ? _f : 0) - (null !== (_h = null === (_g = this._label.getBgRect()) || void 0 === _g ? void 0 : _g.AABBBounds.y1) && void 0 !== _h ? _h : 0)), labelHeight = Math.max(labelRectHeight, labelTextHeight);
|
|
28
|
+
let angle, orthogonalOffsetDirection;
|
|
29
|
+
switch (direction) {
|
|
30
|
+
case IMarkCommonArcLabelPosition.center:
|
|
31
|
+
angle = (startAngle + endAngle) / 2, orthogonalOffsetDirection = 0;
|
|
32
|
+
break;
|
|
33
|
+
|
|
34
|
+
case IMarkCommonArcLabelPosition.arcInnerStart:
|
|
35
|
+
angle = startAngle, orthogonalOffsetDirection = -1;
|
|
36
|
+
break;
|
|
37
|
+
|
|
38
|
+
case IMarkCommonArcLabelPosition.arcOuterStart:
|
|
39
|
+
angle = startAngle, orthogonalOffsetDirection = 1;
|
|
40
|
+
break;
|
|
41
|
+
|
|
42
|
+
case IMarkCommonArcLabelPosition.arcInnerEnd:
|
|
43
|
+
angle = endAngle, orthogonalOffsetDirection = -1;
|
|
44
|
+
break;
|
|
45
|
+
|
|
46
|
+
case IMarkCommonArcLabelPosition.arcOuterEnd:
|
|
47
|
+
angle = endAngle, orthogonalOffsetDirection = 1;
|
|
48
|
+
break;
|
|
49
|
+
|
|
50
|
+
case IMarkCommonArcLabelPosition.arcInnerMiddle:
|
|
51
|
+
angle = (startAngle + endAngle) / 2, orthogonalOffsetDirection = -1;
|
|
52
|
+
break;
|
|
53
|
+
|
|
54
|
+
case IMarkCommonArcLabelPosition.arcOuterMiddle:
|
|
55
|
+
angle = (startAngle + endAngle) / 2, orthogonalOffsetDirection = 1;
|
|
56
|
+
break;
|
|
57
|
+
|
|
58
|
+
default:
|
|
59
|
+
angle = (startAngle + endAngle) / 2, orthogonalOffsetDirection = -1;
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
position: {
|
|
63
|
+
x: center.x + (radius + orthogonalOffsetDirection * labelHeight / 2 + refY) * Math.cos(angle) + refX * Math.cos(angle - Math.PI / 2),
|
|
64
|
+
y: center.y + (radius + orthogonalOffsetDirection * labelHeight / 2 + refY) * Math.sin(angle) + refX * Math.sin(angle - Math.PI / 2)
|
|
65
|
+
},
|
|
66
|
+
angle: angle
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
setLabelPos() {
|
|
70
|
+
var _a;
|
|
71
|
+
super.setLabelPos();
|
|
72
|
+
const {label: label = {}} = this.attribute, {position: position = "arcInnerMiddle", autoRotate: autoRotate = !0} = label, labelAttr = this.getPositionByDirection(position);
|
|
73
|
+
this._label.setAttributes(Object.assign(Object.assign({}, labelAttr.position), {
|
|
74
|
+
angle: autoRotate ? labelAttr.angle - Math.PI / 2 + (null !== (_a = label.refAngle) && void 0 !== _a ? _a : 0) : 0
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
createSegment() {
|
|
78
|
+
const {center: center, radius: radius, startAngle: startAngle, endAngle: endAngle, startSymbol: startSymbol, endSymbol: endSymbol, lineStyle: lineStyle, state: state} = this.attribute;
|
|
79
|
+
return new ArcSegment({
|
|
80
|
+
center: center,
|
|
81
|
+
radius: radius,
|
|
82
|
+
startAngle: startAngle,
|
|
83
|
+
endAngle: endAngle,
|
|
84
|
+
startSymbol: startSymbol,
|
|
85
|
+
endSymbol: endSymbol,
|
|
86
|
+
lineStyle: lineStyle,
|
|
87
|
+
state: {
|
|
88
|
+
line: merge({}, DEFAULT_STATES, null == state ? void 0 : state.line),
|
|
89
|
+
startSymbol: merge({}, DEFAULT_STATES, null == state ? void 0 : state.lineStartSymbol),
|
|
90
|
+
endSymbol: merge({}, DEFAULT_STATES, null == state ? void 0 : state.lineEndSymbol)
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
setLineAttributes() {
|
|
95
|
+
const {center: center, radius: radius, startAngle: startAngle, endAngle: endAngle, startSymbol: startSymbol, endSymbol: endSymbol, lineStyle: lineStyle} = this.attribute;
|
|
96
|
+
this._line && this._line.setAttributes({
|
|
97
|
+
center: center,
|
|
98
|
+
radius: radius,
|
|
99
|
+
startAngle: startAngle,
|
|
100
|
+
endAngle: endAngle,
|
|
101
|
+
startSymbol: startSymbol,
|
|
102
|
+
endSymbol: endSymbol,
|
|
103
|
+
lineStyle: lineStyle
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
MarkArcLine.defaultAttributes = DEFAULT_MARK_ARC_LINE_THEME;
|
|
109
|
+
//# sourceMappingURL=arc-line.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/marker/arc-line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,QAAQ,CAAC;AAGrD,OAAO,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAEvD,wBAAwB,EAAE,CAAC;AAC3B,MAAM,OAAO,WAAY,S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,CAAC,EAAE,EAAE,cAAc,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,CAAC;gBAC5C,WAAW,EAAE,KAAK,CAAC,EAAE,EAAE,cAAc,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,eAAe,CAAC;gBAC9D,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE,cAAc,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,aAAa,CAAC;aAC3D;SACF,CAAC,CAAC;IACL,CAAC;IAES,iBAAiB;QACzB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,IAAI;aACrF,SAA6B,CAAC;QACjC,IAAI,IAAI,CAAC,KAAK,EAAE;YACb,IAAI,CAAC,KAAa,CAAC,aAAa,CAAC;gBAChC,MAAM;gBACN,MAAM;gBACN,UAAU;gBACV,QAAQ;gBACR,WAAW;gBACX,SAAS;gBACT,SAAS;aACV,CAAC,CAAC;SACJ;IACH,CAAC;;AA1HM,6BAAiB,GAA8B,2BAA0D,CAAC","file":"arc-line.js","sourcesContent":["import { merge } from '@visactor/vutils';\nimport { ArcSegment } from '../segment';\nimport { loadMarkArcLineComponent } from './register';\nimport { DEFAULT_STATES } from '../constant';\nimport { BaseMarkLine } from './base-line';\nimport type { ComponentOptions } from '../interface';\nimport type { IArcGraphicAttribute } from '@visactor/vrender-core';\nimport { IMarkCommonArcLabelPosition } from './type';\n// eslint-disable-next-line no-duplicate-imports\nimport type { MarkArcLineAttrs } from './type';\nimport { DEFAULT_MARK_ARC_LINE_THEME } from './config';\n\nloadMarkArcLineComponent();\nexport class MarkArcLine extends BaseMarkLine<IArcGraphicAttribute, IMarkCommonArcLabelPosition> {\n name = 'polarMarkArcLine';\n // eslint-disable-next-line max-len\n static defaultAttributes: Partial<MarkArcLineAttrs> = DEFAULT_MARK_ARC_LINE_THEME as unknown as MarkArcLineAttrs;\n protected _line!: ArcSegment;\n\n constructor(attributes: MarkArcLineAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, MarkArcLine.defaultAttributes, attributes));\n }\n\n protected isValidPoints() {\n return true;\n }\n\n protected getPositionByDirection(direction: IMarkCommonArcLabelPosition) {\n const { center, radius, startAngle, endAngle, label } = this.attribute as MarkArcLineAttrs;\n const { refX = 0, refY = 0 } = label;\n // eslint-disable-next-line max-len\n const labelRectHeight = Math.abs(\n (this._label.getTextShape().AABBBounds?.y2 ?? 0) - (this._label.getTextShape()?.AABBBounds.y1 ?? 0)\n );\n // eslint-disable-next-line max-len\n const labelTextHeight = Math.abs(\n (this._label.getBgRect().AABBBounds?.y2 ?? 0) - (this._label.getBgRect()?.AABBBounds.y1 ?? 0)\n );\n const labelHeight = Math.max(labelRectHeight, labelTextHeight);\n\n let angle;\n // tag在正交方向是向内偏移,还是向外偏移\n // 不偏移: 0, 内: -1, 外: 1\n let orthogonalOffsetDirection;\n\n switch (direction) {\n case IMarkCommonArcLabelPosition.center:\n angle = (startAngle + endAngle) / 2;\n orthogonalOffsetDirection = 0;\n break;\n case IMarkCommonArcLabelPosition.arcInnerStart:\n angle = startAngle;\n orthogonalOffsetDirection = -1;\n break;\n case IMarkCommonArcLabelPosition.arcOuterStart:\n angle = startAngle;\n orthogonalOffsetDirection = 1;\n break;\n case IMarkCommonArcLabelPosition.arcInnerEnd:\n angle = endAngle;\n orthogonalOffsetDirection = -1;\n break;\n case IMarkCommonArcLabelPosition.arcOuterEnd:\n angle = endAngle;\n orthogonalOffsetDirection = 1;\n break;\n case IMarkCommonArcLabelPosition.arcInnerMiddle:\n angle = (startAngle + endAngle) / 2;\n orthogonalOffsetDirection = -1;\n break;\n case IMarkCommonArcLabelPosition.arcOuterMiddle:\n angle = (startAngle + endAngle) / 2;\n orthogonalOffsetDirection = 1;\n break;\n default: // default arcInnerMiddle\n angle = (startAngle + endAngle) / 2;\n orthogonalOffsetDirection = -1;\n }\n\n return {\n position: {\n x:\n center.x +\n (radius + (orthogonalOffsetDirection * labelHeight) / 2 + refY) * Math.cos(angle) +\n refX * Math.cos(angle - Math.PI / 2),\n y:\n center.y +\n (radius + (orthogonalOffsetDirection * labelHeight) / 2 + refY) * Math.sin(angle) +\n refX * Math.sin(angle - Math.PI / 2)\n },\n angle\n };\n }\n\n protected setLabelPos(): void {\n super.setLabelPos();\n const { label = {} } = this.attribute as MarkArcLineAttrs;\n const { position = 'arcInnerMiddle', autoRotate = true } = label;\n const labelAttr = this.getPositionByDirection(position as any);\n this._label.setAttributes({\n ...labelAttr.position,\n angle: autoRotate ? labelAttr.angle - Math.PI / 2 + (label.refAngle ?? 0) : 0\n });\n }\n\n protected createSegment() {\n const { center, radius, startAngle, endAngle, startSymbol, endSymbol, lineStyle, state } = this\n .attribute as MarkArcLineAttrs;\n return new ArcSegment({\n center,\n radius,\n startAngle,\n endAngle,\n startSymbol,\n endSymbol,\n lineStyle,\n state: {\n line: merge({}, DEFAULT_STATES, state?.line),\n startSymbol: merge({}, DEFAULT_STATES, state?.lineStartSymbol),\n endSymbol: merge({}, DEFAULT_STATES, state?.lineEndSymbol)\n }\n });\n }\n\n protected setLineAttributes() {\n const { center, radius, startAngle, endAngle, startSymbol, endSymbol, lineStyle } = this\n .attribute as MarkArcLineAttrs;\n if (this._line) {\n (this._line as any).setAttributes({\n center,\n radius,\n startAngle,\n endAngle,\n startSymbol,\n endSymbol,\n lineStyle\n });\n }\n }\n}\n"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { IGroup, IPolygon } from '@visactor/vrender-core';
|
|
2
|
-
import { Tag } from '
|
|
3
|
-
import { Marker } from '
|
|
4
|
-
import type {
|
|
5
|
-
import type { ComponentOptions } from '
|
|
6
|
-
export declare class
|
|
2
|
+
import { Tag } from '../tag';
|
|
3
|
+
import { Marker } from './base';
|
|
4
|
+
import type { MarkAreaAttrs } from './type';
|
|
5
|
+
import type { ComponentOptions } from '../interface';
|
|
6
|
+
export declare class MarkArea extends Marker<MarkAreaAttrs> {
|
|
7
7
|
name: string;
|
|
8
8
|
static defaultAttributes: {
|
|
9
9
|
interactive: boolean;
|
|
10
10
|
label: {
|
|
11
|
-
position: import("
|
|
11
|
+
position: import("./type").IMarkAreaLabelPosition;
|
|
12
12
|
textStyle: {
|
|
13
13
|
fill: string;
|
|
14
14
|
stroke: string;
|
|
@@ -16,6 +16,8 @@ export declare class CartesianMarkArea extends Marker<CartesianMarkAreaAttrs> {
|
|
|
16
16
|
fontSize: number;
|
|
17
17
|
fontWeight: string;
|
|
18
18
|
fontStyle: string;
|
|
19
|
+
textAlign: string;
|
|
20
|
+
textBaseline: string;
|
|
19
21
|
};
|
|
20
22
|
padding: number[];
|
|
21
23
|
panel: {
|
|
@@ -33,8 +35,11 @@ export declare class CartesianMarkArea extends Marker<CartesianMarkAreaAttrs> {
|
|
|
33
35
|
private _area;
|
|
34
36
|
getArea(): IPolygon;
|
|
35
37
|
getLabel(): Tag;
|
|
36
|
-
constructor(attributes:
|
|
37
|
-
|
|
38
|
+
constructor(attributes: MarkAreaAttrs, options?: ComponentOptions);
|
|
39
|
+
protected getPositionByDirection(direction: string): {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
};
|
|
38
43
|
protected setLabelPos(): void;
|
|
39
44
|
protected initMarker(container: IGroup): void;
|
|
40
45
|
protected updateMarker(): void;
|
|
@@ -2,21 +2,21 @@ import { graphicCreator } from "@visactor/vrender-core";
|
|
|
2
2
|
|
|
3
3
|
import { isValidNumber, merge } from "@visactor/vutils";
|
|
4
4
|
|
|
5
|
-
import { Tag } from "
|
|
5
|
+
import { Tag } from "../tag";
|
|
6
6
|
|
|
7
|
-
import { Marker } from "
|
|
7
|
+
import { Marker } from "./base";
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { DEFAULT_MARK_AREA_THEME } from "./config";
|
|
10
10
|
|
|
11
|
-
import { limitShapeInBounds } from "
|
|
11
|
+
import { limitShapeInBounds } from "../util/limit-shape";
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { loadMarkAreaComponent } from "./register";
|
|
14
14
|
|
|
15
|
-
import { DEFAULT_STATES } from "
|
|
15
|
+
import { DEFAULT_STATES } from "../constant";
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
loadMarkAreaComponent();
|
|
18
18
|
|
|
19
|
-
export class
|
|
19
|
+
export class MarkArea extends Marker {
|
|
20
20
|
getArea() {
|
|
21
21
|
return this._area;
|
|
22
22
|
}
|
|
@@ -24,23 +24,24 @@ export class CartesianMarkArea extends Marker {
|
|
|
24
24
|
return this._label;
|
|
25
25
|
}
|
|
26
26
|
constructor(attributes, options) {
|
|
27
|
-
super((null == options ? void 0 : options.skipDefault) ? attributes : merge({},
|
|
28
|
-
this.name = "
|
|
27
|
+
super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, MarkArea.defaultAttributes, attributes)),
|
|
28
|
+
this.name = "markArea";
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
getPositionByDirection(direction) {
|
|
31
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
32
|
+
const {x1: x1, x2: x2, y1: y1, y2: y2} = this._area.AABBBounds, labelRectHeight = Math.abs((null !== (_b = null === (_a = this._label.getTextShape().AABBBounds) || void 0 === _a ? void 0 : _a.y2) && void 0 !== _b ? _b : 0) - (null !== (_d = null === (_c = this._label.getTextShape()) || void 0 === _c ? void 0 : _c.AABBBounds.y1) && void 0 !== _d ? _d : 0)), labelTextHeight = Math.abs((null !== (_f = null === (_e = this._label.getBgRect().AABBBounds) || void 0 === _e ? void 0 : _e.y2) && void 0 !== _f ? _f : 0) - (null !== (_h = null === (_g = this._label.getBgRect()) || void 0 === _g ? void 0 : _g.AABBBounds.y1) && void 0 !== _h ? _h : 0)), labelHeight = Math.max(labelRectHeight, labelTextHeight), labelRectWidth = Math.abs((null !== (_k = null === (_j = this._label.getTextShape().AABBBounds) || void 0 === _j ? void 0 : _j.x2) && void 0 !== _k ? _k : 0) - (null !== (_m = null === (_l = this._label.getTextShape()) || void 0 === _l ? void 0 : _l.AABBBounds.x1) && void 0 !== _m ? _m : 0)), labelTextWidth = Math.abs((null !== (_p = null === (_o = this._label.getBgRect().AABBBounds) || void 0 === _o ? void 0 : _o.x2) && void 0 !== _p ? _p : 0) - (null !== (_r = null === (_q = this._label.getBgRect()) || void 0 === _q ? void 0 : _q.AABBBounds.x1) && void 0 !== _r ? _r : 0)), labelWidth = Math.max(labelRectWidth, labelTextWidth);
|
|
32
33
|
return direction.includes("left") || direction.includes("Left") ? {
|
|
33
|
-
x: x1,
|
|
34
|
+
x: x1 + (direction.includes("inside") ? .5 : -.5) * labelWidth,
|
|
34
35
|
y: (y1 + y2) / 2
|
|
35
36
|
} : direction.includes("right") || direction.includes("Right") ? {
|
|
36
|
-
x: x2,
|
|
37
|
+
x: x2 + (direction.includes("inside") ? -.5 : .5) * labelWidth,
|
|
37
38
|
y: (y1 + y2) / 2
|
|
38
39
|
} : direction.includes("top") || direction.includes("Top") ? {
|
|
39
40
|
x: (x1 + x2) / 2,
|
|
40
|
-
y: y1
|
|
41
|
+
y: y1 + (direction.includes("inside") ? .5 : -.5) * labelHeight
|
|
41
42
|
} : direction.includes("bottom") || direction.includes("Bottom") ? {
|
|
42
43
|
x: (x1 + x2) / 2,
|
|
43
|
-
y: y2
|
|
44
|
+
y: y2 + (direction.includes("inside") ? -.5 : .5) * labelHeight
|
|
44
45
|
} : {
|
|
45
46
|
x: (x1 + x2) / 2,
|
|
46
47
|
y: (y1 + y2) / 2
|
|
@@ -49,10 +50,8 @@ export class CartesianMarkArea extends Marker {
|
|
|
49
50
|
setLabelPos() {
|
|
50
51
|
var _a;
|
|
51
52
|
if (this._label && this._area) {
|
|
52
|
-
const {label: label = {}} = this.attribute, labelPosition = null !== (_a = label.position) && void 0 !== _a ? _a : "middle", labelPoint = this.
|
|
53
|
-
if (this._label.setAttributes(Object.assign(
|
|
54
|
-
textStyle: Object.assign(Object.assign({}, DEFAULT_CARTESIAN_MARK_AREA_TEXT_STYLE_MAP[labelPosition]), label.textStyle)
|
|
55
|
-
})), this.attribute.limitRect && label.confine) {
|
|
53
|
+
const {label: label = {}} = this.attribute, labelPosition = null !== (_a = label.position) && void 0 !== _a ? _a : "middle", labelPoint = this.getPositionByDirection(labelPosition);
|
|
54
|
+
if (this._label.setAttributes(Object.assign({}, labelPoint)), this.attribute.limitRect && label.confine) {
|
|
56
55
|
const {x: x, y: y, width: width, height: height} = this.attribute.limitRect;
|
|
57
56
|
limitShapeInBounds(this._label, {
|
|
58
57
|
x1: x,
|
|
@@ -97,5 +96,5 @@ export class CartesianMarkArea extends Marker {
|
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
98
|
|
|
100
|
-
|
|
99
|
+
MarkArea.defaultAttributes = DEFAULT_MARK_AREA_THEME;
|
|
101
100
|
//# sourceMappingURL=area.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/marker/area.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGxD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,qBAAqB,EAAE,CAAC;AACxB,MAAM,OAAO,QAAS,SAAQ,MAAqB;IAIjD,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED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,IAAI,CAAC,SAA0B,CAAC;QACrE,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,IAAI,CAAC,KAAK,CAAC,aAAa,iBACtB,MAAM,EAAE,MAAM,IACX,SAAS,EACZ,CAAC;SACJ;QACD,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,aAAa,iBACvB,EAAE,EAAE,CAAC,EACL,EAAE,EAAE,CAAC,IACD,KAAuB,EAC3B,CAAC;SACJ;QACD,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;IAES,aAAa;QACrB,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,SAA0B,CAAC;QACnD,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YAChC,OAAO,KAAK,CAAC;SACd;QACD,IAAI,SAAS,GAAG,IAAI,CAAC;QACrB,MAAM,CAAC,OAAO,CAAC,CAAC,KAAY,EAAE,EAAE;YAC9B,IAAI,CAAC,aAAa,CAAE,KAAe,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAE,KAAe,CAAC,CAAC,CAAC,EAAE;gBAC5E,SAAS,GAAG,KAAK,CAAC;gBAClB,OAAO;aACR;QACH,CAAC,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;;AAjJM,0BAAiB,GAAG,uBAAuB,CAAC","file":"area.js","sourcesContent":["import type { IGroup, INode, IPolygon } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { graphicCreator } from '@visactor/vrender-core';\nimport { isValidNumber, merge } from '@visactor/vutils';\nimport type { TagAttributes } from '../tag';\n// eslint-disable-next-line no-duplicate-imports\nimport { Tag } from '../tag';\nimport { Marker } from './base';\nimport { DEFAULT_MARK_AREA_THEME } from './config';\nimport type { MarkAreaAttrs } from './type';\nimport { limitShapeInBounds } from '../util/limit-shape';\nimport type { ComponentOptions } from '../interface';\nimport { loadMarkAreaComponent } from './register';\nimport type { Point } from '../core/type';\nimport { DEFAULT_STATES } from '../constant';\n\nloadMarkAreaComponent();\nexport class MarkArea extends Marker<MarkAreaAttrs> {\n name = 'markArea';\n static defaultAttributes = DEFAULT_MARK_AREA_THEME;\n private _area!: IPolygon;\n getArea() {\n return this._area;\n }\n\n getLabel() {\n return this._label;\n }\n\n constructor(attributes: MarkAreaAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, MarkArea.defaultAttributes, attributes));\n }\n\n protected getPositionByDirection(direction: string) {\n const { x1, x2, y1, y2 } = this._area.AABBBounds;\n // labelHeight\n // eslint-disable-next-line max-len\n const labelRectHeight = Math.abs(\n (this._label.getTextShape().AABBBounds?.y2 ?? 0) - (this._label.getTextShape()?.AABBBounds.y1 ?? 0)\n );\n // eslint-disable-next-line max-len\n const labelTextHeight = Math.abs(\n (this._label.getBgRect().AABBBounds?.y2 ?? 0) - (this._label.getBgRect()?.AABBBounds.y1 ?? 0)\n );\n const labelHeight = Math.max(labelRectHeight, labelTextHeight);\n\n // labelWidth\n // eslint-disable-next-line max-len\n const labelRectWidth = Math.abs(\n (this._label.getTextShape().AABBBounds?.x2 ?? 0) - (this._label.getTextShape()?.AABBBounds.x1 ?? 0)\n );\n // eslint-disable-next-line max-len\n const labelTextWidth = Math.abs(\n (this._label.getBgRect().AABBBounds?.x2 ?? 0) - (this._label.getBgRect()?.AABBBounds.x1 ?? 0)\n );\n const labelWidth = Math.max(labelRectWidth, labelTextWidth);\n\n if (direction.includes('left') || direction.includes('Left')) {\n return {\n x: x1 + (direction.includes('inside') ? 0.5 : -0.5) * labelWidth,\n y: (y1 + y2) / 2\n };\n }\n if (direction.includes('right') || direction.includes('Right')) {\n return {\n x: x2 + (direction.includes('inside') ? -0.5 : 0.5) * labelWidth,\n y: (y1 + y2) / 2\n };\n }\n if (direction.includes('top') || direction.includes('Top')) {\n return {\n x: (x1 + x2) / 2,\n y: y1 + (direction.includes('inside') ? 0.5 : -0.5) * labelHeight\n };\n }\n if (direction.includes('bottom') || direction.includes('Bottom')) {\n return {\n x: (x1 + x2) / 2,\n y: y2 + (direction.includes('inside') ? -0.5 : 0.5) * labelHeight\n };\n }\n\n return {\n x: (x1 + x2) / 2,\n y: (y1 + y2) / 2\n };\n }\n\n protected setLabelPos() {\n if (this._label && this._area) {\n const { label = {} } = this.attribute as MarkAreaAttrs;\n const labelPosition = label.position ?? 'middle';\n const labelPoint = this.getPositionByDirection(labelPosition);\n this._label.setAttributes({\n ...labelPoint\n });\n\n if (this.attribute.limitRect && label.confine) {\n const { x, y, width, height } = this.attribute.limitRect;\n limitShapeInBounds(this._label, {\n x1: x,\n y1: y,\n x2: x + width,\n y2: y + height\n });\n }\n }\n }\n\n protected initMarker(container: IGroup) {\n const { points, label, areaStyle, state } = this.attribute as MarkAreaAttrs;\n const area = graphicCreator.polygon({\n points: points,\n ...areaStyle\n });\n area.states = merge({}, DEFAULT_STATES, state?.area);\n area.name = 'mark-polygon-polygon';\n this._area = area;\n container.add(area);\n\n const markLabel = new Tag({\n ...(label as TagAttributes),\n state: {\n panel: merge({}, DEFAULT_STATES, state?.labelBackground),\n text: merge({}, DEFAULT_STATES, state?.label)\n }\n });\n markLabel.name = 'mark-polygon-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 if (this._area) {\n this._area.setAttributes({\n points: points,\n ...areaStyle\n });\n }\n if (this._area) {\n this._label.setAttributes({\n dx: 0,\n dy: 0, // 需要进行复位\n ...(label as TagAttributes)\n });\n }\n this.setLabelPos();\n }\n\n protected isValidPoints() {\n const { points } = this.attribute as MarkAreaAttrs;\n if (!points || points.length < 3) {\n return false;\n }\n let validFlag = true;\n points.forEach((point: Point) => {\n if (!isValidNumber((point as Point).x) || !isValidNumber((point as Point).y)) {\n validFlag = false;\n return;\n }\n });\n return validFlag;\n }\n}\n"]}
|
package/es/marker/base-line.d.ts
CHANGED
|
@@ -3,12 +3,12 @@ import type { ArcSegment, Segment } from '../segment';
|
|
|
3
3
|
import { Tag } from '../tag';
|
|
4
4
|
import type { CommonMarkLineAttrs } from './type';
|
|
5
5
|
import { Marker } from './base';
|
|
6
|
-
export declare abstract class BaseMarkLine extends Marker<CommonMarkLineAttrs
|
|
6
|
+
export declare abstract class BaseMarkLine<LineAttr, LabelPosition> extends Marker<CommonMarkLineAttrs<LineAttr, LabelPosition>> {
|
|
7
7
|
name: string;
|
|
8
|
-
static defaultAttributes: Partial<CommonMarkLineAttrs>;
|
|
9
8
|
protected _line: Segment | ArcSegment;
|
|
10
9
|
protected abstract createSegment(): any;
|
|
11
10
|
protected abstract setLineAttributes(): any;
|
|
11
|
+
protected abstract getPositionByDirection(direction: any): any;
|
|
12
12
|
getLine(): Segment | ArcSegment;
|
|
13
13
|
getLabel(): Tag;
|
|
14
14
|
protected setLabelPos(): void;
|
package/es/marker/base-line.js
CHANGED
|
@@ -2,8 +2,6 @@ import { merge } from "@visactor/vutils";
|
|
|
2
2
|
|
|
3
3
|
import { Tag } from "../tag";
|
|
4
4
|
|
|
5
|
-
import { DEFAULT_COMMON_MARK_LINE_THEME, DEFAULT_COMMON_MARK_LINE_TEXT_STYLE_MAP } from "./config";
|
|
6
|
-
|
|
7
5
|
import { limitShapeInBounds } from "../util/limit-shape";
|
|
8
6
|
|
|
9
7
|
import { DEFAULT_STATES } from "../constant";
|
|
@@ -21,22 +19,8 @@ export class BaseMarkLine extends Marker {
|
|
|
21
19
|
return this._label;
|
|
22
20
|
}
|
|
23
21
|
setLabelPos() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
let labelPoint;
|
|
27
|
-
if (labelPoint = position.includes("start") || position.includes("Start") ? {
|
|
28
|
-
x: points[0].x + labelOffsetX,
|
|
29
|
-
y: points[0].y + labelOffsetY
|
|
30
|
-
} : position.includes("middle") || position.includes("Middle") ? {
|
|
31
|
-
x: (points[0].x + points[points.length - 1].x) / 2 + labelOffsetX,
|
|
32
|
-
y: (points[0].y + points[points.length - 1].y) / 2 + labelOffsetY
|
|
33
|
-
} : {
|
|
34
|
-
x: points[points.length - 1].x + labelOffsetX,
|
|
35
|
-
y: points[points.length - 1].y + labelOffsetY
|
|
36
|
-
}, this._label.setAttributes(Object.assign(Object.assign({}, labelPoint), {
|
|
37
|
-
angle: label.autoRotate ? labelAngle + (null !== (_b = label.refAngle) && void 0 !== _b ? _b : 0) : 0,
|
|
38
|
-
textStyle: Object.assign(Object.assign({}, DEFAULT_COMMON_MARK_LINE_TEXT_STYLE_MAP[position]), label.textStyle)
|
|
39
|
-
})), limitRect && confine) {
|
|
22
|
+
const {label: label = {}, limitRect: limitRect} = this.attribute, {position: position = "end", refX: refX = 0, refY: refY = 0, confine: confine} = label, labelPoint = this.getPositionByDirection(position);
|
|
23
|
+
if (this._label.setAttributes(Object.assign({}, labelPoint)), limitRect && confine) {
|
|
40
24
|
const {x: x, y: y, width: width, height: height} = limitRect;
|
|
41
25
|
limitShapeInBounds(this._label, {
|
|
42
26
|
x1: x,
|
|
@@ -66,6 +50,4 @@ export class BaseMarkLine extends Marker {
|
|
|
66
50
|
}, label)), this.setLabelPos();
|
|
67
51
|
}
|
|
68
52
|
}
|
|
69
|
-
|
|
70
|
-
BaseMarkLine.defaultAttributes = DEFAULT_COMMON_MARK_LINE_THEME;
|
|
71
53
|
//# sourceMappingURL=base-line.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/marker/base-line.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAIzC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/marker/base-line.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAIzC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qB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B,SAAS,CAAC,GAAG,CAAC,IAAwB,CAAC,CAAC;QAExC,MAAM,SAAS,GAAG,IAAI,GAAG,iCACnB,KAAuB,KAC3B,KAAK,EAAE;gBACL,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,cAAc,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,eAAe,CAAC;gBACxD,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,cAAc,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAC;aAC9C,IACD,CAAC;QACH,SAAS,CAAC,IAAI,GAAG,2BAA2B,CAAC;QAC7C,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,KAAK,EAAE,GAAG,IAAI,CAAC,SAAyD,CAAC;QAEjF,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAEzB,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,IAAI,CAAC,MAAM,CAAC,aAAa,iBACvB,EAAE,EAAE,CAAC,EACL,EAAE,EAAE,CAAC,IACD,KAAuB,EAC3B,CAAC;SACJ;QAED,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;CACF","file":"base-line.js","sourcesContent":["import type { IGroup, INode } from '@visactor/vrender-core';\nimport { merge } from '@visactor/vutils';\nimport type { ArcSegment, Segment } from '../segment';\nimport type { TagAttributes } from '../tag';\n// eslint-disable-next-line no-duplicate-imports\nimport { Tag } from '../tag';\nimport type { CommonMarkLineAttrs } from './type';\nimport { limitShapeInBounds } from '../util/limit-shape';\nimport { DEFAULT_STATES } from '../constant';\nimport { Marker } from './base';\n\nexport abstract class BaseMarkLine<LineAttr, LabelPosition> extends Marker<\n CommonMarkLineAttrs<LineAttr, LabelPosition>\n> {\n name = 'baseMarkLine';\n\n protected _line!: Segment | ArcSegment;\n\n protected abstract createSegment(): any;\n protected abstract setLineAttributes(): any;\n protected abstract getPositionByDirection(direction: any): any;\n\n getLine() {\n return this._line;\n }\n getLabel() {\n return this._label;\n }\n\n protected setLabelPos() {\n const { label = {}, limitRect } = this.attribute;\n const { position = 'end', refX = 0, refY = 0, confine } = label;\n const labelPoint = this.getPositionByDirection(position);\n this._label.setAttributes({\n ...labelPoint\n });\n if (limitRect && confine) {\n const { x, y, width, height } = limitRect;\n limitShapeInBounds(this._label, {\n x1: x,\n y1: y,\n x2: x + width,\n y2: y + height\n });\n }\n }\n\n protected initMarker(container: IGroup) {\n const { label, state } = this.attribute as CommonMarkLineAttrs<LineAttr, LabelPosition>;\n const line = this.createSegment();\n line.name = 'cartesian-mark-line-line';\n this._line = line;\n container.add(line as unknown as INode);\n\n const markLabel = new Tag({\n ...(label as TagAttributes),\n state: {\n panel: merge({}, DEFAULT_STATES, state?.labelBackground),\n text: merge({}, DEFAULT_STATES, state?.label)\n }\n });\n markLabel.name = 'cartesian-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 { label } = this.attribute as CommonMarkLineAttrs<LineAttr, LabelPosition>;\n\n this.setLineAttributes();\n\n if (this._label) {\n this._label.setAttributes({\n dx: 0,\n dy: 0, // 需要进行复位\n ...(label as TagAttributes)\n });\n }\n\n this.setLabelPos();\n }\n}\n"]}
|