@visactor/vrender-components 0.23.0-alpha.3 → 1.0.0-alpha.10
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/animation/animate-component.d.ts +22 -0
- package/cjs/animation/animate-component.js +29 -0
- package/cjs/animation/animate-component.js.map +1 -0
- package/cjs/animation/axis-animate.d.ts +10 -0
- package/cjs/animation/axis-animate.js +71 -0
- package/cjs/animation/axis-animate.js.map +1 -0
- package/cjs/animation/label-animate.d.ts +10 -0
- package/cjs/animation/label-animate.js +80 -0
- package/cjs/animation/label-animate.js.map +1 -0
- package/cjs/axis/animate/config.d.ts +6 -0
- package/cjs/axis/animate/config.js +10 -0
- package/cjs/axis/animate/config.js.map +1 -0
- package/cjs/axis/animate/group-transition.d.ts +2 -1
- package/cjs/axis/animate/group-transition.js +2 -2
- package/cjs/axis/animate/group-transition.js.map +1 -1
- package/cjs/axis/base.d.ts +9 -4
- package/cjs/axis/base.js +70 -5
- package/cjs/axis/base.js.map +1 -1
- package/cjs/axis/line.js.map +1 -1
- package/cjs/axis/register.js +2 -2
- package/cjs/axis/register.js.map +1 -1
- package/cjs/axis/type.d.ts +4 -0
- package/cjs/axis/type.js.map +1 -1
- package/cjs/axis/util.js +5 -5
- package/cjs/axis/util.js.map +1 -1
- package/cjs/brush/brush.d.ts +16 -10
- package/cjs/brush/brush.js +81 -93
- package/cjs/brush/brush.js.map +1 -1
- package/cjs/brush/config.d.ts +5 -5
- package/cjs/brush/config.js +6 -7
- package/cjs/brush/config.js.map +1 -1
- package/cjs/brush/type.d.ts +1 -0
- package/cjs/brush/type.js +3 -2
- package/cjs/brush/type.js.map +1 -1
- package/cjs/crosshair/rect.js +1 -2
- package/cjs/crosshair/type.js +2 -1
- package/cjs/data-zoom/data-zoom.d.ts +3 -0
- package/cjs/data-zoom/data-zoom.js +36 -19
- package/cjs/data-zoom/data-zoom.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/indicator/register.js +1 -2
- package/cjs/jsx/index.js +2 -1
- package/cjs/label/animate/animate.d.ts +1 -12
- package/cjs/label/animate/animate.js +1 -78
- package/cjs/label/animate/animate.js.map +1 -1
- package/cjs/label/base.d.ts +5 -3
- package/cjs/label/base.js +61 -35
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/dataLabel.js +1 -1
- package/cjs/label/overlap/scaler.js +3 -3
- package/cjs/label/overlap/scaler.js.map +1 -1
- package/cjs/label/register.d.ts +1 -0
- package/cjs/label/register.js +8 -4
- package/cjs/label/register.js.map +1 -1
- package/cjs/label-item/index.js +1 -1
- package/cjs/label-item/label-item.js +1 -1
- package/cjs/label-item/label-item.js.map +1 -1
- package/cjs/label-item/register.js +1 -1
- package/cjs/label-item/type.js +1 -1
- package/cjs/marker/animate/animate.d.ts +3 -3
- package/cjs/marker/animate/animate.js.map +1 -1
- package/cjs/marker/animate/clip-in.d.ts +1 -1
- package/cjs/marker/animate/clip-in.js +6 -3
- package/cjs/marker/animate/clip-in.js.map +1 -1
- package/cjs/marker/animate/fade-in.d.ts +3 -3
- package/cjs/marker/animate/fade-in.js +10 -4
- package/cjs/marker/animate/fade-in.js.map +1 -1
- package/cjs/marker/animate/fade-out.d.ts +3 -3
- package/cjs/marker/animate/fade-out.js +10 -4
- package/cjs/marker/animate/fade-out.js.map +1 -1
- package/cjs/marker/arc-area.d.ts +8 -5
- package/cjs/marker/arc-area.js +18 -39
- package/cjs/marker/arc-area.js.map +1 -1
- package/cjs/marker/arc-line.d.ts +6 -4
- package/cjs/marker/arc-line.js +12 -9
- package/cjs/marker/arc-line.js.map +1 -1
- package/cjs/marker/area.d.ts +6 -4
- package/cjs/marker/area.js +14 -32
- package/cjs/marker/area.js.map +1 -1
- package/cjs/marker/base.d.ts +2 -3
- package/cjs/marker/base.js.map +1 -1
- package/cjs/marker/common-line.d.ts +11 -7
- package/cjs/marker/common-line.js +11 -31
- package/cjs/marker/common-line.js.map +1 -1
- package/cjs/marker/config.d.ts +2 -0
- package/cjs/marker/config.js +2 -0
- package/cjs/marker/config.js.map +1 -1
- package/cjs/marker/line.d.ts +6 -4
- package/cjs/marker/line.js +10 -4
- package/cjs/marker/line.js.map +1 -1
- package/cjs/marker/mixin/label.d.ts +16 -0
- package/cjs/marker/mixin/label.js +57 -0
- package/cjs/marker/mixin/label.js.map +1 -0
- package/cjs/marker/type.d.ts +19 -16
- package/cjs/marker/type.js.map +1 -1
- package/cjs/poptip/contribution.js +4 -2
- package/cjs/poptip/contribution.js.map +1 -1
- package/cjs/poptip/poptip.d.ts +5 -0
- package/cjs/poptip/poptip.js +87 -18
- package/cjs/poptip/poptip.js.map +1 -1
- package/cjs/poptip/type.d.ts +4 -1
- package/cjs/poptip/type.js.map +1 -1
- package/cjs/scrollbar/scrollbar.d.ts +1 -0
- package/cjs/scrollbar/scrollbar.js +21 -12
- package/cjs/scrollbar/scrollbar.js.map +1 -1
- package/cjs/slider/slider.d.ts +3 -0
- package/cjs/slider/slider.js +48 -27
- package/cjs/slider/slider.js.map +1 -1
- package/cjs/switch/switch.js +2 -2
- package/cjs/switch/switch.js.map +1 -1
- package/cjs/tag/tag.js +60 -56
- package/cjs/tag/tag.js.map +1 -1
- package/cjs/util/event.d.ts +1 -0
- package/cjs/util/event.js +14 -0
- package/cjs/util/event.js.map +1 -0
- package/cjs/weather/weather-box.d.ts +1 -2
- package/cjs/weather/weather-box.js.map +1 -1
- package/dist/index.es.js +14149 -12832
- package/es/animation/animate-component.d.ts +22 -0
- package/es/animation/animate-component.js +21 -0
- package/es/animation/animate-component.js.map +1 -0
- package/es/animation/axis-animate.d.ts +10 -0
- package/es/animation/axis-animate.js +60 -0
- package/es/animation/axis-animate.js.map +1 -0
- package/es/animation/label-animate.d.ts +10 -0
- package/es/animation/label-animate.js +69 -0
- package/es/animation/label-animate.js.map +1 -0
- package/es/axis/animate/config.d.ts +6 -0
- package/es/axis/animate/config.js +6 -0
- package/es/axis/animate/config.js.map +1 -0
- package/es/axis/animate/group-transition.d.ts +2 -1
- package/es/axis/animate/group-transition.js +3 -1
- package/es/axis/animate/group-transition.js.map +1 -1
- package/es/axis/base.d.ts +9 -4
- package/es/axis/base.js +75 -9
- package/es/axis/base.js.map +1 -1
- package/es/axis/line.js.map +1 -1
- package/es/axis/register.js +3 -1
- package/es/axis/register.js.map +1 -1
- package/es/axis/type.d.ts +4 -0
- package/es/axis/type.js.map +1 -1
- package/es/axis/util.js +5 -6
- package/es/axis/util.js.map +1 -1
- package/es/brush/brush.d.ts +16 -10
- package/es/brush/brush.js +83 -95
- package/es/brush/brush.js.map +1 -1
- package/es/brush/config.d.ts +5 -5
- package/es/brush/config.js +6 -7
- package/es/brush/config.js.map +1 -1
- package/es/brush/type.d.ts +1 -0
- package/es/brush/type.js +3 -2
- package/es/brush/type.js.map +1 -1
- package/es/crosshair/rect.js +1 -2
- package/es/crosshair/type.js +2 -1
- package/es/data-zoom/data-zoom.d.ts +3 -0
- package/es/data-zoom/data-zoom.js +35 -16
- package/es/data-zoom/data-zoom.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/indicator/register.js +1 -2
- package/es/jsx/index.js +2 -1
- package/es/label/animate/animate.d.ts +1 -12
- package/es/label/animate/animate.js +0 -76
- package/es/label/animate/animate.js.map +1 -1
- package/es/label/base.d.ts +5 -3
- package/es/label/base.js +63 -35
- package/es/label/base.js.map +1 -1
- package/es/label/dataLabel.js +1 -1
- package/es/label/overlap/scaler.js +1 -1
- package/es/label/overlap/scaler.js.map +1 -1
- package/es/label/register.d.ts +1 -0
- package/es/label/register.js +7 -1
- package/es/label/register.js.map +1 -1
- package/es/label-item/index.js +1 -1
- package/es/label-item/label-item.js +1 -1
- package/es/label-item/label-item.js.map +1 -1
- package/es/label-item/register.js +1 -1
- package/es/label-item/type.js +1 -1
- package/es/marker/animate/animate.d.ts +3 -3
- package/es/marker/animate/animate.js.map +1 -1
- package/es/marker/animate/clip-in.d.ts +1 -1
- package/es/marker/animate/clip-in.js +6 -2
- package/es/marker/animate/clip-in.js.map +1 -1
- package/es/marker/animate/fade-in.d.ts +3 -3
- package/es/marker/animate/fade-in.js +11 -3
- package/es/marker/animate/fade-in.js.map +1 -1
- package/es/marker/animate/fade-out.d.ts +3 -3
- package/es/marker/animate/fade-out.js +11 -3
- package/es/marker/animate/fade-out.js.map +1 -1
- package/es/marker/arc-area.d.ts +8 -5
- package/es/marker/arc-area.js +19 -41
- package/es/marker/arc-area.js.map +1 -1
- package/es/marker/arc-line.d.ts +6 -4
- package/es/marker/arc-line.js +12 -9
- package/es/marker/arc-line.js.map +1 -1
- package/es/marker/area.d.ts +6 -4
- package/es/marker/area.js +15 -34
- package/es/marker/area.js.map +1 -1
- package/es/marker/base.d.ts +2 -3
- package/es/marker/base.js.map +1 -1
- package/es/marker/common-line.d.ts +11 -7
- package/es/marker/common-line.js +14 -34
- package/es/marker/common-line.js.map +1 -1
- package/es/marker/config.d.ts +2 -0
- package/es/marker/config.js +2 -0
- package/es/marker/config.js.map +1 -1
- package/es/marker/line.d.ts +6 -4
- package/es/marker/line.js +10 -4
- package/es/marker/line.js.map +1 -1
- package/es/marker/mixin/label.d.ts +16 -0
- package/es/marker/mixin/label.js +45 -0
- package/es/marker/mixin/label.js.map +1 -0
- package/es/marker/type.d.ts +19 -16
- package/es/marker/type.js.map +1 -1
- package/es/poptip/contribution.js +4 -2
- package/es/poptip/contribution.js.map +1 -1
- package/es/poptip/poptip.d.ts +5 -0
- package/es/poptip/poptip.js +85 -19
- package/es/poptip/poptip.js.map +1 -1
- package/es/poptip/type.d.ts +4 -1
- package/es/poptip/type.js.map +1 -1
- package/es/scrollbar/scrollbar.d.ts +1 -0
- package/es/scrollbar/scrollbar.js +22 -11
- package/es/scrollbar/scrollbar.js.map +1 -1
- package/es/slider/slider.d.ts +3 -0
- package/es/slider/slider.js +49 -26
- package/es/slider/slider.js.map +1 -1
- package/es/switch/switch.js +2 -2
- package/es/switch/switch.js.map +1 -1
- package/es/tag/tag.js +59 -56
- package/es/tag/tag.js.map +1 -1
- package/es/util/event.d.ts +1 -0
- package/es/util/event.js +6 -0
- package/es/util/event.js.map +1 -0
- package/es/weather/weather-box.d.ts +1 -2
- package/es/weather/weather-box.js.map +1 -1
- package/package.json +7 -7
|
@@ -1,79 +1,3 @@
|
|
|
1
|
-
import { IncreaseCount } from "@visactor/vrender-animate";
|
|
2
|
-
|
|
3
|
-
import { array, isArray, isEmpty, isValidNumber } from "@visactor/vutils";
|
|
4
|
-
|
|
5
|
-
const fadeIn = (textAttribute = {}) => {
|
|
6
|
-
var _a, _b, _c;
|
|
7
|
-
return {
|
|
8
|
-
from: {
|
|
9
|
-
opacity: 0,
|
|
10
|
-
fillOpacity: 0,
|
|
11
|
-
strokeOpacity: 0
|
|
12
|
-
},
|
|
13
|
-
to: {
|
|
14
|
-
opacity: null !== (_a = textAttribute.opacity) && void 0 !== _a ? _a : 1,
|
|
15
|
-
fillOpacity: null !== (_b = textAttribute.fillOpacity) && void 0 !== _b ? _b : 1,
|
|
16
|
-
strokeOpacity: null !== (_c = textAttribute.strokeOpacity) && void 0 !== _c ? _c : 1
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
}, fadeOut = (textAttribute = {}) => {
|
|
20
|
-
var _a, _b, _c;
|
|
21
|
-
return {
|
|
22
|
-
from: {
|
|
23
|
-
opacity: null !== (_a = textAttribute.opacity) && void 0 !== _a ? _a : 1,
|
|
24
|
-
fillOpacity: null !== (_b = textAttribute.fillOpacity) && void 0 !== _b ? _b : 1,
|
|
25
|
-
strokeOpacity: null !== (_c = textAttribute.strokeOpacity) && void 0 !== _c ? _c : 1
|
|
26
|
-
},
|
|
27
|
-
to: {
|
|
28
|
-
opacity: 0,
|
|
29
|
-
fillOpacity: 0,
|
|
30
|
-
strokeOpacity: 0
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
}, animationEffects = {
|
|
34
|
-
fadeIn: fadeIn,
|
|
35
|
-
fadeOut: fadeOut
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export function getAnimationAttributes(textAttribute, type) {
|
|
39
|
-
var _a, _b;
|
|
40
|
-
return null !== (_b = null === (_a = animationEffects[type]) || void 0 === _a ? void 0 : _a.call(animationEffects, textAttribute)) && void 0 !== _b ? _b : {
|
|
41
|
-
from: {},
|
|
42
|
-
to: {}
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function updateAnimation(prev, next, animationConfig) {
|
|
47
|
-
if (!isArray(animationConfig)) {
|
|
48
|
-
const {duration: duration, easing: easing, increaseEffect: increaseEffect = !0} = animationConfig;
|
|
49
|
-
return prev.animate().to(next.attribute, duration, easing), void (increaseEffect && "text" === prev.type && "text" === next.type && playIncreaseCount(prev, next, duration, easing));
|
|
50
|
-
}
|
|
51
|
-
animationConfig.forEach((cfg => {
|
|
52
|
-
const {duration: duration, easing: easing, increaseEffect: increaseEffect = !0, channel: channel} = cfg, {to: to} = update(prev, next, channel, cfg.options);
|
|
53
|
-
isEmpty(to) || prev.animate().to(to, duration, easing), increaseEffect && "text" === prev.type && "text" === next.type && playIncreaseCount(prev, next, duration, easing);
|
|
54
|
-
}));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export const update = (prev, next, channel, options) => {
|
|
58
|
-
const from = Object.assign({}, prev.attribute), to = Object.assign({}, next.attribute);
|
|
59
|
-
return array(null == options ? void 0 : options.excludeChannels).forEach((key => {
|
|
60
|
-
delete to[key];
|
|
61
|
-
})), Object.keys(to).forEach((key => {
|
|
62
|
-
channel && !channel.includes(key) && delete to[key];
|
|
63
|
-
})), {
|
|
64
|
-
from: from,
|
|
65
|
-
to: to
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export function playIncreaseCount(prev, next, duration, easing) {
|
|
70
|
-
prev.attribute.text !== next.attribute.text && isValidNumber(Number(prev.attribute.text) * Number(next.attribute.text)) && prev.animate().play(new IncreaseCount({
|
|
71
|
-
text: prev.attribute.text
|
|
72
|
-
}, {
|
|
73
|
-
text: next.attribute.text
|
|
74
|
-
}, duration, easing));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
1
|
export const DefaultLabelAnimation = {
|
|
78
2
|
mode: "same-time",
|
|
79
3
|
duration: 300,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/label/animate/animate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/label/animate/animate.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,qBAAqB,GAAoB;IACpD,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,GAAG;IACb,MAAM,EAAE,QAAsB;CAC/B,CAAC","file":"animate.js","sourcesContent":["import type { EasingType } from '@visactor/vrender-core';\nimport type { ILabelAnimation } from '../type';\n\nexport const DefaultLabelAnimation: ILabelAnimation = {\n mode: 'same-time',\n duration: 300,\n easing: 'linear' as EasingType\n};\n"]}
|
package/es/label/base.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { IGroup, IGraphic, IText, ILine, IRichText } from '@visactor/vrender-core';
|
|
2
2
|
import type { IAABBBounds, IBoundsLike, IPointLike } from '@visactor/vutils';
|
|
3
|
-
import { AbstractComponent } from '../core/base';
|
|
4
3
|
import type { PointLocationCfg } from '../core/type';
|
|
5
4
|
import type { Bitmap, BitmapTool } from './overlap';
|
|
6
5
|
import { bitmapTool } from './overlap';
|
|
7
6
|
import type { BaseLabelAttrs, OverlapAttrs, LabelItem, ILabelEnterAnimation, ILabelExitAnimation, ILabelUpdateAnimation, LabelContent } from './type';
|
|
8
7
|
import type { ComponentOptions } from '../interface';
|
|
9
|
-
|
|
8
|
+
import { AnimateComponent } from '../animation/animate-component';
|
|
9
|
+
export declare class LabelBase<T extends BaseLabelAttrs> extends AnimateComponent<T> {
|
|
10
10
|
name: string;
|
|
11
11
|
protected _baseMarks?: IGraphic[];
|
|
12
12
|
protected _isCollectionBase: boolean;
|
|
@@ -52,11 +52,13 @@ export declare class LabelBase<T extends BaseLabelAttrs> extends AbstractCompone
|
|
|
52
52
|
protected _overlapGlobal(labels: (IText | IRichText)[], option: OverlapAttrs, bmpTool: BitmapTool, bitmap: Bitmap): (IRichText | IText)[];
|
|
53
53
|
protected _processClampForce(text: IText, bmpTool: BitmapTool, bitmap: Bitmap, overlapPadding?: number): boolean;
|
|
54
54
|
protected _overlapByStrategy(labels: (IText | IRichText)[], option: OverlapAttrs, bmpTool: BitmapTool, bitmap: Bitmap): (IRichText | IText)[];
|
|
55
|
+
protected isMarkInsideRect(baseMark: IGraphic, bmpTool: BitmapTool): boolean;
|
|
55
56
|
protected getBaseMarkGroup(): IGroup;
|
|
56
57
|
protected getGraphicBounds(graphic?: IGraphic, point?: Partial<PointLocationCfg>, position?: string): IBoundsLike;
|
|
57
58
|
protected _renderLabels(labels: (IText | IRichText)[]): void;
|
|
58
|
-
protected runEnterAnimation(text: IText | IRichText): void;
|
|
59
|
+
protected runEnterAnimation(text: IText | IRichText, labelLine?: ILine): void;
|
|
59
60
|
protected _runUpdateAnimation(prevLabel: LabelContent, currentLabel: LabelContent): void;
|
|
61
|
+
protected _syncStateWithRelatedGraphic(relatedGraphic: IGraphic): void;
|
|
60
62
|
protected _addLabel(label: LabelContent, texts?: LabelContent['text'][], labelLines?: LabelContent['labelLine'][], index?: number): void;
|
|
61
63
|
protected _updateLabel(prevLabel: LabelContent, currentLabel: LabelContent): void;
|
|
62
64
|
protected _removeLabel(textMap: Map<any, LabelContent>): void;
|
package/es/label/base.js
CHANGED
|
@@ -10,9 +10,7 @@ var __rest = this && this.__rest || function(s, e) {
|
|
|
10
10
|
|
|
11
11
|
import { graphicCreator, AttributeUpdateType, CustomPath2D } from "@visactor/vrender-core";
|
|
12
12
|
|
|
13
|
-
import { isFunction, isEmpty, isValid, isString, merge, isRectIntersect, isNil, isArray, isObject } from "@visactor/vutils";
|
|
14
|
-
|
|
15
|
-
import { AbstractComponent } from "../core/base";
|
|
13
|
+
import { isFunction, isEmpty, isValid, isString, merge, isRectIntersect, isNil, isArray, isObject, pointInRect } from "@visactor/vutils";
|
|
16
14
|
|
|
17
15
|
import { labelSmartInvert, contrastAccessibilityChecker, smartInvertStrategy } from "../util/label-smartInvert";
|
|
18
16
|
|
|
@@ -30,9 +28,11 @@ import { loadLabelComponent } from "./register";
|
|
|
30
28
|
|
|
31
29
|
import { shiftY } from "./overlap/shiftY";
|
|
32
30
|
|
|
31
|
+
import { AnimateComponent } from "../animation/animate-component";
|
|
32
|
+
|
|
33
33
|
loadLabelComponent();
|
|
34
34
|
|
|
35
|
-
export class LabelBase extends
|
|
35
|
+
export class LabelBase extends AnimateComponent {
|
|
36
36
|
setBitmap(bitmap) {
|
|
37
37
|
this._bitmap = bitmap;
|
|
38
38
|
}
|
|
@@ -95,6 +95,10 @@ export class LabelBase extends AbstractComponent {
|
|
|
95
95
|
}
|
|
96
96
|
render() {
|
|
97
97
|
if (this._prepare(), isNil(this._idToGraphic) || this._isCollectionBase && isNil(this._idToPoint)) return;
|
|
98
|
+
const markAttributeList = [];
|
|
99
|
+
!1 !== this._enableAnimation && this._baseMarks.forEach((mark => {
|
|
100
|
+
markAttributeList.push(mark.attribute), mark.initAttributes(mark.getAttributes(!0));
|
|
101
|
+
}));
|
|
98
102
|
const {overlap: overlap, smartInvert: smartInvert, dataFilter: dataFilter, customLayoutFunc: customLayoutFunc, customOverlapFunc: customOverlapFunc} = this.attribute;
|
|
99
103
|
let data = this.attribute.data;
|
|
100
104
|
if (isFunction(dataFilter) && (data = dataFilter(data)), data && data.length) {
|
|
@@ -107,7 +111,10 @@ export class LabelBase extends AbstractComponent {
|
|
|
107
111
|
isFunction(this.attribute.onAfterOverlapping) && this.attribute.onAfterOverlapping(labels, this.getRelatedGraphic.bind(this), this._isCollectionBase ? d => this._idToPoint.get(d.id) : null, this),
|
|
108
112
|
labels && labels.length && labels.forEach((label => {
|
|
109
113
|
this._bindEvent(label), this._setStatesOfText(label);
|
|
110
|
-
})), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels)
|
|
114
|
+
})), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels),
|
|
115
|
+
!1 !== this._enableAnimation && this._baseMarks.forEach(((mark, index) => {
|
|
116
|
+
mark.initAttributes(markAttributeList[index]);
|
|
117
|
+
}));
|
|
111
118
|
}
|
|
112
119
|
_bindEvent(target) {
|
|
113
120
|
if (this.attribute.disableTriggerEvent) return;
|
|
@@ -160,18 +167,7 @@ export class LabelBase extends AbstractComponent {
|
|
|
160
167
|
textData && baseMark && (isValid(textData.id) || (textData.id = `vrender-component-${this.name}-${i}`),
|
|
161
168
|
this._idToGraphic.set(textData.id, baseMark));
|
|
162
169
|
}
|
|
163
|
-
|
|
164
|
-
const {animation: animation, animationEnter: animationEnter, animationExit: animationExit, animationUpdate: animationUpdate} = this.attribute, animationCfg = isObject(animation) ? animation : {};
|
|
165
|
-
this._animationConfig = {
|
|
166
|
-
enter: !1 !== animationEnter && merge({}, DefaultLabelAnimation, animationCfg, null != animationEnter ? animationEnter : {}),
|
|
167
|
-
exit: !1 !== animationExit && merge({}, DefaultLabelAnimation, animationCfg, null != animationExit ? animationExit : {}),
|
|
168
|
-
update: !1 !== animationUpdate && (isArray(animationUpdate) ? animationUpdate : merge({}, DefaultLabelAnimation, animationCfg, null != animationUpdate ? animationUpdate : {}))
|
|
169
|
-
};
|
|
170
|
-
} else this._animationConfig = {
|
|
171
|
-
enter: !1,
|
|
172
|
-
exit: !1,
|
|
173
|
-
update: !1
|
|
174
|
-
};
|
|
170
|
+
this._prepareAnimate(DefaultLabelAnimation);
|
|
175
171
|
}
|
|
176
172
|
}
|
|
177
173
|
getRelatedGraphic(item) {
|
|
@@ -220,7 +216,7 @@ export class LabelBase extends AbstractComponent {
|
|
|
220
216
|
"shiftY" === (null == strategy ? void 0 : strategy.type) ? this._overlapGlobal(labels, option, bmpTool, bitmap) : this._overlapByStrategy(labels, option, bmpTool, bitmap);
|
|
221
217
|
}
|
|
222
218
|
_overlapGlobal(labels, option, bmpTool, bitmap) {
|
|
223
|
-
let result = labels.filter((label => label.attribute.visible && 0 !== label.attribute.opacity));
|
|
219
|
+
let result = labels.filter((label => label.attribute.visible && 0 !== label.attribute.opacity && this.isMarkInsideRect(this.getRelatedGraphic(label.attribute), bmpTool)));
|
|
224
220
|
const {clampForce: clampForce = !0, hideOnHit: hideOnHit = !0, overlapPadding: overlapPadding, strategy: strategy} = option;
|
|
225
221
|
if (clampForce) for (let i = 0; i < result.length; i++) {
|
|
226
222
|
const text = labels[i], {dx: dx = 0, dy: dy = 0} = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
|
|
@@ -279,12 +275,7 @@ export class LabelBase extends AbstractComponent {
|
|
|
279
275
|
for (let i = 0; i < labels.length; i++) {
|
|
280
276
|
if (!1 === labels[i].attribute.visible) continue;
|
|
281
277
|
const text = labels[i], baseMark = this.getRelatedGraphic(text.attribute);
|
|
282
|
-
if (text.update(), !
|
|
283
|
-
x1: 0,
|
|
284
|
-
x2: bmpTool.width,
|
|
285
|
-
y1: 0,
|
|
286
|
-
y2: bmpTool.height
|
|
287
|
-
}, !0)) continue;
|
|
278
|
+
if (text.update(), !this.isMarkInsideRect(baseMark, bmpTool)) continue;
|
|
288
279
|
if (canPlace(bmpTool, bitmap, text.AABBBounds, clampForce, overlapPadding)) {
|
|
289
280
|
if (!checkBounds) {
|
|
290
281
|
bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(text);
|
|
@@ -314,13 +305,41 @@ export class LabelBase extends AbstractComponent {
|
|
|
314
305
|
}
|
|
315
306
|
return result;
|
|
316
307
|
}
|
|
308
|
+
isMarkInsideRect(baseMark, bmpTool) {
|
|
309
|
+
const {left: left, right: right, top: top, bottom: bottom} = bmpTool.padding, rect = {
|
|
310
|
+
x1: -left,
|
|
311
|
+
x2: bmpTool.width + right,
|
|
312
|
+
y1: -top,
|
|
313
|
+
y2: bmpTool.height + bottom
|
|
314
|
+
}, bounds = baseMark.AABBBounds;
|
|
315
|
+
if (0 !== bounds.width() && 0 !== bounds.height()) return isRectIntersect(baseMark.AABBBounds, rect, !0);
|
|
316
|
+
const {attribute: attribute} = baseMark;
|
|
317
|
+
if ("rect" === baseMark.type) {
|
|
318
|
+
const {x: x, x1: x1, y: y, y1: y1} = attribute;
|
|
319
|
+
return pointInRect({
|
|
320
|
+
x: null != x ? x : x1,
|
|
321
|
+
y: null != y ? y : y1
|
|
322
|
+
}, rect, !0);
|
|
323
|
+
}
|
|
324
|
+
return "x" in attribute && "y" in attribute && pointInRect({
|
|
325
|
+
x: attribute.x,
|
|
326
|
+
y: attribute.y
|
|
327
|
+
}, rect, !0);
|
|
328
|
+
}
|
|
317
329
|
getBaseMarkGroup() {
|
|
318
330
|
const {baseMarkGroupName: baseMarkGroupName} = this.attribute;
|
|
319
331
|
if (baseMarkGroupName) return this.getRootNode().find((node => node.name === baseMarkGroupName), !0);
|
|
320
332
|
}
|
|
321
333
|
getGraphicBounds(graphic, point = {}, position) {
|
|
334
|
+
var _a;
|
|
322
335
|
if (graphic) {
|
|
323
|
-
if (!1 !== graphic.attribute.visible)
|
|
336
|
+
if (!1 !== graphic.attribute.visible) {
|
|
337
|
+
if (null === (_a = graphic.context) || void 0 === _a ? void 0 : _a.animationState) {
|
|
338
|
+
const clonedGraphic = graphic.clone();
|
|
339
|
+
return Object.assign(clonedGraphic.attribute, graphic.getAttributes(!0)), clonedGraphic.AABBBounds;
|
|
340
|
+
}
|
|
341
|
+
return graphic.AABBBounds;
|
|
342
|
+
}
|
|
324
343
|
const {x: x, y: y} = graphic.attribute;
|
|
325
344
|
return {
|
|
326
345
|
x1: x,
|
|
@@ -377,18 +396,23 @@ export class LabelBase extends AbstractComponent {
|
|
|
377
396
|
}
|
|
378
397
|
})), this._removeLabel(prevTextMap), this._graphicToText = currentTextMap;
|
|
379
398
|
}
|
|
380
|
-
runEnterAnimation(text) {
|
|
399
|
+
runEnterAnimation(text, labelLine) {
|
|
381
400
|
if (!1 === this._enableAnimation || !this._animationConfig.enter) return;
|
|
382
401
|
const relatedGraphic = this.getRelatedGraphic(text.attribute), {enter: enter} = this._animationConfig;
|
|
383
|
-
text.applyAnimationState([ "enter" ], [ {
|
|
402
|
+
[ text, labelLine ].filter(Boolean).forEach((item => item.applyAnimationState([ "enter" ], [ {
|
|
384
403
|
name: "enter",
|
|
385
404
|
animation: Object.assign(Object.assign({}, enter), {
|
|
405
|
+
type: "labelEnter",
|
|
386
406
|
selfOnly: !0,
|
|
387
407
|
customParameters: {
|
|
388
|
-
relatedGraphic: relatedGraphic
|
|
408
|
+
relatedGraphic: relatedGraphic,
|
|
409
|
+
relatedGraphics: this._idToGraphic,
|
|
410
|
+
config: Object.assign(Object.assign({}, enter), {
|
|
411
|
+
type: item === text ? enter.type : "fadeIn"
|
|
412
|
+
})
|
|
389
413
|
}
|
|
390
414
|
})
|
|
391
|
-
} ]);
|
|
415
|
+
} ])));
|
|
392
416
|
}
|
|
393
417
|
_runUpdateAnimation(prevLabel, currentLabel) {
|
|
394
418
|
if (!1 === this._enableAnimation || !this._animationConfig.update) return;
|
|
@@ -408,9 +432,13 @@ export class LabelBase extends AbstractComponent {
|
|
|
408
432
|
}
|
|
409
433
|
} ]);
|
|
410
434
|
}
|
|
435
|
+
_syncStateWithRelatedGraphic(relatedGraphic) {
|
|
436
|
+
this.attribute.syncState && relatedGraphic && relatedGraphic.on("afterStateUpdate", this._handleRelatedGraphicSetState);
|
|
437
|
+
}
|
|
411
438
|
_addLabel(label, texts, labelLines, index) {
|
|
412
|
-
const {text: text, labelLine: labelLine} = label;
|
|
413
|
-
text && this.add(text), labelLine && this.add(labelLine),
|
|
439
|
+
const {text: text, labelLine: labelLine} = label, relatedGraphic = this.getRelatedGraphic(text.attribute);
|
|
440
|
+
this._syncStateWithRelatedGraphic(relatedGraphic), text && this.add(text), labelLine && this.add(labelLine),
|
|
441
|
+
this.runEnterAnimation(text, labelLine);
|
|
414
442
|
}
|
|
415
443
|
_updateLabel(prevLabel, currentLabel) {
|
|
416
444
|
const {text: prevText, labelLine: prevLabelLine} = prevLabel, {text: curText, labelLine: curLabelLine} = currentLabel;
|
|
@@ -425,16 +453,16 @@ export class LabelBase extends AbstractComponent {
|
|
|
425
453
|
var _a;
|
|
426
454
|
label.text.applyAnimationState([ "exit" ], [ {
|
|
427
455
|
name: "exit",
|
|
428
|
-
animation: Object.assign({
|
|
456
|
+
animation: Object.assign(Object.assign({}, this._animationConfig.exit), {
|
|
429
457
|
type: "fadeOut"
|
|
430
|
-
}
|
|
458
|
+
})
|
|
431
459
|
} ], (() => {
|
|
432
460
|
removeLabelAndLine(label);
|
|
433
461
|
})), null === (_a = label.labelLine) || void 0 === _a || _a.applyAnimationState([ "exit" ], [ {
|
|
434
462
|
name: "exit",
|
|
435
|
-
animation: Object.assign({
|
|
463
|
+
animation: Object.assign(Object.assign({}, this._animationConfig.exit), {
|
|
436
464
|
type: "fadeOut"
|
|
437
|
-
}
|
|
465
|
+
})
|
|
438
466
|
} ], (() => {}));
|
|
439
467
|
})) : textMap.forEach((label => {
|
|
440
468
|
removeLabelAndLine(label);
|