@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,13 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ILabelAnimation, ILabelUpdateAnimation, ILabelUpdateChannelAnimation, LabelContent } from '../type';
|
|
3
|
-
export declare function getAnimationAttributes(textAttribute: ITextGraphicAttribute, type: 'fadeIn' | 'fadeOut'): {
|
|
4
|
-
from: any;
|
|
5
|
-
to: any;
|
|
6
|
-
};
|
|
7
|
-
export declare function updateAnimation(prev: LabelContent['text'], next: LabelContent['text'], animationConfig: ILabelUpdateAnimation | ILabelUpdateChannelAnimation[]): void;
|
|
8
|
-
export declare const update: (prev: LabelContent['text'], next: LabelContent['text'], channel?: string[], options?: ILabelUpdateChannelAnimation['options']) => {
|
|
9
|
-
from: Partial<ITextGraphicAttribute> | Partial<import("@visactor/vrender-core").IRichTextGraphicAttribute>;
|
|
10
|
-
to: Partial<ITextGraphicAttribute> | Partial<import("@visactor/vrender-core").IRichTextGraphicAttribute>;
|
|
11
|
-
};
|
|
12
|
-
export declare function playIncreaseCount(prev: IText, next: IText, duration: number, easing: EasingType): void;
|
|
1
|
+
import type { ILabelAnimation } from '../type';
|
|
13
2
|
export declare const DefaultLabelAnimation: ILabelAnimation;
|
|
@@ -2,84 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: !0
|
|
5
|
-
}), exports.DefaultLabelAnimation =
|
|
6
|
-
|
|
7
|
-
const vrender_animate_1 = require("@visactor/vrender-animate"), vutils_1 = require("@visactor/vutils"), fadeIn = (textAttribute = {}) => {
|
|
8
|
-
var _a, _b, _c;
|
|
9
|
-
return {
|
|
10
|
-
from: {
|
|
11
|
-
opacity: 0,
|
|
12
|
-
fillOpacity: 0,
|
|
13
|
-
strokeOpacity: 0
|
|
14
|
-
},
|
|
15
|
-
to: {
|
|
16
|
-
opacity: null !== (_a = textAttribute.opacity) && void 0 !== _a ? _a : 1,
|
|
17
|
-
fillOpacity: null !== (_b = textAttribute.fillOpacity) && void 0 !== _b ? _b : 1,
|
|
18
|
-
strokeOpacity: null !== (_c = textAttribute.strokeOpacity) && void 0 !== _c ? _c : 1
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
}, fadeOut = (textAttribute = {}) => {
|
|
22
|
-
var _a, _b, _c;
|
|
23
|
-
return {
|
|
24
|
-
from: {
|
|
25
|
-
opacity: null !== (_a = textAttribute.opacity) && void 0 !== _a ? _a : 1,
|
|
26
|
-
fillOpacity: null !== (_b = textAttribute.fillOpacity) && void 0 !== _b ? _b : 1,
|
|
27
|
-
strokeOpacity: null !== (_c = textAttribute.strokeOpacity) && void 0 !== _c ? _c : 1
|
|
28
|
-
},
|
|
29
|
-
to: {
|
|
30
|
-
opacity: 0,
|
|
31
|
-
fillOpacity: 0,
|
|
32
|
-
strokeOpacity: 0
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}, animationEffects = {
|
|
36
|
-
fadeIn: fadeIn,
|
|
37
|
-
fadeOut: fadeOut
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
function getAnimationAttributes(textAttribute, type) {
|
|
41
|
-
var _a, _b;
|
|
42
|
-
return null !== (_b = null === (_a = animationEffects[type]) || void 0 === _a ? void 0 : _a.call(animationEffects, textAttribute)) && void 0 !== _b ? _b : {
|
|
43
|
-
from: {},
|
|
44
|
-
to: {}
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function updateAnimation(prev, next, animationConfig) {
|
|
49
|
-
if (!(0, vutils_1.isArray)(animationConfig)) {
|
|
50
|
-
const {duration: duration, easing: easing, increaseEffect: increaseEffect = !0} = animationConfig;
|
|
51
|
-
return prev.animate().to(next.attribute, duration, easing), void (increaseEffect && "text" === prev.type && "text" === next.type && playIncreaseCount(prev, next, duration, easing));
|
|
52
|
-
}
|
|
53
|
-
animationConfig.forEach((cfg => {
|
|
54
|
-
const {duration: duration, easing: easing, increaseEffect: increaseEffect = !0, channel: channel} = cfg, {to: to} = (0,
|
|
55
|
-
exports.update)(prev, next, channel, cfg.options);
|
|
56
|
-
(0, vutils_1.isEmpty)(to) || prev.animate().to(to, duration, easing), increaseEffect && "text" === prev.type && "text" === next.type && playIncreaseCount(prev, next, duration, easing);
|
|
57
|
-
}));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
exports.getAnimationAttributes = getAnimationAttributes, exports.updateAnimation = updateAnimation;
|
|
61
|
-
|
|
62
|
-
const update = (prev, next, channel, options) => {
|
|
63
|
-
const from = Object.assign({}, prev.attribute), to = Object.assign({}, next.attribute);
|
|
64
|
-
return (0, vutils_1.array)(null == options ? void 0 : options.excludeChannels).forEach((key => {
|
|
65
|
-
delete to[key];
|
|
66
|
-
})), Object.keys(to).forEach((key => {
|
|
67
|
-
channel && !channel.includes(key) && delete to[key];
|
|
68
|
-
})), {
|
|
69
|
-
from: from,
|
|
70
|
-
to: to
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
function playIncreaseCount(prev, next, duration, easing) {
|
|
75
|
-
prev.attribute.text !== next.attribute.text && (0, vutils_1.isValidNumber)(Number(prev.attribute.text) * Number(next.attribute.text)) && prev.animate().play(new vrender_animate_1.IncreaseCount({
|
|
76
|
-
text: prev.attribute.text
|
|
77
|
-
}, {
|
|
78
|
-
text: next.attribute.text
|
|
79
|
-
}, duration, easing));
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
exports.update = update, exports.playIncreaseCount = playIncreaseCount, exports.DefaultLabelAnimation = {
|
|
5
|
+
}), exports.DefaultLabelAnimation = void 0, exports.DefaultLabelAnimation = {
|
|
83
6
|
mode: "same-time",
|
|
84
7
|
duration: 300,
|
|
85
8
|
easing: "linear"
|
|
@@ -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,QAAA,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/cjs/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/cjs/label/base.js
CHANGED
|
@@ -14,11 +14,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
14
14
|
value: !0
|
|
15
15
|
}), exports.LabelBase = void 0;
|
|
16
16
|
|
|
17
|
-
const vrender_core_1 = require("@visactor/vrender-core"), vutils_1 = require("@visactor/vutils"),
|
|
17
|
+
const vrender_core_1 = require("@visactor/vrender-core"), vutils_1 = require("@visactor/vutils"), label_smartInvert_1 = require("../util/label-smartInvert"), util_1 = require("../util"), constant_1 = require("../constant"), overlap_1 = require("./overlap"), animate_1 = require("./animate/animate"), util_2 = require("./util"), register_1 = require("./register"), shiftY_1 = require("./overlap/shiftY"), animate_component_1 = require("../animation/animate-component");
|
|
18
18
|
|
|
19
19
|
(0, register_1.loadLabelComponent)();
|
|
20
20
|
|
|
21
|
-
class LabelBase extends
|
|
21
|
+
class LabelBase extends animate_component_1.AnimateComponent {
|
|
22
22
|
setBitmap(bitmap) {
|
|
23
23
|
this._bitmap = bitmap;
|
|
24
24
|
}
|
|
@@ -85,6 +85,10 @@ class LabelBase extends base_1.AbstractComponent {
|
|
|
85
85
|
render() {
|
|
86
86
|
if (this._prepare(), (0, vutils_1.isNil)(this._idToGraphic) || this._isCollectionBase && (0,
|
|
87
87
|
vutils_1.isNil)(this._idToPoint)) return;
|
|
88
|
+
const markAttributeList = [];
|
|
89
|
+
!1 !== this._enableAnimation && this._baseMarks.forEach((mark => {
|
|
90
|
+
markAttributeList.push(mark.attribute), mark.initAttributes(mark.getAttributes(!0));
|
|
91
|
+
}));
|
|
88
92
|
const {overlap: overlap, smartInvert: smartInvert, dataFilter: dataFilter, customLayoutFunc: customLayoutFunc, customOverlapFunc: customOverlapFunc} = this.attribute;
|
|
89
93
|
let data = this.attribute.data;
|
|
90
94
|
if ((0, vutils_1.isFunction)(dataFilter) && (data = dataFilter(data)), data && data.length) {
|
|
@@ -97,7 +101,10 @@ class LabelBase extends base_1.AbstractComponent {
|
|
|
97
101
|
(0, vutils_1.isFunction)(this.attribute.onAfterOverlapping) && this.attribute.onAfterOverlapping(labels, this.getRelatedGraphic.bind(this), this._isCollectionBase ? d => this._idToPoint.get(d.id) : null, this),
|
|
98
102
|
labels && labels.length && labels.forEach((label => {
|
|
99
103
|
this._bindEvent(label), this._setStatesOfText(label);
|
|
100
|
-
})), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels)
|
|
104
|
+
})), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels),
|
|
105
|
+
!1 !== this._enableAnimation && this._baseMarks.forEach(((mark, index) => {
|
|
106
|
+
mark.initAttributes(markAttributeList[index]);
|
|
107
|
+
}));
|
|
101
108
|
}
|
|
102
109
|
_bindEvent(target) {
|
|
103
110
|
if (this.attribute.disableTriggerEvent) return;
|
|
@@ -150,20 +157,7 @@ class LabelBase extends base_1.AbstractComponent {
|
|
|
150
157
|
textData && baseMark && ((0, vutils_1.isValid)(textData.id) || (textData.id = `vrender-component-${this.name}-${i}`),
|
|
151
158
|
this._idToGraphic.set(textData.id, baseMark));
|
|
152
159
|
}
|
|
153
|
-
|
|
154
|
-
const {animation: animation, animationEnter: animationEnter, animationExit: animationExit, animationUpdate: animationUpdate} = this.attribute, animationCfg = (0,
|
|
155
|
-
vutils_1.isObject)(animation) ? animation : {};
|
|
156
|
-
this._animationConfig = {
|
|
157
|
-
enter: !1 !== animationEnter && (0, vutils_1.merge)({}, animate_1.DefaultLabelAnimation, animationCfg, null != animationEnter ? animationEnter : {}),
|
|
158
|
-
exit: !1 !== animationExit && (0, vutils_1.merge)({}, animate_1.DefaultLabelAnimation, animationCfg, null != animationExit ? animationExit : {}),
|
|
159
|
-
update: !1 !== animationUpdate && ((0, vutils_1.isArray)(animationUpdate) ? animationUpdate : (0,
|
|
160
|
-
vutils_1.merge)({}, animate_1.DefaultLabelAnimation, animationCfg, null != animationUpdate ? animationUpdate : {}))
|
|
161
|
-
};
|
|
162
|
-
} else this._animationConfig = {
|
|
163
|
-
enter: !1,
|
|
164
|
-
exit: !1,
|
|
165
|
-
update: !1
|
|
166
|
-
};
|
|
160
|
+
this._prepareAnimate(animate_1.DefaultLabelAnimation);
|
|
167
161
|
}
|
|
168
162
|
}
|
|
169
163
|
getRelatedGraphic(item) {
|
|
@@ -213,7 +207,7 @@ class LabelBase extends base_1.AbstractComponent {
|
|
|
213
207
|
"shiftY" === (null == strategy ? void 0 : strategy.type) ? this._overlapGlobal(labels, option, bmpTool, bitmap) : this._overlapByStrategy(labels, option, bmpTool, bitmap);
|
|
214
208
|
}
|
|
215
209
|
_overlapGlobal(labels, option, bmpTool, bitmap) {
|
|
216
|
-
let result = labels.filter((label => label.attribute.visible && 0 !== label.attribute.opacity));
|
|
210
|
+
let result = labels.filter((label => label.attribute.visible && 0 !== label.attribute.opacity && this.isMarkInsideRect(this.getRelatedGraphic(label.attribute), bmpTool)));
|
|
217
211
|
const {clampForce: clampForce = !0, hideOnHit: hideOnHit = !0, overlapPadding: overlapPadding, strategy: strategy} = option;
|
|
218
212
|
if (clampForce) for (let i = 0; i < result.length; i++) {
|
|
219
213
|
const text = labels[i], {dx: dx = 0, dy: dy = 0} = (0, overlap_1.clampText)(text, bmpTool.width, bmpTool.height, bmpTool.padding);
|
|
@@ -273,12 +267,7 @@ class LabelBase extends base_1.AbstractComponent {
|
|
|
273
267
|
for (let i = 0; i < labels.length; i++) {
|
|
274
268
|
if (!1 === labels[i].attribute.visible) continue;
|
|
275
269
|
const text = labels[i], baseMark = this.getRelatedGraphic(text.attribute);
|
|
276
|
-
if (text.update(), !
|
|
277
|
-
x1: 0,
|
|
278
|
-
x2: bmpTool.width,
|
|
279
|
-
y1: 0,
|
|
280
|
-
y2: bmpTool.height
|
|
281
|
-
}, !0)) continue;
|
|
270
|
+
if (text.update(), !this.isMarkInsideRect(baseMark, bmpTool)) continue;
|
|
282
271
|
if ((0, overlap_1.canPlace)(bmpTool, bitmap, text.AABBBounds, clampForce, overlapPadding)) {
|
|
283
272
|
if (!checkBounds) {
|
|
284
273
|
bitmap.setRange((0, overlap_1.boundToRange)(bmpTool, text.AABBBounds, !0)), result.push(text);
|
|
@@ -308,13 +297,41 @@ class LabelBase extends base_1.AbstractComponent {
|
|
|
308
297
|
}
|
|
309
298
|
return result;
|
|
310
299
|
}
|
|
300
|
+
isMarkInsideRect(baseMark, bmpTool) {
|
|
301
|
+
const {left: left, right: right, top: top, bottom: bottom} = bmpTool.padding, rect = {
|
|
302
|
+
x1: -left,
|
|
303
|
+
x2: bmpTool.width + right,
|
|
304
|
+
y1: -top,
|
|
305
|
+
y2: bmpTool.height + bottom
|
|
306
|
+
}, bounds = baseMark.AABBBounds;
|
|
307
|
+
if (0 !== bounds.width() && 0 !== bounds.height()) return (0, vutils_1.isRectIntersect)(baseMark.AABBBounds, rect, !0);
|
|
308
|
+
const {attribute: attribute} = baseMark;
|
|
309
|
+
if ("rect" === baseMark.type) {
|
|
310
|
+
const {x: x, x1: x1, y: y, y1: y1} = attribute;
|
|
311
|
+
return (0, vutils_1.pointInRect)({
|
|
312
|
+
x: null != x ? x : x1,
|
|
313
|
+
y: null != y ? y : y1
|
|
314
|
+
}, rect, !0);
|
|
315
|
+
}
|
|
316
|
+
return "x" in attribute && "y" in attribute && (0, vutils_1.pointInRect)({
|
|
317
|
+
x: attribute.x,
|
|
318
|
+
y: attribute.y
|
|
319
|
+
}, rect, !0);
|
|
320
|
+
}
|
|
311
321
|
getBaseMarkGroup() {
|
|
312
322
|
const {baseMarkGroupName: baseMarkGroupName} = this.attribute;
|
|
313
323
|
if (baseMarkGroupName) return this.getRootNode().find((node => node.name === baseMarkGroupName), !0);
|
|
314
324
|
}
|
|
315
325
|
getGraphicBounds(graphic, point = {}, position) {
|
|
326
|
+
var _a;
|
|
316
327
|
if (graphic) {
|
|
317
|
-
if (!1 !== graphic.attribute.visible)
|
|
328
|
+
if (!1 !== graphic.attribute.visible) {
|
|
329
|
+
if (null === (_a = graphic.context) || void 0 === _a ? void 0 : _a.animationState) {
|
|
330
|
+
const clonedGraphic = graphic.clone();
|
|
331
|
+
return Object.assign(clonedGraphic.attribute, graphic.getAttributes(!0)), clonedGraphic.AABBBounds;
|
|
332
|
+
}
|
|
333
|
+
return graphic.AABBBounds;
|
|
334
|
+
}
|
|
318
335
|
const {x: x, y: y} = graphic.attribute;
|
|
319
336
|
return {
|
|
320
337
|
x1: x,
|
|
@@ -371,18 +388,23 @@ class LabelBase extends base_1.AbstractComponent {
|
|
|
371
388
|
}
|
|
372
389
|
})), this._removeLabel(prevTextMap), this._graphicToText = currentTextMap;
|
|
373
390
|
}
|
|
374
|
-
runEnterAnimation(text) {
|
|
391
|
+
runEnterAnimation(text, labelLine) {
|
|
375
392
|
if (!1 === this._enableAnimation || !this._animationConfig.enter) return;
|
|
376
393
|
const relatedGraphic = this.getRelatedGraphic(text.attribute), {enter: enter} = this._animationConfig;
|
|
377
|
-
text.applyAnimationState([ "enter" ], [ {
|
|
394
|
+
[ text, labelLine ].filter(Boolean).forEach((item => item.applyAnimationState([ "enter" ], [ {
|
|
378
395
|
name: "enter",
|
|
379
396
|
animation: Object.assign(Object.assign({}, enter), {
|
|
397
|
+
type: "labelEnter",
|
|
380
398
|
selfOnly: !0,
|
|
381
399
|
customParameters: {
|
|
382
|
-
relatedGraphic: relatedGraphic
|
|
400
|
+
relatedGraphic: relatedGraphic,
|
|
401
|
+
relatedGraphics: this._idToGraphic,
|
|
402
|
+
config: Object.assign(Object.assign({}, enter), {
|
|
403
|
+
type: item === text ? enter.type : "fadeIn"
|
|
404
|
+
})
|
|
383
405
|
}
|
|
384
406
|
})
|
|
385
|
-
} ]);
|
|
407
|
+
} ])));
|
|
386
408
|
}
|
|
387
409
|
_runUpdateAnimation(prevLabel, currentLabel) {
|
|
388
410
|
if (!1 === this._enableAnimation || !this._animationConfig.update) return;
|
|
@@ -402,9 +424,13 @@ class LabelBase extends base_1.AbstractComponent {
|
|
|
402
424
|
}
|
|
403
425
|
} ]);
|
|
404
426
|
}
|
|
427
|
+
_syncStateWithRelatedGraphic(relatedGraphic) {
|
|
428
|
+
this.attribute.syncState && relatedGraphic && relatedGraphic.on("afterStateUpdate", this._handleRelatedGraphicSetState);
|
|
429
|
+
}
|
|
405
430
|
_addLabel(label, texts, labelLines, index) {
|
|
406
|
-
const {text: text, labelLine: labelLine} = label;
|
|
407
|
-
text && this.add(text), labelLine && this.add(labelLine),
|
|
431
|
+
const {text: text, labelLine: labelLine} = label, relatedGraphic = this.getRelatedGraphic(text.attribute);
|
|
432
|
+
this._syncStateWithRelatedGraphic(relatedGraphic), text && this.add(text), labelLine && this.add(labelLine),
|
|
433
|
+
this.runEnterAnimation(text, labelLine);
|
|
408
434
|
}
|
|
409
435
|
_updateLabel(prevLabel, currentLabel) {
|
|
410
436
|
const {text: prevText, labelLine: prevLabelLine} = prevLabel, {text: curText, labelLine: curLabelLine} = currentLabel;
|
|
@@ -419,16 +445,16 @@ class LabelBase extends base_1.AbstractComponent {
|
|
|
419
445
|
var _a;
|
|
420
446
|
label.text.applyAnimationState([ "exit" ], [ {
|
|
421
447
|
name: "exit",
|
|
422
|
-
animation: Object.assign({
|
|
448
|
+
animation: Object.assign(Object.assign({}, this._animationConfig.exit), {
|
|
423
449
|
type: "fadeOut"
|
|
424
|
-
}
|
|
450
|
+
})
|
|
425
451
|
} ], (() => {
|
|
426
452
|
removeLabelAndLine(label);
|
|
427
453
|
})), null === (_a = label.labelLine) || void 0 === _a || _a.applyAnimationState([ "exit" ], [ {
|
|
428
454
|
name: "exit",
|
|
429
|
-
animation: Object.assign({
|
|
455
|
+
animation: Object.assign(Object.assign({}, this._animationConfig.exit), {
|
|
430
456
|
type: "fadeOut"
|
|
431
|
-
}
|
|
457
|
+
})
|
|
432
458
|
} ], (() => {}));
|
|
433
459
|
})) : textMap.forEach((label => {
|
|
434
460
|
removeLabelAndLine(label);
|