@visactor/vrender-components 0.18.10-alpha.3 → 0.18.10-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/axis/base.js +4 -20
- package/cjs/axis/base.js.map +1 -1
- package/cjs/brush/brush.js +1 -2
- package/cjs/brush/type.js +2 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/marker/arc-area.d.ts +1 -1
- package/cjs/marker/arc-area.js +4 -4
- package/cjs/marker/arc-area.js.map +1 -1
- package/cjs/marker/arc-line.d.ts +5 -5
- package/cjs/marker/arc-line.js +11 -15
- package/cjs/marker/arc-line.js.map +1 -1
- package/cjs/marker/area.d.ts +3 -3
- package/cjs/marker/area.js +12 -12
- package/cjs/marker/area.js.map +1 -1
- package/cjs/marker/base.d.ts +1 -0
- package/cjs/marker/base.js +12 -26
- package/cjs/marker/base.js.map +1 -1
- package/cjs/marker/{base-line.d.ts → common-line.d.ts} +3 -2
- package/cjs/marker/{base-line.js → common-line.js} +11 -9
- package/cjs/marker/common-line.js.map +1 -0
- package/cjs/marker/line.d.ts +6 -6
- package/cjs/marker/line.js +23 -27
- package/cjs/marker/line.js.map +1 -1
- package/cjs/util/interaction.d.ts +4 -0
- package/cjs/util/interaction.js +37 -0
- package/cjs/util/interaction.js.map +1 -0
- package/es/axis/base.js +7 -21
- package/es/axis/base.js.map +1 -1
- package/es/brush/brush.js +1 -2
- package/es/brush/type.js +2 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/marker/arc-area.d.ts +1 -1
- package/es/marker/arc-area.js +4 -4
- package/es/marker/arc-area.js.map +1 -1
- package/es/marker/arc-line.d.ts +5 -5
- package/es/marker/arc-line.js +11 -15
- package/es/marker/arc-line.js.map +1 -1
- package/es/marker/area.d.ts +3 -3
- package/es/marker/area.js +12 -12
- package/es/marker/area.js.map +1 -1
- package/es/marker/base.d.ts +1 -0
- package/es/marker/base.js +12 -30
- package/es/marker/base.js.map +1 -1
- package/es/marker/{base-line.d.ts → common-line.d.ts} +3 -2
- package/es/marker/{base-line.js → common-line.js} +9 -7
- package/es/marker/common-line.js.map +1 -0
- package/es/marker/line.d.ts +6 -6
- package/es/marker/line.js +23 -27
- package/es/marker/line.js.map +1 -1
- package/es/util/interaction.d.ts +4 -0
- package/es/util/interaction.js +30 -0
- package/es/util/interaction.js.map +1 -0
- package/package.json +3 -3
- package/cjs/marker/base-line.js.map +0 -1
- package/es/marker/base-line.js.map +0 -1
package/cjs/marker/area.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/marker/area.ts"],"names":[],"mappings":";;;AAEA,yDAAwD;AACxD,6CAAwD;AAGxD,gCAA6B;AAC7B,iCAAgC;AAChC,qCAAmD;AAEnD,qDAAyD;AAEzD,yCAAmD;AAEnD,0CAA6C;AAE7C,IAAA,gCAAqB,GAAE,CAAC;AACxB,MAAa,QAAS,SAAQ,aAAqB;IAIjD,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,YAAY,UAAyB,EAAE,OAA0B;QAC/D,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,QAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAZ/F,SAAI,GAAG,UAAU,CAAC;IAalB,CAAC;IAES,sBAAsB,CAAC,SAAiB;;QAChD,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;QAGjD,MAAM,eAAe,GAAG,IAAI,CAAC,GAAG,CAC9B,CA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C,EAAE;YAChC,OAAO,KAAK,CAAC;SACd;QACD,IAAI,SAAS,GAAG,IAAI,CAAC;QACrB,MAAM,CAAC,OAAO,CAAC,CAAC,KAAY,EAAE,EAAE;YAC9B,IAAI,CAAC,IAAA,sBAAa,EAAE,KAAe,CAAC,CAAC,CAAC,IAAI,CAAC,IAAA,sBAAa,EAAE,KAAe,CAAC,CAAC,CAAC,EAAE;gBAC5E,SAAS,GAAG,KAAK,CAAC;gBAClB,OAAO;aACR;QACH,CAAC,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;;AAnJH,4BAoJC;AAlJQ,0BAAiB,GAAG,gCAAuB,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"]}
|
|
1
|
+
{"version":3,"sources":["../src/marker/area.ts"],"names":[],"mappings":";;;AAEA,yDAAwD;AACxD,6CAAwD;AAGxD,gCAA6B;AAC7B,iCAAgC;AAChC,qCAAmD;AAEnD,qDAAyD;AAEzD,yCAAmD;AAEnD,0CAA6C;AAE7C,IAAA,gCAAqB,GAAE,CAAC;AACxB,MAAa,QAAS,SAAQ,aAAqB;IAIjD,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,YAAY,UAAyB,EAAE,OAA0B;QAC/D,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,U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ACX,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,IAAA,sBAAa,EAAE,KAAe,CAAC,CAAC,CAAC,IAAI,CAAC,IAAA,sBAAa,EAAE,KAAe,CAAC,CAAC,CAAC,EAAE;gBAC5E,SAAS,GAAG,KAAK,CAAC;gBAClB,OAAO;aACR;QACH,CAAC,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;;AA/IH,4BAgJC;AA9IQ,0BAAiB,GAAG,gCAAuB,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 { IMarkAreaLabelPosition, 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 getPointAttrByPosition(position: IMarkAreaLabelPosition) {\n const { x1, x2, y1, y2 } = this._area.AABBBounds;\n // labelHeight\n const labelRectHeight = Math.abs(\n (this._label.getTextShape().AABBBounds?.y2 ?? 0) - (this._label.getTextShape()?.AABBBounds.y1 ?? 0)\n );\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 const labelRectWidth = Math.abs(\n (this._label.getTextShape().AABBBounds?.x2 ?? 0) - (this._label.getTextShape()?.AABBBounds.x1 ?? 0)\n );\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 (position.includes('left') || position.includes('Left')) {\n return {\n x: x1 + (position.includes('inside') ? 0.5 : -0.5) * labelWidth,\n y: (y1 + y2) / 2\n };\n }\n if (position.includes('right') || position.includes('Right')) {\n return {\n x: x2 + (position.includes('inside') ? -0.5 : 0.5) * labelWidth,\n y: (y1 + y2) / 2\n };\n }\n if (position.includes('top') || position.includes('Top')) {\n return {\n x: (x1 + x2) / 2,\n y: y1 + (position.includes('inside') ? 0.5 : -0.5) * labelHeight\n };\n }\n if (position.includes('bottom') || position.includes('Bottom')) {\n return {\n x: (x1 + x2) / 2,\n y: y2 + (position.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.getPointAttrByPosition(labelPosition as IMarkAreaLabelPosition);\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-area-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-area-label';\n this._label = markLabel;\n container.add(markLabel as unknown as INode);\n this.setLabelPos();\n }\n\n protected updateMarker() {\n const { points, label, areaStyle } = this.attribute as MarkAreaAttrs;\n 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/cjs/marker/base.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare abstract class Marker<T extends MarkerAttrs> extends AbstractComp
|
|
|
15
15
|
protected abstract isValidPoints(): any;
|
|
16
16
|
setAttribute(key: string, value: any, forceUpdateTag?: boolean | undefined): void;
|
|
17
17
|
private _bindEvent;
|
|
18
|
+
private _releaseEvent;
|
|
18
19
|
private _onHover;
|
|
19
20
|
private _onUnHover;
|
|
20
21
|
private _onClick;
|
package/cjs/marker/base.js
CHANGED
|
@@ -4,32 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.Marker = void 0;
|
|
6
6
|
|
|
7
|
-
const vrender_core_1 = require("@visactor/vrender-core"), base_1 = require("../core/base"),
|
|
7
|
+
const vrender_core_1 = require("@visactor/vrender-core"), base_1 = require("../core/base"), interaction_1 = require("../util/interaction");
|
|
8
8
|
|
|
9
9
|
class Marker extends base_1.AbstractComponent {
|
|
10
10
|
constructor() {
|
|
11
11
|
super(...arguments), this.name = "marker", this._onHover = e => {
|
|
12
|
-
|
|
13
|
-
target !== this._lastHover && target.name && !(0, vutils_1.isEmpty)(target.states) && (target.addState(constant_1.StateValue.hover, !0),
|
|
14
|
-
(0, util_1.traverseGroup)(this._container, (node => {
|
|
15
|
-
node !== target && node.name && !(0, vutils_1.isEmpty)(node.states) && node.addState(constant_1.StateValue.hoverReverse, !0);
|
|
16
|
-
})), this._lastHover = target);
|
|
12
|
+
this._lastHover = (0, interaction_1.dispatchHoverState)(e, this._container, this._lastHover);
|
|
17
13
|
}, this._onUnHover = e => {
|
|
18
|
-
this._lastHover
|
|
19
|
-
node.name && !(0, vutils_1.isEmpty)(node.states) && (node.removeState(constant_1.StateValue.hoverReverse),
|
|
20
|
-
node.removeState(constant_1.StateValue.hover));
|
|
21
|
-
})), this._lastHover = null);
|
|
14
|
+
this._lastHover = (0, interaction_1.dispatchUnHoverState)(e, this._container, this._lastHover);
|
|
22
15
|
}, this._onClick = e => {
|
|
23
|
-
|
|
24
|
-
if (this._lastSelect === target && target.hasState(constant_1.StateValue.selected)) return this._lastSelect = null,
|
|
25
|
-
void (0, util_1.traverseGroup)(this._container, (node => {
|
|
26
|
-
node.name && !(0, vutils_1.isEmpty)(node.states) && (node.removeState(constant_1.StateValue.selectedReverse),
|
|
27
|
-
node.removeState(constant_1.StateValue.selected));
|
|
28
|
-
}));
|
|
29
|
-
target.name && !(0, vutils_1.isEmpty)(target.states) && (target.addState(constant_1.StateValue.selected, !0),
|
|
30
|
-
(0, util_1.traverseGroup)(this._container, (node => {
|
|
31
|
-
node !== target && node.name && !(0, vutils_1.isEmpty)(node.states) && node.addState(constant_1.StateValue.selectedReverse, !0);
|
|
32
|
-
})), this._lastSelect = target);
|
|
16
|
+
this._lastSelect = (0, interaction_1.dispatchClickState)(e, this._container, this._lastSelect);
|
|
33
17
|
};
|
|
34
18
|
}
|
|
35
19
|
setAttribute(key, value, forceUpdateTag) {
|
|
@@ -43,6 +27,12 @@ class Marker extends base_1.AbstractComponent {
|
|
|
43
27
|
null === (_b = this._container) || void 0 === _b || _b.addEventListener("pointerout", this._onUnHover)),
|
|
44
28
|
select && (null === (_c = this._container) || void 0 === _c || _c.addEventListener("pointerdown", this._onClick));
|
|
45
29
|
}
|
|
30
|
+
_releaseEvent() {
|
|
31
|
+
var _a, _b, _c;
|
|
32
|
+
null === (_a = this._container) || void 0 === _a || _a.removeEventListener("pointermove", this._onHover),
|
|
33
|
+
null === (_b = this._container) || void 0 === _b || _b.removeEventListener("pointerout", this._onUnHover),
|
|
34
|
+
null === (_c = this._container) || void 0 === _c || _c.removeEventListener("pointerdown", this._onClick);
|
|
35
|
+
}
|
|
46
36
|
_initContainer() {
|
|
47
37
|
var _a, _b;
|
|
48
38
|
const {limitRect: limitRect = {}, clipInRange: clipInRange} = this.attribute;
|
|
@@ -80,14 +70,10 @@ class Marker extends base_1.AbstractComponent {
|
|
|
80
70
|
!1 === this.attribute.interactive && this.setAttribute("childrenPickable", !1),
|
|
81
71
|
markerVisible && this.isValidPoints() ? this._container ? (this._updateContainer(),
|
|
82
72
|
this.updateMarker()) : (this._initContainer(), this.initMarker(this._container)) : (this._container = null,
|
|
83
|
-
this.removeAllChild(!0)), this._bindEvent();
|
|
73
|
+
this.removeAllChild(!0)), this._releaseEvent(), this._bindEvent();
|
|
84
74
|
}
|
|
85
75
|
release() {
|
|
86
|
-
|
|
87
|
-
super.release(), null === (_a = this._container) || void 0 === _a || _a.removeEventListener("pointermove", this._onHover),
|
|
88
|
-
null === (_b = this._container) || void 0 === _b || _b.removeEventListener("pointerout", this._onUnHover),
|
|
89
|
-
null === (_c = this._container) || void 0 === _c || _c.removeEventListener("pointerdown", this._onClick),
|
|
90
|
-
this._container = null;
|
|
76
|
+
super.release(), this._releaseEvent(), this._container = null;
|
|
91
77
|
}
|
|
92
78
|
}
|
|
93
79
|
|
package/cjs/marker/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/marker/base.ts"],"names":[],"mappings":";;;AAEA,yDAAwD;AACxD,uCAAiD;AAGjD,0CAAyC;AACzC,kCAAwC;AACxC,6CAA2C;AAE3C,MAAsB,MAA8B,SAAQ,wBAA8B;IAA1F;;QACE,SAAI,GAAG,QAAQ,CAAC;QAoCR,aAAQ,GAAG,CAAC,CAAwB,EAAE,EAAE;YAC9C,MAAM,MAAM,GAAG,CAAC,CAAC,MAA6B,CAAC;YAC/C,IAAI,MAAM,KAAK,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,IAAI,CAAC,IAAA,gBAAO,EAAC,MAAM,CAAC,MAAM,CAAC,EAAE;gBACxE,MAAM,CAAC,QAAQ,CAAC,qBAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;gBACxC,IAAA,oBAAa,EAAC,IAAI,CAAC,UAAU,EAAE,CAAC,IAAc,EAAE,EAAE;oBAChD,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,IAAA,gBAAO,EAAC,IAAI,CAAC,MAAM,CAAC,EAAE;wBACzD,IAAI,CAAC,QAAQ,CAAC,qBAAU,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;qBAC9C;gBACH,CAAC,CAAC,CAAC;gBAC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U,GAAG,IAAI,CAAC;IACzB,CAAC;CACF;AAnKD,wBAmKC","file":"base.js","sourcesContent":["import type { FederatedPointerEvent, IGraphic, IGroup } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { graphicCreator } from '@visactor/vrender-core';\nimport { AbstractComponent } from '../core/base';\nimport type { Tag } from '../tag';\nimport type { MarkerAttrs } from './type';\nimport { StateValue } from '../constant';\nimport { traverseGroup } from '../util';\nimport { isEmpty } from '@visactor/vutils';\n\nexport abstract class Marker<T extends MarkerAttrs> extends AbstractComponent<Required<T>> {\n name = 'marker';\n private _containerClip!: IGroup;\n private _container!: IGroup;\n\n protected _label!: Tag;\n private _lastHover: IGraphic;\n private _lastSelect: IGraphic;\n\n protected abstract setLabelPos(): any;\n protected abstract initMarker(container: IGroup): any;\n protected abstract updateMarker(): any;\n protected abstract isValidPoints(): any;\n\n setAttribute(key: string, value: any, forceUpdateTag?: boolean | undefined): void {\n super.setAttribute(key, value, forceUpdateTag);\n if (key === 'visible') {\n this.render();\n }\n }\n\n private _bindEvent() {\n if (!this.attribute.interactive) {\n return;\n }\n const { hover, select } = this.attribute;\n\n if (hover) {\n this._container?.addEventListener('pointermove', this._onHover as EventListenerOrEventListenerObject);\n this._container?.addEventListener('pointerout', this._onUnHover as EventListenerOrEventListenerObject);\n }\n\n if (select) {\n this._container?.addEventListener('pointerdown', this._onClick as EventListenerOrEventListenerObject);\n }\n }\n\n private _onHover = (e: FederatedPointerEvent) => {\n const target = e.target as unknown as IGraphic;\n if (target !== this._lastHover && target.name && !isEmpty(target.states)) {\n target.addState(StateValue.hover, true);\n traverseGroup(this._container, (node: IGraphic) => {\n if (node !== target && node.name && !isEmpty(node.states)) {\n node.addState(StateValue.hoverReverse, true);\n }\n });\n this._lastHover = target;\n }\n };\n\n private _onUnHover = (e: FederatedPointerEvent) => {\n if (this._lastHover) {\n traverseGroup(this._container, (node: IGraphic) => {\n if (node.name && !isEmpty(node.states)) {\n node.removeState(StateValue.hoverReverse);\n node.removeState(StateValue.hover);\n }\n });\n this._lastHover = null;\n }\n };\n\n private _onClick = (e: FederatedPointerEvent) => {\n const target = e.target as unknown as IGraphic;\n if (this._lastSelect === target && target.hasState(StateValue.selected)) {\n // 取消选中\n this._lastSelect = null;\n traverseGroup(this._container, (node: IGraphic) => {\n if (node.name && !isEmpty(node.states)) {\n node.removeState(StateValue.selectedReverse);\n node.removeState(StateValue.selected);\n }\n });\n return;\n }\n\n if (target.name && !isEmpty(target.states)) {\n target.addState(StateValue.selected, true);\n traverseGroup(this._container, (node: IGraphic) => {\n if (node !== target && node.name && !isEmpty(node.states)) {\n node.addState(StateValue.selectedReverse, true);\n }\n });\n this._lastSelect = target;\n }\n };\n\n private _initContainer() {\n const { limitRect = {} as T['limitRect'], clipInRange } = this.attribute;\n let group;\n if (clipInRange) {\n // 如果用户配置了剪切\n const groupClip = graphicCreator.group({\n ...limitRect,\n clip: true,\n pickable: false\n });\n group = graphicCreator.group({\n x: -(limitRect.x ?? 0),\n y: -(limitRect.y ?? 0),\n pickable: false\n });\n groupClip.add(group);\n this._containerClip = groupClip;\n this.add(groupClip);\n } else {\n group = graphicCreator.group({\n x: 0,\n y: 0,\n pickable: false\n });\n this.add(group);\n }\n group.name = 'marker-container';\n this._container = group;\n }\n\n private _updateContainer() {\n const { limitRect = {} as T['limitRect'], clipInRange } = this.attribute;\n if (this._containerClip) {\n this._containerClip.setAttributes({\n ...limitRect\n });\n }\n\n this._container.setAttributes({\n x: clipInRange ? -(limitRect.x ?? 0) : 0,\n y: clipInRange ? -(limitRect.y ?? 0) : 0\n });\n }\n\n protected render() {\n // 因为标注本身不规则,所以默认将组件的 group 设置为不可拾取\n this.setAttribute('pickable', false);\n\n const markerVisible = this.attribute.visible ?? true;\n if (this.attribute.interactive === false) {\n this.setAttribute('childrenPickable', false);\n }\n\n if (markerVisible && this.isValidPoints()) {\n if (!this._container) {\n this._initContainer();\n this.initMarker(this._container);\n } else {\n this._updateContainer();\n this.updateMarker();\n }\n } else {\n this._container = null;\n this.removeAllChild(true);\n }\n\n this._bindEvent();\n }\n\n release(): void {\n super.release();\n this._container?.removeEventListener('pointermove', this._onHover as EventListenerOrEventListenerObject);\n this._container?.removeEventListener('pointerout', this._onUnHover as EventListenerOrEventListenerObject);\n this._container?.removeEventListener('pointerdown', this._onClick as EventListenerOrEventListenerObject);\n this._container = null;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/marker/base.ts"],"names":[],"mappings":";;;AAEA,yDAAwD;AACxD,uCAAiD;AAMjD,qDAAmG;AAEnG,MAAsB,MAA8B,SAAQ,wBAA8B;IAA1F;;QACE,SAAI,GAAG,QAAQ,CAAC;QA0CR,aAAQ,GAAG,CAAC,CAAwB,EAAE,EAAE;YAC9C,IAAI,CAAC,UAAU,GAAG,IAAA,gCAAkB,EAAC,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5E,CAAC,CAAC;QAEM,eAAU,GAAG,CAAC,CAAwB,EAAE,EAAE;YAChD,IAAI,CAAC,UAAU,GAAG,IAAA,kCAAoB,EAAC,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC9E,CAAC,CAAC;QAEM,aAAQ,GAAG,CAAC,CAAwB,EAAE,EAAE;YAC9C,IAAI,CAAC,WAAW,GAAG,IAAA,gCAAkB,EAAC,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAC9E,CAAC,CAAC;IA8EJ,CAAC;IArHC,YAAY,CAAC,GAAW,EAAE,KAAU,EAAE,cAAoC;QACxE,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;QAC/C,IAAI,GAAG,KAAK,SAAS,EAAE;YACrB,IAAI,CAAC,MAAM,EAAE,CAAC;SACf;IACH,CAAC;IAEO,UAAU;;QAChB,IAAI,CAAC,IAAI,CAAC,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C,YAAY,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;SAC9C;QAED,IAAI,aAAa,IAAI,IAAI,CAAC,aAAa,EAAE,EAAE;YACzC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;gBACpB,IAAI,CAAC,cAAc,EAAE,CAAC;gBACtB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;aAClC;iBAAM;gBACL,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBACxB,IAAI,CAAC,YAAY,EAAE,CAAC;aACrB;SACF;aAAM;YACL,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;SAC3B;QAGD,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAED,OAAO;QACL,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,CAAC;CACF;AAnID,wBAmIC","file":"base.js","sourcesContent":["import type { FederatedPointerEvent, IGraphic, IGroup } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { graphicCreator } from '@visactor/vrender-core';\nimport { AbstractComponent } from '../core/base';\nimport type { Tag } from '../tag';\nimport type { MarkerAttrs } from './type';\nimport { StateValue } from '../constant';\nimport { traverseGroup } from '../util';\nimport { isEmpty } from '@visactor/vutils';\nimport { dispatchClickState, dispatchHoverState, dispatchUnHoverState } from '../util/interaction';\n\nexport abstract class Marker<T extends MarkerAttrs> extends AbstractComponent<Required<T>> {\n name = 'marker';\n private _containerClip!: IGroup;\n private _container!: IGroup;\n\n protected _label!: Tag;\n private _lastHover: IGraphic;\n private _lastSelect: IGraphic;\n\n protected abstract setLabelPos(): any;\n protected abstract initMarker(container: IGroup): any;\n protected abstract updateMarker(): any;\n protected abstract isValidPoints(): any;\n\n setAttribute(key: string, value: any, forceUpdateTag?: boolean | undefined): void {\n super.setAttribute(key, value, forceUpdateTag);\n if (key === 'visible') {\n this.render();\n }\n }\n\n private _bindEvent() {\n if (!this.attribute.interactive) {\n return;\n }\n const { hover, select } = this.attribute;\n\n if (hover) {\n this._container?.addEventListener('pointermove', this._onHover as EventListenerOrEventListenerObject);\n this._container?.addEventListener('pointerout', this._onUnHover as EventListenerOrEventListenerObject);\n }\n\n if (select) {\n this._container?.addEventListener('pointerdown', this._onClick as EventListenerOrEventListenerObject);\n }\n }\n\n private _releaseEvent() {\n this._container?.removeEventListener('pointermove', this._onHover as EventListenerOrEventListenerObject);\n this._container?.removeEventListener('pointerout', this._onUnHover as EventListenerOrEventListenerObject);\n this._container?.removeEventListener('pointerdown', this._onClick as EventListenerOrEventListenerObject);\n }\n\n private _onHover = (e: FederatedPointerEvent) => {\n this._lastHover = dispatchHoverState(e, this._container, this._lastHover);\n };\n\n private _onUnHover = (e: FederatedPointerEvent) => {\n this._lastHover = dispatchUnHoverState(e, this._container, this._lastHover);\n };\n\n private _onClick = (e: FederatedPointerEvent) => {\n this._lastSelect = dispatchClickState(e, this._container, this._lastSelect);\n };\n\n private _initContainer() {\n const { limitRect = {} as T['limitRect'], clipInRange } = this.attribute;\n let group;\n if (clipInRange) {\n // 如果用户配置了剪切\n const groupClip = graphicCreator.group({\n ...limitRect,\n clip: true,\n pickable: false\n });\n group = graphicCreator.group({\n x: -(limitRect.x ?? 0),\n y: -(limitRect.y ?? 0),\n pickable: false\n });\n groupClip.add(group);\n this._containerClip = groupClip;\n this.add(groupClip);\n } else {\n group = graphicCreator.group({\n x: 0,\n y: 0,\n pickable: false\n });\n this.add(group);\n }\n group.name = 'marker-container';\n this._container = group;\n }\n\n private _updateContainer() {\n const { limitRect = {} as T['limitRect'], clipInRange } = this.attribute;\n if (this._containerClip) {\n this._containerClip.setAttributes({\n ...limitRect\n });\n }\n\n this._container.setAttributes({\n x: clipInRange ? -(limitRect.x ?? 0) : 0,\n y: clipInRange ? -(limitRect.y ?? 0) : 0\n });\n }\n\n protected render() {\n // 因为标注本身不规则,所以默认将组件的 group 设置为不可拾取\n this.setAttribute('pickable', false);\n\n const markerVisible = this.attribute.visible ?? true;\n if (this.attribute.interactive === false) {\n this.setAttribute('childrenPickable', false);\n }\n\n if (markerVisible && this.isValidPoints()) {\n if (!this._container) {\n this._initContainer();\n this.initMarker(this._container);\n } else {\n this._updateContainer();\n this.updateMarker();\n }\n } else {\n this._container = null;\n this.removeAllChild(true);\n }\n\n // 先把之前的event都release掉,否则会重复触发\n this._releaseEvent();\n this._bindEvent();\n }\n\n release(): void {\n super.release();\n this._releaseEvent();\n this._container = null;\n }\n}\n"]}
|
|
@@ -3,12 +3,13 @@ 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
|
|
6
|
+
export declare abstract class MarkCommonLine<LineAttr, LabelPosition> extends Marker<CommonMarkLineAttrs<LineAttr, LabelPosition>> {
|
|
7
7
|
name: string;
|
|
8
8
|
protected _line: Segment | ArcSegment;
|
|
9
9
|
protected abstract createSegment(): any;
|
|
10
10
|
protected abstract setLineAttributes(): any;
|
|
11
|
-
protected abstract
|
|
11
|
+
protected abstract getPointAttrByPosition(position: any): any;
|
|
12
|
+
protected abstract getRotateByAngle(angle: number): number;
|
|
12
13
|
getLine(): Segment | ArcSegment;
|
|
13
14
|
getLabel(): Tag;
|
|
14
15
|
protected setLabelPos(): void;
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: !0
|
|
5
|
-
}), exports.
|
|
5
|
+
}), exports.MarkCommonLine = void 0;
|
|
6
6
|
|
|
7
7
|
const vutils_1 = require("@visactor/vutils"), tag_1 = require("../tag"), limit_shape_1 = require("../util/limit-shape"), constant_1 = require("../constant"), base_1 = require("./base");
|
|
8
8
|
|
|
9
|
-
class
|
|
9
|
+
class MarkCommonLine extends base_1.Marker {
|
|
10
10
|
constructor() {
|
|
11
|
-
super(...arguments), this.name = "
|
|
11
|
+
super(...arguments), this.name = "markCommonLine";
|
|
12
12
|
}
|
|
13
13
|
getLine() {
|
|
14
14
|
return this._line;
|
|
@@ -17,8 +17,10 @@ class BaseMarkLine extends base_1.Marker {
|
|
|
17
17
|
return this._label;
|
|
18
18
|
}
|
|
19
19
|
setLabelPos() {
|
|
20
|
-
const {label: label = {}, limitRect: limitRect} = this.attribute, {position: position
|
|
21
|
-
if (this._label.setAttributes(Object.assign({}, labelPoint)
|
|
20
|
+
const {label: label = {}, limitRect: limitRect} = this.attribute, {position: position, confine: confine, autoRotate: autoRotate = !0} = label, labelPoint = this.getPointAttrByPosition(position);
|
|
21
|
+
if (this._label.setAttributes(Object.assign(Object.assign({}, labelPoint.position), {
|
|
22
|
+
angle: autoRotate ? this.getRotateByAngle(labelPoint.angle) : 0
|
|
23
|
+
})), limitRect && confine) {
|
|
22
24
|
const {x: x, y: y, width: width, height: height} = limitRect;
|
|
23
25
|
(0, limit_shape_1.limitShapeInBounds)(this._label, {
|
|
24
26
|
x1: x,
|
|
@@ -30,14 +32,14 @@ class BaseMarkLine extends base_1.Marker {
|
|
|
30
32
|
}
|
|
31
33
|
initMarker(container) {
|
|
32
34
|
const {label: label, state: state} = this.attribute, line = this.createSegment();
|
|
33
|
-
line.name = "
|
|
35
|
+
line.name = "mark-common-line-line", this._line = line, container.add(line);
|
|
34
36
|
const markLabel = new tag_1.Tag(Object.assign(Object.assign({}, label), {
|
|
35
37
|
state: {
|
|
36
38
|
panel: (0, vutils_1.merge)({}, constant_1.DEFAULT_STATES, null == state ? void 0 : state.labelBackground),
|
|
37
39
|
text: (0, vutils_1.merge)({}, constant_1.DEFAULT_STATES, null == state ? void 0 : state.label)
|
|
38
40
|
}
|
|
39
41
|
}));
|
|
40
|
-
markLabel.name = "
|
|
42
|
+
markLabel.name = "mark-common-line-label", this._label = markLabel, container.add(markLabel),
|
|
41
43
|
this.setLabelPos();
|
|
42
44
|
}
|
|
43
45
|
updateMarker() {
|
|
@@ -49,5 +51,5 @@ class BaseMarkLine extends base_1.Marker {
|
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
exports.
|
|
53
|
-
//# sourceMappingURL=
|
|
54
|
+
exports.MarkCommonLine = MarkCommonLine;
|
|
55
|
+
//# sourceMappingURL=common-line.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/marker/common-line.ts"],"names":[],"mappings":";;;AACA,6CAAyC;AAIzC,gCAA6B;AAE7B,qDAAyD;AACzD,0CAA6C;AAC7C,iCAAgC;AAEhC,MAAsB,cAAwC,SAAQ,aAErE;IAFD;;QAGE,SAAI,GAAG,gBAAgB,CAAC;IAsE1B,CAAC;IA7DC,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IACD,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAES,WAAW;QACnB,MAAM,EAAE,KAAK,GAAG,EAAE,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;QACjD,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;QACvD,MAAM,UAAU,GAAG,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC;QACzD,IAAI,CAAC,MAAM,CAAC,aAAa,iCACpB,UAAU,CAAC,QAAQ,KACtB,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAC/D,CAAC;QACH,IAAI,SAAS,IAAI,OAAO,EAAE;YACxB,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GA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,CAAC,IACD,KAAuB,EAC3B,CAAC;SACJ;QAED,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;CACF;AAzED,wCAyEC","file":"common-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 MarkCommonLine<LineAttr, LabelPosition> extends Marker<\n CommonMarkLineAttrs<LineAttr, LabelPosition>\n> {\n name = 'markCommonLine';\n\n protected _line!: Segment | ArcSegment;\n\n protected abstract createSegment(): any;\n protected abstract setLineAttributes(): any;\n protected abstract getPointAttrByPosition(position: any): any;\n protected abstract getRotateByAngle(angle: number): number;\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, confine, autoRotate = true } = label;\n const labelPoint = this.getPointAttrByPosition(position);\n this._label.setAttributes({\n ...labelPoint.position,\n angle: autoRotate ? this.getRotateByAngle(labelPoint.angle) : 0\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 = 'mark-common-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 = 'mark-common-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"]}
|
package/cjs/marker/line.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { IMarkLineLabelPosition } from './type';
|
|
2
2
|
import type { MarkLineAttrs } from './type';
|
|
3
3
|
import type { ComponentOptions } from '../interface';
|
|
4
|
-
import {
|
|
4
|
+
import { MarkCommonLine } from './common-line';
|
|
5
5
|
import type { ArcSegment } from '../segment';
|
|
6
6
|
import { Segment } from '../segment';
|
|
7
7
|
import type { ILineGraphicAttribute } from '@visactor/vrender-core';
|
|
8
|
-
export declare class MarkLine extends
|
|
8
|
+
export declare class MarkLine extends MarkCommonLine<ILineGraphicAttribute, IMarkLineLabelPosition> {
|
|
9
9
|
name: string;
|
|
10
10
|
static defaultAttributes: Partial<MarkLineAttrs>;
|
|
11
11
|
protected _line: Segment | ArcSegment;
|
|
12
12
|
constructor(attributes: MarkLineAttrs, options?: ComponentOptions);
|
|
13
|
-
protected
|
|
14
|
-
protected getLabelOffsetByDirection(direction: IMarkLineLabelPosition): {
|
|
13
|
+
protected getLabelOffsetByPosition(position: IMarkLineLabelPosition): {
|
|
15
14
|
offsetX: number;
|
|
16
15
|
offsetY: number;
|
|
17
16
|
};
|
|
18
|
-
protected
|
|
17
|
+
protected getPointAttrByPosition(position: IMarkLineLabelPosition): {
|
|
19
18
|
position: {
|
|
20
19
|
x: number;
|
|
21
20
|
y: number;
|
|
22
21
|
};
|
|
23
22
|
angle: number;
|
|
24
23
|
};
|
|
25
|
-
protected
|
|
24
|
+
protected getRotateByAngle(angle: number): number;
|
|
26
25
|
protected createSegment(): Segment;
|
|
27
26
|
protected setLineAttributes(): void;
|
|
27
|
+
protected isValidPoints(): boolean;
|
|
28
28
|
}
|
package/cjs/marker/line.js
CHANGED
|
@@ -4,29 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.MarkLine = void 0;
|
|
6
6
|
|
|
7
|
-
const vutils_1 = require("@visactor/vutils"), type_1 = require("./type"), register_1 = require("./register"),
|
|
7
|
+
const vutils_1 = require("@visactor/vutils"), type_1 = require("./type"), register_1 = require("./register"), common_line_1 = require("./common-line"), segment_1 = require("../segment"), constant_1 = require("../constant"), config_1 = require("./config");
|
|
8
8
|
|
|
9
9
|
(0, register_1.loadMarkLineComponent)();
|
|
10
10
|
|
|
11
|
-
class MarkLine extends
|
|
11
|
+
class MarkLine extends common_line_1.MarkCommonLine {
|
|
12
12
|
constructor(attributes, options) {
|
|
13
13
|
super((null == options ? void 0 : options.skipDefault) ? attributes : (0, vutils_1.merge)({}, MarkLine.defaultAttributes, attributes)),
|
|
14
|
-
this.name = "
|
|
14
|
+
this.name = "markLine";
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return points.forEach((point => {
|
|
21
|
-
if (point.length) point.forEach((p => {
|
|
22
|
-
(0, vutils_1.isValidNumber)(p.x) && (0, vutils_1.isValidNumber)(p.y) || (validFlag = !1);
|
|
23
|
-
})); else if (!(0, vutils_1.isValidNumber)(point.x) || !(0, vutils_1.isValidNumber)(point.y)) return void (validFlag = !1);
|
|
24
|
-
})), validFlag;
|
|
25
|
-
}
|
|
26
|
-
getLabelOffsetByDirection(direction) {
|
|
27
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
28
|
-
const 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);
|
|
29
|
-
switch (direction) {
|
|
16
|
+
getLabelOffsetByPosition(position) {
|
|
17
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
18
|
+
const labelRectHeight = Math.abs((null !== (_c = null === (_b = null === (_a = this._label.getTextShape()) || void 0 === _a ? void 0 : _a.AABBBounds) || void 0 === _b ? void 0 : _b.y2) && void 0 !== _c ? _c : 0) - (null !== (_e = null === (_d = this._label.getTextShape()) || void 0 === _d ? void 0 : _d.AABBBounds.y1) && void 0 !== _e ? _e : 0)), labelTextHeight = Math.abs((null !== (_h = null === (_g = null === (_f = this._label.getBgRect()) || void 0 === _f ? void 0 : _f.AABBBounds) || void 0 === _g ? void 0 : _g.y2) && void 0 !== _h ? _h : 0) - (null !== (_k = null === (_j = this._label.getBgRect()) || void 0 === _j ? void 0 : _j.AABBBounds.y1) && void 0 !== _k ? _k : 0)), labelHeight = Math.max(labelRectHeight, labelTextHeight), labelRectWidth = Math.abs((null !== (_o = null === (_m = null === (_l = this._label.getTextShape()) || void 0 === _l ? void 0 : _l.AABBBounds) || void 0 === _m ? void 0 : _m.x2) && void 0 !== _o ? _o : 0) - (null !== (_q = null === (_p = this._label.getTextShape()) || void 0 === _p ? void 0 : _p.AABBBounds.x1) && void 0 !== _q ? _q : 0)), labelTextWidth = Math.abs((null !== (_t = null === (_s = null === (_r = this._label.getBgRect()) || void 0 === _r ? void 0 : _r.AABBBounds) || void 0 === _s ? void 0 : _s.x2) && void 0 !== _t ? _t : 0) - (null !== (_v = null === (_u = this._label.getBgRect()) || void 0 === _u ? void 0 : _u.AABBBounds.x1) && void 0 !== _v ? _v : 0)), labelWidth = Math.max(labelRectWidth, labelTextWidth);
|
|
19
|
+
switch (position) {
|
|
30
20
|
case type_1.IMarkLineLabelPosition.start:
|
|
31
21
|
return {
|
|
32
22
|
offsetX: -labelWidth / 2,
|
|
@@ -88,16 +78,16 @@ class MarkLine extends base_line_1.BaseMarkLine {
|
|
|
88
78
|
};
|
|
89
79
|
}
|
|
90
80
|
}
|
|
91
|
-
|
|
81
|
+
getPointAttrByPosition(position) {
|
|
92
82
|
var _a;
|
|
93
|
-
const {label: label = {}} = this.attribute, {refX: refX = 0, refY: refY = 0} = label, points = this._line.getMainSegmentPoints(), labelAngle = null !== (_a = this._line.getEndAngle()) && void 0 !== _a ? _a : 0, totalRefX = refX + this.
|
|
94
|
-
return
|
|
83
|
+
const {label: label = {}} = this.attribute, {refX: refX = 0, refY: refY = 0} = label, points = this._line.getMainSegmentPoints(), labelAngle = null !== (_a = this._line.getEndAngle()) && void 0 !== _a ? _a : 0, totalRefX = refX + this.getLabelOffsetByPosition(position).offsetX, totalRefY = refY + this.getLabelOffsetByPosition(position).offsetY, labelOffsetX = totalRefX * Math.cos(labelAngle) + totalRefY * Math.cos(labelAngle - Math.PI / 2), labelOffsetY = totalRefX * Math.sin(labelAngle) + totalRefY * Math.sin(labelAngle - Math.PI / 2);
|
|
84
|
+
return position.includes("start") || position.includes("Start") ? {
|
|
95
85
|
position: {
|
|
96
86
|
x: points[0].x + labelOffsetX,
|
|
97
87
|
y: points[0].y + labelOffsetY
|
|
98
88
|
},
|
|
99
89
|
angle: labelAngle
|
|
100
|
-
} :
|
|
90
|
+
} : position.includes("middle") || position.includes("Middle") ? {
|
|
101
91
|
position: {
|
|
102
92
|
x: (points[0].x + points[points.length - 1].x) / 2 + labelOffsetX,
|
|
103
93
|
y: (points[0].y + points[points.length - 1].y) / 2 + labelOffsetY
|
|
@@ -111,13 +101,9 @@ class MarkLine extends base_line_1.BaseMarkLine {
|
|
|
111
101
|
angle: labelAngle
|
|
112
102
|
};
|
|
113
103
|
}
|
|
114
|
-
|
|
104
|
+
getRotateByAngle(angle) {
|
|
115
105
|
var _a;
|
|
116
|
-
|
|
117
|
-
const {label: label = {}} = this.attribute, {position: position = "end", autoRotate: autoRotate = !0} = label, labelAttr = this.getPositionByDirection(position);
|
|
118
|
-
this._label.setAttributes(Object.assign(Object.assign({}, labelAttr.position), {
|
|
119
|
-
angle: autoRotate ? labelAttr.angle + (null !== (_a = label.refAngle) && void 0 !== _a ? _a : 0) : 0
|
|
120
|
-
}));
|
|
106
|
+
return angle + (null !== (_a = this.attribute.label.refAngle) && void 0 !== _a ? _a : 0);
|
|
121
107
|
}
|
|
122
108
|
createSegment() {
|
|
123
109
|
const {points: points, startSymbol: startSymbol, endSymbol: endSymbol, lineStyle: lineStyle, mainSegmentIndex: mainSegmentIndex, multiSegment: multiSegment, state: state} = this.attribute;
|
|
@@ -147,6 +133,16 @@ class MarkLine extends base_line_1.BaseMarkLine {
|
|
|
147
133
|
multiSegment: multiSegment
|
|
148
134
|
});
|
|
149
135
|
}
|
|
136
|
+
isValidPoints() {
|
|
137
|
+
const {points: points} = this.attribute;
|
|
138
|
+
if (!points || points.length < 2) return !1;
|
|
139
|
+
let validFlag = !0;
|
|
140
|
+
return points.forEach((point => {
|
|
141
|
+
if (point.length) point.forEach((p => {
|
|
142
|
+
(0, vutils_1.isValidNumber)(p.x) && (0, vutils_1.isValidNumber)(p.y) || (validFlag = !1);
|
|
143
|
+
})); else if (!(0, vutils_1.isValidNumber)(point.x) || !(0, vutils_1.isValidNumber)(point.y)) return void (validFlag = !1);
|
|
144
|
+
})), validFlag;
|
|
145
|
+
}
|
|
150
146
|
}
|
|
151
147
|
|
|
152
148
|
exports.MarkLine = MarkLine, MarkLine.defaultAttributes = config_1.DEFAULT_MARK_LINE_THEME;
|
package/cjs/marker/line.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/marker/line.ts"],"names":[],"mappings":";;;AAAA,6CAAwD;AACxD,iCAAgD;AAGhD,yCAAmD;AAEnD,2CAA2C;AAG3C,wCAAqC;AACrC,0CAA6C;AAC7C,qCAAmD;AAGnD,IAAA,gCAAqB,GAAE,CAAC;AACxB,MAAa,QAAS,SAAQ,wBAA2D;IAMvF,YAAY,UAAyB,EAAE,OAA0B;QAC/D,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,QAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAN/F,SAAI,GAAG,UAAU,CAAC;IAOlB,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,KAAsB,EAAE,EAAE;YACxC,IAAK,KAAa,CAAC,MAAM,EAAE;gBACxB,KAAiB,CAAC,OAAO,CAAC,CAAC,CAAQ,EAAE,EAAE;oBACtC,IAAI,CAAC,IAAA,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AAE,GAAG,IAAI;aACvF,SAA0B,CAAC;QAC9B,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;gBACvB,MAAM;gBACN,WAAW;gBACX,SAAS;gBACT,SAAS;gBACT,gBAAgB;gBAChB,YAAY;aACb,CAAC,CAAC;SACJ;IACH,CAAC;;AA9LH,4BA+LC;AA5LQ,0BAAiB,GAA2B,gCAAmD,CAAC","file":"line.js","sourcesContent":["import { isValidNumber, merge } from '@visactor/vutils';\nimport { IMarkLineLabelPosition } from './type';\nimport type { MarkLineAttrs } from './type';\nimport type { ComponentOptions } from '../interface';\nimport { loadMarkLineComponent } from './register';\nimport type { Point } from '../core/type';\nimport { BaseMarkLine } from './base-line';\nimport type { ArcSegment } from '../segment';\n// eslint-disable-next-line no-duplicate-imports\nimport { Segment } from '../segment';\nimport { DEFAULT_STATES } from '../constant';\nimport { DEFAULT_MARK_LINE_THEME } from './config';\nimport type { ILineGraphicAttribute } from '@visactor/vrender-core';\n\nloadMarkLineComponent();\nexport class MarkLine extends BaseMarkLine<ILineGraphicAttribute, IMarkLineLabelPosition> {\n name = 'MarkLine';\n // eslint-disable-next-line max-len\n static defaultAttributes: Partial<MarkLineAttrs> = DEFAULT_MARK_LINE_THEME as unknown as MarkLineAttrs;\n protected _line!: Segment | ArcSegment;\n\n constructor(attributes: MarkLineAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, MarkLine.defaultAttributes, attributes));\n }\n\n protected isValidPoints() {\n const { points } = this.attribute as MarkLineAttrs;\n if (!points || points.length < 2) {\n return false;\n }\n let validFlag = true;\n points.forEach((point: Point | Point[]) => {\n if ((point as any).length) {\n (point as Point[]).forEach((p: Point) => {\n if (!isValidNumber((p as Point).x) || !isValidNumber((p as Point).y)) {\n validFlag = false;\n return;\n }\n });\n } else if (!isValidNumber((point as Point).x) || !isValidNumber((point as Point).y)) {\n validFlag = false;\n return;\n }\n });\n return validFlag;\n }\n\n protected getLabelOffsetByDirection(direction: IMarkLineLabelPosition) {\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 switch (direction) {\n case IMarkLineLabelPosition.start:\n return {\n offsetX: -labelWidth / 2,\n offsetY: 0\n };\n case IMarkLineLabelPosition.insideStartTop:\n return {\n offsetX: labelWidth / 2,\n offsetY: labelHeight / 2\n };\n case IMarkLineLabelPosition.insideStartBottom:\n return {\n offsetX: labelWidth / 2,\n offsetY: -labelHeight / 2\n };\n case IMarkLineLabelPosition.middle:\n return {\n offsetX: 0,\n offsetY: 0\n };\n case IMarkLineLabelPosition.insideMiddleTop:\n return {\n offsetX: 0,\n offsetY: labelHeight / 2\n };\n case IMarkLineLabelPosition.insideMiddleBottom:\n return {\n offsetX: 0,\n offsetY: -labelHeight / 2\n };\n case IMarkLineLabelPosition.end:\n return {\n offsetX: labelWidth / 2,\n offsetY: 0\n };\n case IMarkLineLabelPosition.insideEndTop:\n return {\n offsetX: -labelWidth / 2,\n offsetY: labelHeight / 2\n };\n case IMarkLineLabelPosition.insideEndBottom:\n return {\n offsetX: -labelWidth / 2,\n offsetY: -labelHeight / 2\n };\n default: // default end\n return {\n offsetX: labelWidth / 2,\n offsetY: 0\n };\n }\n }\n\n protected getPositionByDirection(direction: IMarkLineLabelPosition) {\n const { label = {} } = this.attribute;\n const { refX = 0, refY = 0 } = label;\n const points = this._line.getMainSegmentPoints();\n const labelAngle = this._line.getEndAngle() ?? 0;\n\n const totalRefX = refX + this.getLabelOffsetByDirection(direction).offsetX;\n const totalRefY = refY + this.getLabelOffsetByDirection(direction).offsetY;\n\n const labelOffsetX = totalRefX * Math.cos(labelAngle) + totalRefY * Math.cos(labelAngle - Math.PI / 2);\n const labelOffsetY = totalRefX * Math.sin(labelAngle) + totalRefY * Math.sin(labelAngle - Math.PI / 2);\n\n if (direction.includes('start') || direction.includes('Start')) {\n return {\n position: {\n x: points[0].x + labelOffsetX,\n y: points[0].y + labelOffsetY\n },\n angle: labelAngle\n };\n } else if (direction.includes('middle') || direction.includes('Middle')) {\n return {\n position: {\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 angle: labelAngle\n };\n }\n return {\n position: {\n x: points[points.length - 1].x + labelOffsetX,\n y: points[points.length - 1].y + labelOffsetY\n },\n angle: labelAngle\n };\n }\n\n protected setLabelPos(): void {\n super.setLabelPos();\n const { label = {} } = this.attribute as MarkLineAttrs;\n const { position = 'end', autoRotate = true } = label;\n const labelAttr = this.getPositionByDirection(position as any);\n this._label.setAttributes({\n ...labelAttr.position,\n angle: autoRotate ? labelAttr.angle + (label.refAngle ?? 0) : 0\n });\n }\n\n protected createSegment() {\n const { points, startSymbol, endSymbol, lineStyle, mainSegmentIndex, multiSegment, state } = this\n .attribute as MarkLineAttrs;\n return new Segment({\n points,\n startSymbol,\n endSymbol,\n lineStyle,\n mainSegmentIndex,\n multiSegment,\n pickable: false, // 组件容器本身不参与拾取\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 { points, startSymbol, endSymbol, lineStyle, mainSegmentIndex, multiSegment } = this\n .attribute as MarkLineAttrs;\n if (this._line) {\n this._line.setAttributes({\n points,\n startSymbol,\n endSymbol,\n lineStyle,\n mainSegmentIndex,\n multiSegment\n });\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/marker/line.ts"],"names":[],"mappings":";;;AAAA,6CAAwD;AACxD,iCAAgD;AAGhD,yCAAmD;AAEnD,+CAA+C;AAG/C,wCAAqC;AACrC,0CAA6C;AAC7C,qCAAmD;AAGnD,IAAA,gCAAqB,GAAE,CAAC;AACxB,MAAa,QAAS,SAAQ,4BAA6D;IAMzF,YAAY,UAAyB,EAAE,OAA0B;QAC/D,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,QAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAN/F,SAAI,GAAG,UAAU,CAAC;IAOlB,CAAC;IAES,wBAAwB,CAAC,QAAgC;;QAEjE,MAAM,eAAe,GAAG,IAAI,CAAC,GAAG,CAC9B,CAAC,MAAA,MAAA,MAAA,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,0CAAE,UAAU,0CAAE,EAAE,mCAAI,CAAC,CAAC,GAAG,CAAC,MAAA,MAAA,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,0CAAE,UAAU,CAAC,EAAE,mCAAI,CAAC,CAAC,CACrG,CAAC;QACF,MAAM,eAAe,GAAG,IAAI,CAAC,GAAG,CAC9B,CAAC,MAAA,MAAA,MAAA,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,0CAAE,UAAU,0CAAE,EAAE,mCAAI,CAAC,CAAC,GAAG,CAAC,MAAA,MAAA,IAAI,CAAC,MAAM,CAAC,SAAS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AAI;aACvF,SAA0B,CAAC;QAC9B,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;gBACvB,MAAM;gBACN,WAAW;gBACX,SAAS;gBACT,SAAS;gBACT,gBAAgB;gBAChB,YAAY;aACb,CAAC,CAAC;SACJ;IACH,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,KAAsB,EAAE,EAAE;YACxC,IAAK,KAAa,CAAC,MAAM,EAAE;gBACxB,KAAiB,CAAC,OAAO,CAAC,CAAC,CAAQ,EAAE,EAAE;oBACtC,IAAI,CAAC,IAAA,sBAAa,EAAE,CAAW,CAAC,CAAC,CAAC,IAAI,CAAC,IAAA,sBAAa,EAAE,CAAW,CAAC,CAAC,CAAC,EAAE;wBACpE,SAAS,GAAG,KAAK,CAAC;wBAClB,OAAO;qBACR;gBACH,CAAC,CAAC,CAAC;aACJ;iBAAM,IAAI,CAAC,IAAA,sBAAa,EAAE,KAAe,CAAC,CAAC,CAAC,IAAI,CAAC,IAAA,sBAAa,EAAE,KAAe,CAAC,CAAC,CAAC,EAAE;gBACnF,SAAS,GAAG,KAAK,CAAC;gBAClB,OAAO;aACR;QACH,CAAC,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;;AAnLH,4BAoLC;AAjLQ,0BAAiB,GAA2B,gCAAmD,CAAC","file":"line.js","sourcesContent":["import { isValidNumber, merge } from '@visactor/vutils';\nimport { IMarkLineLabelPosition } from './type';\nimport type { MarkLineAttrs } from './type';\nimport type { ComponentOptions } from '../interface';\nimport { loadMarkLineComponent } from './register';\nimport type { Point } from '../core/type';\nimport { MarkCommonLine } from './common-line';\nimport type { ArcSegment } from '../segment';\n// eslint-disable-next-line no-duplicate-imports\nimport { Segment } from '../segment';\nimport { DEFAULT_STATES } from '../constant';\nimport { DEFAULT_MARK_LINE_THEME } from './config';\nimport type { ILineGraphicAttribute } from '@visactor/vrender-core';\n\nloadMarkLineComponent();\nexport class MarkLine extends MarkCommonLine<ILineGraphicAttribute, IMarkLineLabelPosition> {\n name = 'markLine';\n // eslint-disable-next-line max-len\n static defaultAttributes: Partial<MarkLineAttrs> = DEFAULT_MARK_LINE_THEME as unknown as MarkLineAttrs;\n protected _line!: Segment | ArcSegment;\n\n constructor(attributes: MarkLineAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, MarkLine.defaultAttributes, attributes));\n }\n\n protected getLabelOffsetByPosition(position: IMarkLineLabelPosition) {\n // labelHeight\n const labelRectHeight = Math.abs(\n (this._label.getTextShape()?.AABBBounds?.y2 ?? 0) - (this._label.getTextShape()?.AABBBounds.y1 ?? 0)\n );\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 const labelRectWidth = Math.abs(\n (this._label.getTextShape()?.AABBBounds?.x2 ?? 0) - (this._label.getTextShape()?.AABBBounds.x1 ?? 0)\n );\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 switch (position) {\n case IMarkLineLabelPosition.start:\n return {\n offsetX: -labelWidth / 2,\n offsetY: 0\n };\n case IMarkLineLabelPosition.insideStartTop:\n return {\n offsetX: labelWidth / 2,\n offsetY: labelHeight / 2\n };\n case IMarkLineLabelPosition.insideStartBottom:\n return {\n offsetX: labelWidth / 2,\n offsetY: -labelHeight / 2\n };\n case IMarkLineLabelPosition.middle:\n return {\n offsetX: 0,\n offsetY: 0\n };\n case IMarkLineLabelPosition.insideMiddleTop:\n return {\n offsetX: 0,\n offsetY: labelHeight / 2\n };\n case IMarkLineLabelPosition.insideMiddleBottom:\n return {\n offsetX: 0,\n offsetY: -labelHeight / 2\n };\n case IMarkLineLabelPosition.end:\n return {\n offsetX: labelWidth / 2,\n offsetY: 0\n };\n case IMarkLineLabelPosition.insideEndTop:\n return {\n offsetX: -labelWidth / 2,\n offsetY: labelHeight / 2\n };\n case IMarkLineLabelPosition.insideEndBottom:\n return {\n offsetX: -labelWidth / 2,\n offsetY: -labelHeight / 2\n };\n default: // default end\n return {\n offsetX: labelWidth / 2,\n offsetY: 0\n };\n }\n }\n\n protected getPointAttrByPosition(position: IMarkLineLabelPosition) {\n const { label = {} } = this.attribute;\n const { refX = 0, refY = 0 } = label;\n const points = this._line.getMainSegmentPoints();\n const labelAngle = this._line.getEndAngle() ?? 0;\n\n const totalRefX = refX + this.getLabelOffsetByPosition(position).offsetX;\n const totalRefY = refY + this.getLabelOffsetByPosition(position).offsetY;\n\n const labelOffsetX = totalRefX * Math.cos(labelAngle) + totalRefY * Math.cos(labelAngle - Math.PI / 2);\n const labelOffsetY = totalRefX * Math.sin(labelAngle) + totalRefY * Math.sin(labelAngle - Math.PI / 2);\n\n if (position.includes('start') || position.includes('Start')) {\n return {\n position: {\n x: points[0].x + labelOffsetX,\n y: points[0].y + labelOffsetY\n },\n angle: labelAngle\n };\n } else if (position.includes('middle') || position.includes('Middle')) {\n return {\n position: {\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 angle: labelAngle\n };\n }\n return {\n position: {\n x: points[points.length - 1].x + labelOffsetX,\n y: points[points.length - 1].y + labelOffsetY\n },\n angle: labelAngle\n };\n }\n\n protected getRotateByAngle(angle: number): number {\n return angle + (this.attribute.label.refAngle ?? 0);\n }\n\n protected createSegment() {\n const { points, startSymbol, endSymbol, lineStyle, mainSegmentIndex, multiSegment, state } = this\n .attribute as MarkLineAttrs;\n return new Segment({\n points,\n startSymbol,\n endSymbol,\n lineStyle,\n mainSegmentIndex,\n multiSegment,\n pickable: false, // 组件容器本身不参与拾取\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 { points, startSymbol, endSymbol, lineStyle, mainSegmentIndex, multiSegment } = this\n .attribute as MarkLineAttrs;\n if (this._line) {\n this._line.setAttributes({\n points,\n startSymbol,\n endSymbol,\n lineStyle,\n mainSegmentIndex,\n multiSegment\n });\n }\n }\n\n protected isValidPoints() {\n const { points } = this.attribute as MarkLineAttrs;\n if (!points || points.length < 2) {\n return false;\n }\n let validFlag = true;\n points.forEach((point: Point | Point[]) => {\n if ((point as any).length) {\n (point as Point[]).forEach((p: Point) => {\n if (!isValidNumber((p as Point).x) || !isValidNumber((p as Point).y)) {\n validFlag = false;\n return;\n }\n });\n } else if (!isValidNumber((point as Point).x) || !isValidNumber((point as Point).y)) {\n validFlag = false;\n return;\n }\n });\n return validFlag;\n }\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FederatedPointerEvent, IGraphic, IGroup } from '@visactor/vrender-core';
|
|
2
|
+
export declare const dispatchHoverState: (e: FederatedPointerEvent, container: IGroup, lastHover: IGraphic | null) => IGraphic<Partial<import("@visactor/vrender-core").IGraphicAttribute>>;
|
|
3
|
+
export declare const dispatchUnHoverState: (e: FederatedPointerEvent, container: IGroup, lastHover: IGraphic | null) => IGraphic<Partial<import("@visactor/vrender-core").IGraphicAttribute>>;
|
|
4
|
+
export declare const dispatchClickState: (e: FederatedPointerEvent, container: IGroup, lastSelect: IGraphic | null) => IGraphic<Partial<import("@visactor/vrender-core").IGraphicAttribute>>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.dispatchClickState = exports.dispatchUnHoverState = exports.dispatchHoverState = void 0;
|
|
6
|
+
|
|
7
|
+
const constant_1 = require("../constant"), util_1 = require("../util"), vutils_1 = require("@visactor/vutils"), dispatchHoverState = (e, container, lastHover) => {
|
|
8
|
+
const target = e.target;
|
|
9
|
+
return target !== lastHover && target.name && !(0, vutils_1.isEmpty)(target.states) ? (target.addState(constant_1.StateValue.hover, !0),
|
|
10
|
+
(0, util_1.traverseGroup)(container, (node => {
|
|
11
|
+
node !== target && node.name && !(0, vutils_1.isEmpty)(node.states) && node.addState(constant_1.StateValue.hoverReverse, !0);
|
|
12
|
+
})), target) : lastHover;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.dispatchHoverState = dispatchHoverState;
|
|
16
|
+
|
|
17
|
+
const dispatchUnHoverState = (e, container, lastHover) => lastHover ? ((0, util_1.traverseGroup)(container, (node => {
|
|
18
|
+
node.name && !(0, vutils_1.isEmpty)(node.states) && (node.removeState(constant_1.StateValue.hoverReverse),
|
|
19
|
+
node.removeState(constant_1.StateValue.hover));
|
|
20
|
+
})), null) : lastHover;
|
|
21
|
+
|
|
22
|
+
exports.dispatchUnHoverState = dispatchUnHoverState;
|
|
23
|
+
|
|
24
|
+
const dispatchClickState = (e, container, lastSelect) => {
|
|
25
|
+
const target = e.target;
|
|
26
|
+
return lastSelect === target && target.hasState(constant_1.StateValue.selected) ? ((0,
|
|
27
|
+
util_1.traverseGroup)(container, (node => {
|
|
28
|
+
node.name && !(0, vutils_1.isEmpty)(node.states) && (node.removeState(constant_1.StateValue.selectedReverse),
|
|
29
|
+
node.removeState(constant_1.StateValue.selected));
|
|
30
|
+
})), null) : target.name && !(0, vutils_1.isEmpty)(target.states) ? (target.addState(constant_1.StateValue.selected, !0),
|
|
31
|
+
(0, util_1.traverseGroup)(container, (node => {
|
|
32
|
+
node !== target && node.name && !(0, vutils_1.isEmpty)(node.states) && node.addState(constant_1.StateValue.selectedReverse, !0);
|
|
33
|
+
})), target) : lastSelect;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.dispatchClickState = dispatchClickState;
|
|
37
|
+
//# sourceMappingURL=interaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/util/interaction.ts"],"names":[],"mappings":";;;AACA,0CAAyC;AACzC,kCAAwC;AACxC,6CAA2C;AAEpC,MAAM,kBAAkB,GAAG,CAAC,CAAwB,EAAE,SAAiB,EAAE,SAA0B,EAAE,EAAE;IAC5G,MAAM,MAAM,GAAG,CAAC,CAAC,MAA6B,CAAC;IAC/C,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,IAAI,CAAC,IAAA,gBAAO,EAAC,MAAM,CAAC,MAAM,CAAC,EAAE;QAClE,MAAM,CAAC,QAAQ,CAAC,qBAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACxC,IAAA,oBAAa,EAAC,SAAS,EAAE,CAAC,IAAc,EAAE,EAAE;YAC1C,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,IAAA,gBAAO,EAAC,IAAI,CAAC,MAAM,CAAC,EAAE;gBACzD,IAAI,CAAC,QAAQ,CAAC,qBAAU,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;aAC9C;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;KACf;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAZW,QAAA,kBAAkB,sBAY7B;AAEK,MAAM,oBAAoB,GAAG,CAAC,CAAwB,EAAE,SAAiB,EAAE,SAA0B,EAAE,EAAE;IAC9G,IAAI,SAAS,EAAE;QACb,IAAA,oBAAa,EAAC,SAAS,EAAE,CAAC,IAAc,EAAE,EAAE;YAC1C,IAAI,IAAI,CAAC,IAAI,I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AI,CAAC,QAAQ,CAAC,qBAAU,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;aACjD;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;KACf;IACD,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAvBW,QAAA,kBAAkB,sBAuB7B","file":"interaction.js","sourcesContent":["import type { FederatedPointerEvent, IGraphic, IGroup } from '@visactor/vrender-core';\nimport { StateValue } from '../constant';\nimport { traverseGroup } from '../util';\nimport { isEmpty } from '@visactor/vutils';\n\nexport const dispatchHoverState = (e: FederatedPointerEvent, container: IGroup, lastHover: IGraphic | null) => {\n const target = e.target as unknown as IGraphic;\n if (target !== lastHover && target.name && !isEmpty(target.states)) {\n target.addState(StateValue.hover, true);\n traverseGroup(container, (node: IGraphic) => {\n if (node !== target && node.name && !isEmpty(node.states)) {\n node.addState(StateValue.hoverReverse, true);\n }\n });\n return target;\n }\n return lastHover;\n};\n\nexport const dispatchUnHoverState = (e: FederatedPointerEvent, container: IGroup, lastHover: IGraphic | null) => {\n if (lastHover) {\n traverseGroup(container, (node: IGraphic) => {\n if (node.name && !isEmpty(node.states)) {\n node.removeState(StateValue.hoverReverse);\n node.removeState(StateValue.hover);\n }\n });\n return null;\n }\n return lastHover;\n};\n\nexport const dispatchClickState = (e: FederatedPointerEvent, container: IGroup, lastSelect: IGraphic | null) => {\n const target = e.target as unknown as IGraphic;\n if (lastSelect === target && target.hasState(StateValue.selected)) {\n traverseGroup(container, (node: IGraphic) => {\n if (node.name && !isEmpty(node.states)) {\n node.removeState(StateValue.selectedReverse);\n node.removeState(StateValue.selected);\n }\n });\n // 取消选中\n return null;\n }\n\n if (target.name && !isEmpty(target.states)) {\n target.addState(StateValue.selected, true);\n traverseGroup(container, (node: IGraphic) => {\n if (node !== target && node.name && !isEmpty(node.states)) {\n node.addState(StateValue.selectedReverse, true);\n }\n });\n return target;\n }\n return lastSelect;\n};\n"]}
|
package/es/axis/base.js
CHANGED
|
@@ -4,9 +4,9 @@ import { abs, cloneDeep, get, isEmpty, isFunction, isNumberClose, merge, pi } fr
|
|
|
4
4
|
|
|
5
5
|
import { AbstractComponent } from "../core/base";
|
|
6
6
|
|
|
7
|
-
import { isRichText, richTextAttributeTransform
|
|
7
|
+
import { isRichText, richTextAttributeTransform } from "../util";
|
|
8
8
|
|
|
9
|
-
import { DEFAULT_STATES
|
|
9
|
+
import { DEFAULT_STATES } from "../constant";
|
|
10
10
|
|
|
11
11
|
import { AXIS_ELEMENT_NAME } from "./constant";
|
|
12
12
|
|
|
@@ -16,32 +16,18 @@ import { Tag } from "../tag/tag";
|
|
|
16
16
|
|
|
17
17
|
import { getElMap } from "./util";
|
|
18
18
|
|
|
19
|
+
import { dispatchClickState, dispatchHoverState, dispatchUnHoverState } from "../util/interaction";
|
|
20
|
+
|
|
19
21
|
export class AxisBase extends AbstractComponent {
|
|
20
22
|
constructor() {
|
|
21
23
|
super(...arguments), this.name = "axis", this.data = [], this.tickLineItems = [],
|
|
22
24
|
this.subTickLineItems = [], this.axisLabelLayerSize = {}, this.axisLabelsContainer = null,
|
|
23
25
|
this._onHover = e => {
|
|
24
|
-
|
|
25
|
-
target !== this._lastHover && target.name && !isEmpty(target.states) && (target.addState(StateValue.hover, !0),
|
|
26
|
-
traverseGroup(this.axisContainer, (node => {
|
|
27
|
-
node !== target && node.name && !isEmpty(node.states) && node.addState(StateValue.hoverReverse, !0);
|
|
28
|
-
})), this._lastHover = target);
|
|
26
|
+
this._lastHover = dispatchHoverState(e, this.axisContainer, this._lastHover);
|
|
29
27
|
}, this._onUnHover = e => {
|
|
30
|
-
this._lastHover
|
|
31
|
-
node.name && !isEmpty(node.states) && (node.removeState(StateValue.hoverReverse),
|
|
32
|
-
node.removeState(StateValue.hover));
|
|
33
|
-
})), this._lastHover = null);
|
|
28
|
+
this._lastHover = dispatchUnHoverState(e, this.axisContainer, this._lastHover);
|
|
34
29
|
}, this._onClick = e => {
|
|
35
|
-
|
|
36
|
-
if (this._lastSelect === target && target.hasState(StateValue.selected)) return this._lastSelect = null,
|
|
37
|
-
void traverseGroup(this.axisContainer, (node => {
|
|
38
|
-
node.name && !isEmpty(node.states) && (node.removeState(StateValue.selectedReverse),
|
|
39
|
-
node.removeState(StateValue.selected));
|
|
40
|
-
}));
|
|
41
|
-
target.name && !isEmpty(target.states) && (target.addState(StateValue.selected, !0),
|
|
42
|
-
traverseGroup(this.axisContainer, (node => {
|
|
43
|
-
node !== target && node.name && !isEmpty(node.states) && node.addState(StateValue.selectedReverse, !0);
|
|
44
|
-
})), this._lastSelect = target);
|
|
30
|
+
this._lastSelect = dispatchClickState(e, this.axisContainer, this._lastSelect);
|
|
45
31
|
};
|
|
46
32
|
}
|
|
47
33
|
getInnerView() {
|