@visactor/vrender-components 0.22.15-alpha.1 → 0.22.16
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/animate/group-transition.d.ts +1 -2
- 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 +4 -9
- package/cjs/axis/base.js +5 -70
- 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 +0 -4
- package/cjs/axis/type.js.map +1 -1
- package/cjs/axis/util.js +1 -2
- package/cjs/brush/brush.js.map +1 -1
- package/cjs/brush/config.js +2 -1
- package/cjs/crosshair/polygon-sector.js +1 -2
- package/cjs/crosshair/rect.js +2 -1
- 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 +2 -1
- package/cjs/jsx/index.js +1 -2
- package/cjs/label/animate/animate.d.ts +12 -1
- package/cjs/label/animate/animate.js +84 -1
- package/cjs/label/animate/animate.js.map +1 -1
- package/cjs/label/arc.js +6 -6
- package/cjs/label/arc.js.map +1 -1
- package/cjs/label/base.d.ts +6 -6
- package/cjs/label/base.js +132 -102
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/index.js +1 -1
- package/cjs/label/line.js +1 -1
- package/cjs/label/polygon.js +1 -1
- package/cjs/label/register.d.ts +0 -1
- package/cjs/label/register.js +4 -8
- package/cjs/label/register.js.map +1 -1
- package/cjs/label/type.d.ts +1 -0
- package/cjs/label/type.js.map +1 -1
- package/cjs/label-item/label-item.d.ts +20 -9
- package/cjs/label-item/label-item.js +103 -1
- package/cjs/label-item/label-item.js.map +1 -1
- package/cjs/marker/config.d.ts +18 -0
- package/cjs/marker/config.js +19 -1
- package/cjs/marker/config.js.map +1 -1
- package/cjs/marker/point.d.ts +18 -0
- package/cjs/marker/point.js +19 -16
- package/cjs/marker/point.js.map +1 -1
- package/cjs/marker/register.js +7 -8
- package/cjs/marker/register.js.map +1 -1
- package/cjs/marker/type.d.ts +11 -4
- package/cjs/marker/type.js.map +1 -1
- package/cjs/poptip/poptip.d.ts +9 -0
- package/cjs/poptip/poptip.js +37 -1
- package/cjs/poptip/poptip.js.map +1 -1
- package/cjs/weather/weather-box.d.ts +1 -1
- package/cjs/weather/weather-box.js +5 -5
- package/cjs/weather/weather-box.js.map +1 -1
- package/dist/index.es.js +13414 -14743
- package/es/axis/animate/group-transition.d.ts +1 -2
- package/es/axis/animate/group-transition.js +1 -3
- package/es/axis/animate/group-transition.js.map +1 -1
- package/es/axis/base.d.ts +4 -9
- package/es/axis/base.js +9 -75
- package/es/axis/base.js.map +1 -1
- package/es/axis/line.js.map +1 -1
- package/es/axis/register.js +1 -3
- package/es/axis/register.js.map +1 -1
- package/es/axis/type.d.ts +0 -4
- package/es/axis/type.js.map +1 -1
- package/es/axis/util.js +1 -2
- package/es/brush/brush.js.map +1 -1
- package/es/brush/config.js +2 -1
- package/es/crosshair/polygon-sector.js +1 -2
- package/es/crosshair/rect.js +2 -1
- 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 +2 -1
- package/es/jsx/index.js +1 -2
- package/es/label/animate/animate.d.ts +12 -1
- package/es/label/animate/animate.js +82 -0
- package/es/label/animate/animate.js.map +1 -1
- package/es/label/arc.js +6 -6
- package/es/label/arc.js.map +1 -1
- package/es/label/base.d.ts +6 -6
- package/es/label/base.js +132 -105
- package/es/label/base.js.map +1 -1
- package/es/label/index.js +1 -1
- package/es/label/line.js +1 -1
- package/es/label/polygon.js +1 -1
- package/es/label/register.d.ts +0 -1
- package/es/label/register.js +1 -7
- package/es/label/register.js.map +1 -1
- package/es/label/type.d.ts +1 -0
- package/es/label/type.js.map +1 -1
- package/es/label-item/label-item.d.ts +20 -9
- package/es/label-item/label-item.js +104 -0
- package/es/label-item/label-item.js.map +1 -1
- package/es/marker/config.d.ts +18 -0
- package/es/marker/config.js +19 -1
- package/es/marker/config.js.map +1 -1
- package/es/marker/point.d.ts +18 -0
- package/es/marker/point.js +19 -16
- package/es/marker/point.js.map +1 -1
- package/es/marker/register.js +6 -8
- package/es/marker/register.js.map +1 -1
- package/es/marker/type.d.ts +11 -4
- package/es/marker/type.js.map +1 -1
- package/es/poptip/poptip.d.ts +9 -0
- package/es/poptip/poptip.js +38 -0
- package/es/poptip/poptip.js.map +1 -1
- package/es/weather/weather-box.d.ts +1 -1
- package/es/weather/weather-box.js +1 -1
- package/es/weather/weather-box.js.map +1 -1
- package/package.json +8 -9
- package/cjs/animation/animate-component.d.ts +0 -22
- package/cjs/animation/animate-component.js +0 -29
- package/cjs/animation/animate-component.js.map +0 -1
- package/cjs/animation/axis-animate.d.ts +0 -10
- package/cjs/animation/axis-animate.js +0 -71
- package/cjs/animation/axis-animate.js.map +0 -1
- package/cjs/animation/label-animate.d.ts +0 -10
- package/cjs/animation/label-animate.js +0 -81
- package/cjs/animation/label-animate.js.map +0 -1
- package/cjs/axis/animate/config.d.ts +0 -6
- package/cjs/axis/animate/config.js +0 -10
- package/cjs/axis/animate/config.js.map +0 -1
- package/es/animation/animate-component.d.ts +0 -22
- package/es/animation/animate-component.js +0 -21
- package/es/animation/animate-component.js.map +0 -1
- package/es/animation/axis-animate.d.ts +0 -10
- package/es/animation/axis-animate.js +0 -60
- package/es/animation/axis-animate.js.map +0 -1
- package/es/animation/label-animate.d.ts +0 -10
- package/es/animation/label-animate.js +0 -70
- package/es/animation/label-animate.js.map +0 -1
- package/es/axis/animate/config.d.ts +0 -6
- package/es/axis/animate/config.js +0 -6
- package/es/axis/animate/config.js.map +0 -1
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"), 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")
|
|
17
|
+
const vrender_core_1 = require("@visactor/vrender-core"), vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base"), 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");
|
|
18
18
|
|
|
19
19
|
(0, register_1.loadLabelComponent)();
|
|
20
20
|
|
|
21
|
-
class LabelBase extends
|
|
21
|
+
class LabelBase extends base_1.AbstractComponent {
|
|
22
22
|
setBitmap(bitmap) {
|
|
23
23
|
this._bitmap = bitmap;
|
|
24
24
|
}
|
|
@@ -77,7 +77,7 @@ class LabelBase extends animate_component_1.AnimateComponent {
|
|
|
77
77
|
baseMark: baseMark
|
|
78
78
|
}, attrs, new vrender_core_1.CustomPath2D);
|
|
79
79
|
}
|
|
80
|
-
return baseMark && baseMark.
|
|
80
|
+
return baseMark && baseMark.attribute.fill && lineGraphic.setAttribute("stroke", baseMark.attribute.fill),
|
|
81
81
|
this.attribute.line && !(0, vutils_1.isEmpty)(this.attribute.line.style) && lineGraphic.setAttributes(this.attribute.line.style),
|
|
82
82
|
this._setStatesOfLabelLine(lineGraphic), lineGraphic;
|
|
83
83
|
}
|
|
@@ -85,10 +85,6 @@ class LabelBase extends animate_component_1.AnimateComponent {
|
|
|
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
|
-
}));
|
|
92
88
|
const {overlap: overlap, smartInvert: smartInvert, dataFilter: dataFilter, customLayoutFunc: customLayoutFunc, customOverlapFunc: customOverlapFunc} = this.attribute;
|
|
93
89
|
let data = this.attribute.data;
|
|
94
90
|
if ((0, vutils_1.isFunction)(dataFilter) && (data = dataFilter(data)), data && data.length) {
|
|
@@ -101,10 +97,7 @@ class LabelBase extends animate_component_1.AnimateComponent {
|
|
|
101
97
|
(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),
|
|
102
98
|
labels && labels.length && labels.forEach((label => {
|
|
103
99
|
this._bindEvent(label), this._setStatesOfText(label);
|
|
104
|
-
})), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels)
|
|
105
|
-
!1 !== this._enableAnimation && this._baseMarks.forEach(((mark, index) => {
|
|
106
|
-
mark.initAttributes(markAttributeList[index]);
|
|
107
|
-
}));
|
|
100
|
+
})), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels);
|
|
108
101
|
}
|
|
109
102
|
_bindEvent(target) {
|
|
110
103
|
if (this.attribute.disableTriggerEvent) return;
|
|
@@ -157,7 +150,20 @@ class LabelBase extends animate_component_1.AnimateComponent {
|
|
|
157
150
|
textData && baseMark && ((0, vutils_1.isValid)(textData.id) || (textData.id = `vrender-component-${this.name}-${i}`),
|
|
158
151
|
this._idToGraphic.set(textData.id, baseMark));
|
|
159
152
|
}
|
|
160
|
-
this.
|
|
153
|
+
if (!1 !== this.attribute.animation) {
|
|
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
|
+
};
|
|
161
167
|
}
|
|
162
168
|
}
|
|
163
169
|
getRelatedGraphic(item) {
|
|
@@ -168,8 +174,8 @@ class LabelBase extends animate_component_1.AnimateComponent {
|
|
|
168
174
|
for (let i = 0; i < data.length; i++) {
|
|
169
175
|
const textData = data[i], baseMark = this.getRelatedGraphic(textData);
|
|
170
176
|
if (!baseMark) continue;
|
|
171
|
-
const
|
|
172
|
-
fill: this._isCollectionBase ? (0, vutils_1.isArray)(
|
|
177
|
+
const labelAttribute = Object.assign(Object.assign({
|
|
178
|
+
fill: this._isCollectionBase ? (0, vutils_1.isArray)(baseMark.attribute.stroke) ? baseMark.attribute.stroke.find((entry => !!entry && !0 !== entry)) : baseMark.attribute.stroke : baseMark.attribute.fill
|
|
173
179
|
}, textStyle), textData), text = this._createLabelText(labelAttribute);
|
|
174
180
|
labels.push(text);
|
|
175
181
|
}
|
|
@@ -208,13 +214,15 @@ class LabelBase extends animate_component_1.AnimateComponent {
|
|
|
208
214
|
}
|
|
209
215
|
_overlapGlobal(labels, option, bmpTool, bitmap) {
|
|
210
216
|
let result = labels.filter((label => label.attribute.visible && 0 !== label.attribute.opacity && this.isMarkInsideRect(this.getRelatedGraphic(label.attribute), bmpTool)));
|
|
211
|
-
const {clampForce: clampForce = !0, hideOnHit: hideOnHit = !0, overlapPadding: overlapPadding, strategy: strategy} = option;
|
|
212
|
-
if (clampForce) for (let i = 0; i < result.length; i++) {
|
|
217
|
+
const {clampForce: clampForce = !0, hideOnHit: hideOnHit = !0, hideOnOverflow: hideOnOverflow = !1, overlapPadding: overlapPadding, strategy: strategy} = option;
|
|
218
|
+
if (clampForce || hideOnOverflow) for (let i = 0; i < result.length; i++) {
|
|
213
219
|
const text = labels[i], {dx: dx = 0, dy: dy = 0} = (0, overlap_1.clampText)(text, bmpTool.width, bmpTool.height, bmpTool.padding);
|
|
214
|
-
0 === dx && 0 === dy || (text.setAttributes({
|
|
220
|
+
0 === dx && 0 === dy || (hideOnOverflow ? text.setAttributes({
|
|
221
|
+
visible: !1
|
|
222
|
+
}) : (text.setAttributes({
|
|
215
223
|
x: text.attribute.x + dx,
|
|
216
224
|
y: text.attribute.y + dy
|
|
217
|
-
}), text._isClamped = !0);
|
|
225
|
+
}), text._isClamped = !0));
|
|
218
226
|
}
|
|
219
227
|
result = (0, shiftY_1.shiftY)(result, Object.assign(Object.assign({
|
|
220
228
|
maxY: bmpTool.height
|
|
@@ -227,9 +235,9 @@ class LabelBase extends animate_component_1.AnimateComponent {
|
|
|
227
235
|
for (let i = 0; i < result.length; i++) {
|
|
228
236
|
const text = result[i], bounds = text.AABBBounds, range = (0, overlap_1.boundToRange)(bmpTool, bounds, !0);
|
|
229
237
|
if ((0, overlap_1.canPlace)(bmpTool, bitmap, bounds, clampForce, overlapPadding)) bitmap.setRange(range); else {
|
|
230
|
-
if (
|
|
231
|
-
if (this.
|
|
232
|
-
}
|
|
238
|
+
if (hideOnOverflow) {
|
|
239
|
+
if (this._processHideOnOverflow(text, bmpTool)) continue;
|
|
240
|
+
} else if (clampForce && this._processClampForce(text, bmpTool, bitmap, overlapPadding)) continue;
|
|
233
241
|
hideOnHit ? text.setAttributes({
|
|
234
242
|
visible: !1
|
|
235
243
|
}) : bitmap.setRange(range);
|
|
@@ -237,6 +245,12 @@ class LabelBase extends animate_component_1.AnimateComponent {
|
|
|
237
245
|
}
|
|
238
246
|
return result;
|
|
239
247
|
}
|
|
248
|
+
_processHideOnOverflow(text, bmpTool) {
|
|
249
|
+
const {dy: dy = 0, dx: dx = 0} = (0, overlap_1.clampText)(text, bmpTool.width, bmpTool.height, bmpTool.padding);
|
|
250
|
+
return 0 === dx && 0 === dy || (text.setAttributes({
|
|
251
|
+
visible: !1
|
|
252
|
+
}), !1);
|
|
253
|
+
}
|
|
240
254
|
_processClampForce(text, bmpTool, bitmap, overlapPadding = 0) {
|
|
241
255
|
const {dy: dy = 0, dx: dx = 0} = (0, overlap_1.clampText)(text, bmpTool.width, bmpTool.height, bmpTool.padding);
|
|
242
256
|
if (0 === dx && 0 === dy) {
|
|
@@ -256,7 +270,7 @@ class LabelBase extends animate_component_1.AnimateComponent {
|
|
|
256
270
|
}
|
|
257
271
|
_overlapByStrategy(labels, option, bmpTool, bitmap) {
|
|
258
272
|
var _a;
|
|
259
|
-
const {avoidBaseMark: avoidBaseMark, strategy: strategy = [], hideOnHit: hideOnHit = !0, clampForce: clampForce = !0, avoidMarks: avoidMarks = [], overlapPadding: overlapPadding} = option, result = [], checkBounds = strategy.some((s => "bound" === s.type));
|
|
273
|
+
const {avoidBaseMark: avoidBaseMark, strategy: strategy = [], hideOnHit: hideOnHit = !0, clampForce: clampForce = !0, avoidMarks: avoidMarks = [], overlapPadding: overlapPadding, hideOnOverflow: hideOnOverflow = !1} = option, result = [], checkBounds = strategy.some((s => "bound" === s.type));
|
|
260
274
|
avoidBaseMark && (null === (_a = this._baseMarks) || void 0 === _a || _a.forEach((mark => {
|
|
261
275
|
mark.AABBBounds && bitmap.setRange((0, overlap_1.boundToRange)(bmpTool, mark.AABBBounds, !0));
|
|
262
276
|
}))), avoidMarks.length > 0 && avoidMarks.forEach((avoid => {
|
|
@@ -280,15 +294,16 @@ class LabelBase extends animate_component_1.AnimateComponent {
|
|
|
280
294
|
}
|
|
281
295
|
let hasPlace = !1;
|
|
282
296
|
for (let j = 0; j < strategy.length; j++) if (hasPlace = (0, overlap_1.place)(bmpTool, bitmap, strategy[j], this.attribute, text, this._isCollectionBase ? this.getGraphicBounds(null, this._idToPoint.get(labels[i].attribute.id)) : this.getGraphicBounds(baseMark, labels[i].attribute), this.labeling),
|
|
283
|
-
!1 !== hasPlace
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
297
|
+
!1 !== hasPlace && (text.setAttributes({
|
|
298
|
+
x: hasPlace.x,
|
|
299
|
+
y: hasPlace.y
|
|
300
|
+
}), !hideOnOverflow || this._processHideOnOverflow(text, bmpTool))) {
|
|
301
|
+
result.push(text);
|
|
288
302
|
break;
|
|
289
303
|
}
|
|
290
|
-
if (!hasPlace
|
|
291
|
-
if (this.
|
|
304
|
+
if (!hasPlace) {
|
|
305
|
+
if (hideOnOverflow && !this._processHideOnOverflow(text, bmpTool)) continue;
|
|
306
|
+
if (clampForce && this._processClampForce(text, bmpTool, bitmap, overlapPadding)) {
|
|
292
307
|
result.push(text);
|
|
293
308
|
continue;
|
|
294
309
|
}
|
|
@@ -323,15 +338,8 @@ class LabelBase extends animate_component_1.AnimateComponent {
|
|
|
323
338
|
if (baseMarkGroupName) return this.getRootNode().find((node => node.name === baseMarkGroupName), !0);
|
|
324
339
|
}
|
|
325
340
|
getGraphicBounds(graphic, point = {}, position) {
|
|
326
|
-
var _a;
|
|
327
341
|
if (graphic) {
|
|
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
|
-
}
|
|
342
|
+
if (!1 !== graphic.attribute.visible) return graphic.AABBBounds;
|
|
335
343
|
const {x: x, y: y} = graphic.attribute;
|
|
336
344
|
return {
|
|
337
345
|
x1: x,
|
|
@@ -364,88 +372,65 @@ class LabelBase extends animate_component_1.AnimateComponent {
|
|
|
364
372
|
var _a;
|
|
365
373
|
const relatedGraphic = this.getRelatedGraphic(text.attribute), textKey = this._isCollectionBase ? text.attribute.id : relatedGraphic, state = (null == prevTextMap ? void 0 : prevTextMap.get(textKey)) ? "update" : "enter";
|
|
366
374
|
let labelLine;
|
|
367
|
-
showLabelLine && (labelLine = this._createLabelLine(text, relatedGraphic))
|
|
368
|
-
|
|
375
|
+
if (showLabelLine && (labelLine = this._createLabelLine(text, relatedGraphic)),
|
|
376
|
+
syncState && this.updateStatesOfLabels([ labelLine ? {
|
|
369
377
|
text: text,
|
|
370
378
|
labelLine: labelLine
|
|
371
379
|
} : {
|
|
372
380
|
text: text
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
381
|
+
} ], null !== (_a = relatedGraphic.currentStates) && void 0 !== _a ? _a : []), "enter" === state) texts.push(text),
|
|
382
|
+
currentTextMap.set(textKey, labelLine ? {
|
|
383
|
+
text: text,
|
|
384
|
+
labelLine: labelLine
|
|
385
|
+
} : {
|
|
386
|
+
text: text
|
|
387
|
+
}), this._addLabel({
|
|
388
|
+
text: text,
|
|
389
|
+
labelLine: labelLine
|
|
390
|
+
}, texts, labelLines, index); else if ("update" === state) {
|
|
377
391
|
const prevLabel = prevTextMap.get(textKey);
|
|
378
|
-
prevTextMap.delete(textKey), currentTextMap.set(textKey, prevLabel), this._updateLabel(prevLabel,
|
|
392
|
+
prevTextMap.delete(textKey), currentTextMap.set(textKey, prevLabel), this._updateLabel(prevLabel, {
|
|
393
|
+
text: text,
|
|
394
|
+
labelLine: labelLine
|
|
395
|
+
});
|
|
379
396
|
}
|
|
380
397
|
})), this._removeLabel(prevTextMap), this._graphicToText = currentTextMap;
|
|
381
398
|
}
|
|
382
|
-
runEnterAnimation(text, labelLine) {
|
|
383
|
-
if (!1 === this._enableAnimation || !this._animationConfig.enter) return;
|
|
384
|
-
const relatedGraphic = this.getRelatedGraphic(text.attribute), {enter: enter} = this._animationConfig;
|
|
385
|
-
[ text, labelLine ].filter(Boolean).forEach((item => item.applyAnimationState([ "enter" ], [ {
|
|
386
|
-
name: "enter",
|
|
387
|
-
animation: Object.assign(Object.assign({}, enter), {
|
|
388
|
-
type: "labelEnter",
|
|
389
|
-
selfOnly: !0,
|
|
390
|
-
customParameters: {
|
|
391
|
-
relatedGraphic: relatedGraphic,
|
|
392
|
-
relatedGraphics: this._idToGraphic,
|
|
393
|
-
config: Object.assign(Object.assign({}, enter), {
|
|
394
|
-
type: item === text ? enter.type : "fadeIn"
|
|
395
|
-
})
|
|
396
|
-
}
|
|
397
|
-
})
|
|
398
|
-
} ])));
|
|
399
|
-
}
|
|
400
|
-
_runUpdateAnimation(prevLabel, currentLabel) {
|
|
401
|
-
const {text: prevText, labelLine: prevLabelLine} = prevLabel, {text: curText, labelLine: curLabelLine} = currentLabel;
|
|
402
|
-
prevText.applyAnimationState([ "update" ], [ {
|
|
403
|
-
name: "update",
|
|
404
|
-
animation: Object.assign(Object.assign({
|
|
405
|
-
type: "labelUpdate"
|
|
406
|
-
}, this._animationConfig.update), {
|
|
407
|
-
customParameters: {
|
|
408
|
-
prevText: prevText,
|
|
409
|
-
curText: curText,
|
|
410
|
-
prevLabelLine: prevLabelLine,
|
|
411
|
-
curLabelLine: curLabelLine
|
|
412
|
-
}
|
|
413
|
-
})
|
|
414
|
-
} ]);
|
|
415
|
-
}
|
|
416
|
-
_syncStateWithRelatedGraphic(relatedGraphic) {
|
|
417
|
-
this.attribute.syncState && relatedGraphic && relatedGraphic.on("afterStateUpdate", this._handleRelatedGraphicSetState);
|
|
418
|
-
}
|
|
419
399
|
_addLabel(label, texts, labelLines, index) {
|
|
420
400
|
const {text: text, labelLine: labelLine} = label, relatedGraphic = this.getRelatedGraphic(text.attribute);
|
|
421
|
-
this._syncStateWithRelatedGraphic(relatedGraphic),
|
|
422
|
-
|
|
401
|
+
if (this._syncStateWithRelatedGraphic(relatedGraphic), !1 !== this._enableAnimation && !1 !== this._animationConfig.enter) {
|
|
402
|
+
if (relatedGraphic) {
|
|
403
|
+
const {from: from, to: to} = (0, animate_1.getAnimationAttributes)(text.attribute, "fadeIn");
|
|
404
|
+
text && this.add(text), labelLine && (labelLines.push(labelLine), this.add(labelLine)),
|
|
405
|
+
this._animationConfig.enter.duration > 0 && relatedGraphic.once("animate-bind", (a => {
|
|
406
|
+
text.setAttributes(from), labelLine && labelLine.setAttributes(from);
|
|
407
|
+
const listener = this._afterRelatedGraphicAttributeUpdate(text, texts, labelLine, labelLines, index, relatedGraphic, to, this._animationConfig.enter);
|
|
408
|
+
relatedGraphic.on("afterAttributeUpdate", listener);
|
|
409
|
+
}));
|
|
410
|
+
}
|
|
411
|
+
} else text && this.add(text), labelLine && this.add(labelLine);
|
|
423
412
|
}
|
|
424
413
|
_updateLabel(prevLabel, currentLabel) {
|
|
425
414
|
const {text: prevText, labelLine: prevLabelLine} = prevLabel, {text: curText, labelLine: curLabelLine} = currentLabel;
|
|
426
|
-
!1
|
|
427
|
-
|
|
415
|
+
if (!1 !== this._enableAnimation && !1 !== this._animationConfig.update) {
|
|
416
|
+
const {duration: duration, easing: easing} = this._animationConfig.update;
|
|
417
|
+
(0, animate_1.updateAnimation)(prevText, curText, this._animationConfig.update),
|
|
418
|
+
prevLabelLine && curLabelLine && prevLabel.labelLine.animate().to(curLabelLine.attribute, duration, easing);
|
|
419
|
+
} else prevLabel.text.setAttributes(curText.attribute), prevLabelLine && curLabelLine && prevLabel.labelLine.setAttributes(curLabelLine.attribute);
|
|
428
420
|
}
|
|
429
421
|
_removeLabel(textMap) {
|
|
430
422
|
const removeLabelAndLine = label => {
|
|
431
423
|
this.removeChild(label.text), label.labelLine && this.removeChild(label.labelLine);
|
|
432
424
|
};
|
|
433
|
-
!1 !== this._enableAnimation && !1 !== this._animationConfig.exit
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
})
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
})), null === (_a = label.labelLine) || void 0 === _a || _a.applyAnimationState([ "exit" ], [ {
|
|
443
|
-
name: "exit",
|
|
444
|
-
animation: Object.assign(Object.assign({}, this._animationConfig.exit), {
|
|
445
|
-
type: "fadeOut"
|
|
446
|
-
})
|
|
447
|
-
} ], (() => {}));
|
|
448
|
-
})) : textMap.forEach((label => {
|
|
425
|
+
if (!1 !== this._enableAnimation && !1 !== this._animationConfig.exit) {
|
|
426
|
+
const {duration: duration, easing: easing} = this._animationConfig.exit;
|
|
427
|
+
textMap.forEach((label => {
|
|
428
|
+
var _a;
|
|
429
|
+
null === (_a = label.text) || void 0 === _a || _a.animate().to((0, animate_1.getAnimationAttributes)(label.text.attribute, "fadeOut").to, duration, easing).onEnd((() => {
|
|
430
|
+
removeLabelAndLine(label);
|
|
431
|
+
}));
|
|
432
|
+
}));
|
|
433
|
+
} else textMap.forEach((label => {
|
|
449
434
|
removeLabelAndLine(label);
|
|
450
435
|
}));
|
|
451
436
|
}
|
|
@@ -454,6 +439,51 @@ class LabelBase extends animate_component_1.AnimateComponent {
|
|
|
454
439
|
label && (label.text && label.text.useStates(currentStates), label.labelLine && label.labelLine.useStates(currentStates));
|
|
455
440
|
}));
|
|
456
441
|
}
|
|
442
|
+
_syncStateWithRelatedGraphic(relatedGraphic) {
|
|
443
|
+
this.attribute.syncState && relatedGraphic && relatedGraphic.on("afterAttributeUpdate", this._handleRelatedGraphicSetState);
|
|
444
|
+
}
|
|
445
|
+
_afterRelatedGraphicAttributeUpdate(text, texts, labelLine, labelLines, index, relatedGraphic, to, {mode: mode, duration: duration, easing: easing, delay: delay}) {
|
|
446
|
+
const listener = event => {
|
|
447
|
+
var _a, _b, _c;
|
|
448
|
+
const {detail: detail} = event;
|
|
449
|
+
if (!detail) return {};
|
|
450
|
+
const step = null === (_a = detail.animationState) || void 0 === _a ? void 0 : _a.step;
|
|
451
|
+
if (!(detail.type === vrender_core_1.AttributeUpdateType.ANIMATE_UPDATE && step && !("wait" === step.type && null == (null === (_b = step.prev) || void 0 === _b ? void 0 : _b.type)))) return {};
|
|
452
|
+
if (detail.type === vrender_core_1.AttributeUpdateType.ANIMATE_END) return text.setAttributes(to),
|
|
453
|
+
void (labelLine && labelLine.setAttributes(to));
|
|
454
|
+
const onStart = () => {
|
|
455
|
+
relatedGraphic && (relatedGraphic.onAnimateBind = void 0, relatedGraphic.removeEventListener("afterAttributeUpdate", listener));
|
|
456
|
+
};
|
|
457
|
+
switch (mode) {
|
|
458
|
+
case "after":
|
|
459
|
+
detail.animationState.end && (text.animate({
|
|
460
|
+
onStart: onStart
|
|
461
|
+
}).wait(delay).to(to, duration, easing), labelLine && labelLine.animate().wait(delay).to(to, duration, easing));
|
|
462
|
+
break;
|
|
463
|
+
|
|
464
|
+
case "after-all":
|
|
465
|
+
index === texts.length - 1 && detail.animationState.end && (texts.forEach((t => {
|
|
466
|
+
t.animate({
|
|
467
|
+
onStart: onStart
|
|
468
|
+
}).wait(delay).to(to, duration, easing);
|
|
469
|
+
})), labelLines.forEach((t => {
|
|
470
|
+
t.animate().wait(delay).to(to, duration, easing);
|
|
471
|
+
})));
|
|
472
|
+
break;
|
|
473
|
+
|
|
474
|
+
default:
|
|
475
|
+
if (this._isCollectionBase) {
|
|
476
|
+
const point = this._idToPoint.get(text.attribute.id);
|
|
477
|
+
!point || text.animates && text.animates.has("label-animate") || !relatedGraphic.containsPoint(point.x, point.y, vrender_core_1.IContainPointMode.LOCAL, null === (_c = this.stage) || void 0 === _c ? void 0 : _c.getPickerService()) || (text.animate({
|
|
478
|
+
onStart: onStart
|
|
479
|
+
}).wait(delay).to(to, duration, easing), labelLine && labelLine.animate().wait(delay).to(to, duration, easing));
|
|
480
|
+
} else detail.animationState.isFirstFrameOfStep && (text.animate({
|
|
481
|
+
onStart: onStart
|
|
482
|
+
}).wait(delay).to(to, duration, easing), labelLine && labelLine.animate().wait(delay).to(to, duration, easing));
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
return listener;
|
|
486
|
+
}
|
|
457
487
|
_smartInvert(labels) {
|
|
458
488
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
459
489
|
const option = (0, vutils_1.isObject)(this.attribute.smartInvert) ? this.attribute.smartInvert : {}, {textType: textType, contrastRatiosThreshold: contrastRatiosThreshold, alternativeColors: alternativeColors, mode: mode, interactInvertType: interactInvertType} = option, fillStrategy = null !== (_a = option.fillStrategy) && void 0 !== _a ? _a : "invertBase", strokeStrategy = null !== (_b = option.strokeStrategy) && void 0 !== _b ? _b : "base", brightColor = null !== (_c = option.brightColor) && void 0 !== _c ? _c : "#ffffff", darkColor = null !== (_d = option.darkColor) && void 0 !== _d ? _d : "#000000", outsideEnable = null !== (_e = option.outsideEnable) && void 0 !== _e && _e;
|
|
@@ -461,7 +491,7 @@ class LabelBase extends animate_component_1.AnimateComponent {
|
|
|
461
491
|
const label = labels[i];
|
|
462
492
|
if (!label) continue;
|
|
463
493
|
const baseMark = this.getRelatedGraphic(label.attribute);
|
|
464
|
-
let backgroundColor = baseMark.
|
|
494
|
+
let backgroundColor = baseMark.attribute.fill, foregroundColor = label.attribute.fill;
|
|
465
495
|
if ((0, vutils_1.isObject)(backgroundColor) && backgroundColor.gradient) {
|
|
466
496
|
const firstStopColor = null === (_g = null === (_f = backgroundColor.stops) || void 0 === _f ? void 0 : _f[0]) || void 0 === _g ? void 0 : _g.color;
|
|
467
497
|
firstStopColor && (backgroundColor = firstStopColor, foregroundColor = firstStopColor);
|