@visactor/vrender-components 0.22.6-alpha.1 → 0.22.7-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/label/animate/animate.js +8 -2
- package/cjs/label/animate/animate.js.map +1 -1
- package/cjs/label/base.d.ts +1 -0
- package/cjs/label/base.js +23 -7
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/overlap/scaler.js +3 -3
- package/cjs/label/overlap/scaler.js.map +1 -1
- package/cjs/tag/tag.js +60 -56
- package/cjs/tag/tag.js.map +1 -1
- package/dist/index.es.js +156 -116
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/label/animate/animate.js +8 -2
- package/es/label/animate/animate.js.map +1 -1
- package/es/label/base.d.ts +1 -0
- package/es/label/base.js +24 -8
- package/es/label/base.js.map +1 -1
- package/es/label/overlap/scaler.js +1 -1
- package/es/label/overlap/scaler.js.map +1 -1
- package/es/tag/tag.js +59 -56
- package/es/tag/tag.js.map +1 -1
- package/package.json +5 -5
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, Point, PointService, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, pi, isArray, isNumberClose, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, cos, sin, isString, pointAt, isNumber, getDecimalPlaces, isNil, Color, sqrt, OBBBounds, has, normalTransform, isValidUrl, isBase64, acos, transformBoundsWithMatrix, getContextFont, rotatePoint, clampAngleByRadian, asin, arrayEqual, Bounds, getRectIntersect, isRectIntersect, isPlainObject, merge, clamp, clampRange, normalizePadding, debounce, throttle, hexToRgb, crossProduct, isValid, isEmpty, rectInsideAnotherRect, radianToDegree, getAngleByPoint, polarToCartesian, normalizeAngle, isValidNumber, flattenArray,
|
|
1
|
+
import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, Point, PointService, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, pi, isArray, isNumberClose, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, cos, sin, isString, pointAt, isNumber, getDecimalPlaces, isNil, Color, sqrt, OBBBounds, has, normalTransform, isValidUrl, isBase64, acos, transformBoundsWithMatrix, getContextFont, rotatePoint, clampAngleByRadian, asin, arrayEqual, Bounds, getRectIntersect, isRectIntersect, isPlainObject, merge, clamp, clampRange, normalizePadding, debounce, throttle, hexToRgb, crossProduct, isValid, isEmpty, array, rectInsideAnotherRect, radianToDegree, getAngleByPoint, polarToCartesian, normalizeAngle, isValidNumber, flattenArray, isRotateAABBIntersect, isLess, isGreater, cloneDeep, get, last, mixin, isEqual, interpolateString, minInArray, maxInArray, binaryFuzzySearchInNumberRange, pointInRect, calculateAnchorOfBounds, computeQuadrant, polygonContainPoint } from '@visactor/vutils';
|
|
2
2
|
import { isContinuous, isDiscrete, LinearScale } from '@visactor/vscale';
|
|
3
3
|
|
|
4
4
|
class Generator {
|
|
@@ -4162,7 +4162,7 @@ class FederatedEvent {
|
|
|
4162
4162
|
}
|
|
4163
4163
|
_composedDetailPath(params) {
|
|
4164
4164
|
if (params && params.graphic) {
|
|
4165
|
-
const g =
|
|
4165
|
+
const g = params.graphic;
|
|
4166
4166
|
if (g.stage) {
|
|
4167
4167
|
const path = g.stage.eventSystem.manager.propagationPath(g);
|
|
4168
4168
|
this.detailPath.push(path), this._composedDetailPath(params.params);
|
|
@@ -15941,14 +15941,17 @@ class Tag extends AbstractComponent {
|
|
|
15941
15941
|
tagWidth += symbolPlaceWidth;
|
|
15942
15942
|
textX += symbolPlaceWidth;
|
|
15943
15943
|
let textShape;
|
|
15944
|
+
let textWidth;
|
|
15945
|
+
let textHeight;
|
|
15944
15946
|
const isRich = isRichText({ text }) || type === 'rich';
|
|
15945
15947
|
if (isRich) {
|
|
15946
15948
|
const richTextAttrs = Object.assign(Object.assign(Object.assign({}, richTextAttributeTransform(Object.assign({ type, text }, textStyle))), textStyle), { visible: isValid(text) && visible !== false, x: textX, y: 0 });
|
|
15949
|
+
if (isNil(richTextAttrs.lineHeight)) {
|
|
15950
|
+
richTextAttrs.lineHeight = textStyle.fontSize;
|
|
15951
|
+
}
|
|
15947
15952
|
textShape = group.createOrUpdateChild('tag-text', richTextAttrs, 'richtext');
|
|
15948
|
-
|
|
15949
|
-
|
|
15950
|
-
tagX += textShape.AABBBounds.x1;
|
|
15951
|
-
tagY += textShape.AABBBounds.y1;
|
|
15953
|
+
textWidth = textShape.AABBBounds.width();
|
|
15954
|
+
textHeight = textShape.AABBBounds.height();
|
|
15952
15955
|
}
|
|
15953
15956
|
else {
|
|
15954
15957
|
const textAttrs = Object.assign(Object.assign({ text: isObject(text) && 'type' in text && text.type === 'text' ? text.text : text, visible: isValid(text) && visible !== false, lineHeight: textStyle === null || textStyle === void 0 ? void 0 : textStyle.fontSize }, textStyle), { x: textX, y: 0 });
|
|
@@ -15956,126 +15959,134 @@ class Tag extends AbstractComponent {
|
|
|
15956
15959
|
textAttrs.lineHeight = textStyle.fontSize;
|
|
15957
15960
|
}
|
|
15958
15961
|
textShape = group.createOrUpdateChild('tag-text', textAttrs, 'text');
|
|
15959
|
-
if (!isEmpty(state === null || state === void 0 ? void 0 : state.text)) {
|
|
15960
|
-
textShape.states = state.text;
|
|
15961
|
-
}
|
|
15962
15962
|
const textBounds = measureTextSize(textAttrs.text, textStyle, (_b = (_a = this.stage) === null || _a === void 0 ? void 0 : _a.getTheme()) === null || _b === void 0 ? void 0 : _b.text);
|
|
15963
|
-
|
|
15964
|
-
|
|
15965
|
-
|
|
15966
|
-
|
|
15967
|
-
|
|
15968
|
-
|
|
15969
|
-
|
|
15970
|
-
|
|
15971
|
-
|
|
15972
|
-
|
|
15973
|
-
|
|
15974
|
-
if (isValid(maxWidth) && tagWidth > maxWidth) {
|
|
15975
|
-
tagWidth = maxWidth;
|
|
15976
|
-
textShape.setAttribute('maxLineWidth', maxWidth - parsedPadding[1] - parsedPadding[2]);
|
|
15977
|
-
}
|
|
15978
|
-
}
|
|
15979
|
-
tagX = 0;
|
|
15980
|
-
tagY = 0;
|
|
15981
|
-
let flag = 0;
|
|
15982
|
-
if (textAlign === 'left' || textAlign === 'start') {
|
|
15983
|
-
flag = 1;
|
|
15963
|
+
textWidth = textBounds.width;
|
|
15964
|
+
textHeight = textBounds.height;
|
|
15965
|
+
}
|
|
15966
|
+
tagWidth += textWidth;
|
|
15967
|
+
const size = (_c = shape.size) !== null && _c !== void 0 ? _c : 10;
|
|
15968
|
+
const maxSize = (isNumber(size) ? size : Math.max(size[0], size[1]));
|
|
15969
|
+
tagHeight += Math.max(textHeight, shape.visible ? maxSize : 0);
|
|
15970
|
+
const { textAlign, textBaseline } = textStyle;
|
|
15971
|
+
if (isValid(minWidth) || isValid(maxWidth)) {
|
|
15972
|
+
if (isValid(minWidth) && tagWidth < minWidth) {
|
|
15973
|
+
tagWidth = minWidth;
|
|
15984
15974
|
}
|
|
15985
|
-
|
|
15986
|
-
|
|
15975
|
+
if (isValid(maxWidth) && tagWidth > maxWidth) {
|
|
15976
|
+
tagWidth = maxWidth;
|
|
15977
|
+
textShape.setAttribute('maxLineWidth', maxWidth - parsedPadding[1] - parsedPadding[2]);
|
|
15987
15978
|
}
|
|
15988
|
-
|
|
15989
|
-
|
|
15979
|
+
}
|
|
15980
|
+
tagX = 0;
|
|
15981
|
+
tagY = 0;
|
|
15982
|
+
let flag = 0;
|
|
15983
|
+
if (textAlign === 'left' || textAlign === 'start') {
|
|
15984
|
+
flag = 1;
|
|
15985
|
+
}
|
|
15986
|
+
else if (textAlign === 'right' || textAlign === 'end') {
|
|
15987
|
+
flag = -1;
|
|
15988
|
+
}
|
|
15989
|
+
else if (textAlign === 'center') {
|
|
15990
|
+
flag = 0;
|
|
15991
|
+
}
|
|
15992
|
+
if (!flag) {
|
|
15993
|
+
tagX -= tagWidth / 2;
|
|
15994
|
+
if (symbol) {
|
|
15995
|
+
symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth / 2);
|
|
15990
15996
|
}
|
|
15991
|
-
|
|
15992
|
-
|
|
15993
|
-
|
|
15994
|
-
|
|
15995
|
-
|
|
15996
|
-
|
|
15997
|
+
group.setAttribute('x', -symbolPlaceWidth / 2);
|
|
15998
|
+
}
|
|
15999
|
+
else if (flag < 0) {
|
|
16000
|
+
tagX -= tagWidth;
|
|
16001
|
+
if (symbol) {
|
|
16002
|
+
symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth);
|
|
15997
16003
|
}
|
|
15998
|
-
|
|
15999
|
-
|
|
16000
|
-
|
|
16001
|
-
|
|
16002
|
-
|
|
16003
|
-
|
|
16004
|
-
|
|
16005
|
-
|
|
16006
|
-
|
|
16007
|
-
|
|
16008
|
-
const shouldCenter = containerTextAlign ? containerTextAlign === 'center' : textAlwaysCenter;
|
|
16009
|
-
const shouldRight = containerTextAlign === 'right' || containerTextAlign === 'end';
|
|
16010
|
-
const shouldLeft = containerTextAlign === 'left' || containerTextAlign === 'start';
|
|
16011
|
-
if (shouldCenter && flag) {
|
|
16012
|
-
const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];
|
|
16013
|
-
const tsWidth = textWidth + symbolPlaceWidth;
|
|
16014
|
-
const textX = flag === 1
|
|
16015
|
-
? (containerWidth - tsWidth) / 2 + symbolPlaceWidth + textWidth / 2
|
|
16016
|
-
: parsedPadding[0] + symbolPlaceWidth - (tagWidth / 2 + tsWidth / 2 - symbolPlaceWidth) + textWidth / 2;
|
|
16004
|
+
group.setAttribute('x', -parsedPadding[1] - symbolPlaceWidth);
|
|
16005
|
+
}
|
|
16006
|
+
else if (flag > 0) {
|
|
16007
|
+
group.setAttribute('x', parsedPadding[3]);
|
|
16008
|
+
}
|
|
16009
|
+
const shouldCenter = containerTextAlign ? containerTextAlign === 'center' : textAlwaysCenter;
|
|
16010
|
+
const shouldRight = containerTextAlign === 'right' || containerTextAlign === 'end';
|
|
16011
|
+
const shouldLeft = containerTextAlign === 'left' || containerTextAlign === 'start';
|
|
16012
|
+
const updateTextAttrs = (textX, textAlign) => {
|
|
16013
|
+
if (textShape.type === 'richtext') {
|
|
16017
16014
|
textShape.setAttributes({
|
|
16018
16015
|
x: textX,
|
|
16019
|
-
textAlign
|
|
16016
|
+
textAlign,
|
|
16017
|
+
textConfig: array(textShape.attribute.textConfig).map(t => {
|
|
16018
|
+
return Object.assign(Object.assign({}, t), { textAlign });
|
|
16019
|
+
})
|
|
16020
16020
|
});
|
|
16021
|
-
if (symbol) {
|
|
16022
|
-
const symbolX = textX - textWidth / 2 - symbolPlaceWidth + maxSize / 2;
|
|
16023
|
-
symbol.setAttributes({
|
|
16024
|
-
x: symbolX
|
|
16025
|
-
});
|
|
16026
|
-
}
|
|
16027
16021
|
}
|
|
16028
|
-
|
|
16029
|
-
const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];
|
|
16030
|
-
const offset = flag === 0
|
|
16031
|
-
? -containerWidth / 2 + symbolPlaceWidth / 2
|
|
16032
|
-
: -tagWidth + parsedPadding[3] + parsedPadding[1] + symbolPlaceWidth;
|
|
16033
|
-
const textX = offset + symbolPlaceWidth;
|
|
16022
|
+
else {
|
|
16034
16023
|
textShape.setAttributes({
|
|
16035
16024
|
x: textX,
|
|
16036
|
-
textAlign
|
|
16025
|
+
textAlign
|
|
16037
16026
|
});
|
|
16038
|
-
if (symbol) {
|
|
16039
|
-
const symbolX = offset + maxSize / 2;
|
|
16040
|
-
symbol.setAttributes({
|
|
16041
|
-
x: symbolX
|
|
16042
|
-
});
|
|
16043
|
-
}
|
|
16044
16027
|
}
|
|
16045
|
-
|
|
16046
|
-
|
|
16047
|
-
|
|
16048
|
-
|
|
16049
|
-
|
|
16050
|
-
|
|
16028
|
+
};
|
|
16029
|
+
if (shouldCenter && flag) {
|
|
16030
|
+
const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];
|
|
16031
|
+
const tsWidth = textWidth + symbolPlaceWidth;
|
|
16032
|
+
const textX = flag === 1
|
|
16033
|
+
? (containerWidth - tsWidth) / 2 + symbolPlaceWidth + textWidth / 2
|
|
16034
|
+
: parsedPadding[0] + symbolPlaceWidth - (tagWidth / 2 + tsWidth / 2 - symbolPlaceWidth) + textWidth / 2;
|
|
16035
|
+
updateTextAttrs(textX, 'center');
|
|
16036
|
+
if (symbol) {
|
|
16037
|
+
const symbolX = textX - textWidth / 2 - symbolPlaceWidth + maxSize / 2;
|
|
16038
|
+
symbol.setAttributes({
|
|
16039
|
+
x: symbolX
|
|
16051
16040
|
});
|
|
16052
|
-
if (symbol) {
|
|
16053
|
-
const symbolX = textX - textWidth - symbolPlaceWidth + maxSize / 2;
|
|
16054
|
-
symbol.setAttributes({
|
|
16055
|
-
x: symbolX
|
|
16056
|
-
});
|
|
16057
|
-
}
|
|
16058
16041
|
}
|
|
16059
|
-
|
|
16060
|
-
|
|
16061
|
-
|
|
16062
|
-
|
|
16063
|
-
|
|
16042
|
+
}
|
|
16043
|
+
if (shouldLeft && flag !== 1) {
|
|
16044
|
+
const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];
|
|
16045
|
+
const offset = flag === 0
|
|
16046
|
+
? -containerWidth / 2 + symbolPlaceWidth / 2
|
|
16047
|
+
: -tagWidth + parsedPadding[3] + parsedPadding[1] + symbolPlaceWidth;
|
|
16048
|
+
const textX = offset + symbolPlaceWidth;
|
|
16049
|
+
updateTextAttrs(textX, 'left');
|
|
16050
|
+
if (symbol) {
|
|
16051
|
+
const symbolX = offset + maxSize / 2;
|
|
16052
|
+
symbol.setAttributes({
|
|
16053
|
+
x: symbolX
|
|
16054
|
+
});
|
|
16064
16055
|
}
|
|
16065
|
-
|
|
16066
|
-
|
|
16067
|
-
|
|
16068
|
-
|
|
16069
|
-
|
|
16070
|
-
|
|
16056
|
+
}
|
|
16057
|
+
if (shouldRight && flag !== -1) {
|
|
16058
|
+
const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];
|
|
16059
|
+
const textX = flag === 0 ? containerWidth / 2 + symbolPlaceWidth / 2 : containerWidth;
|
|
16060
|
+
updateTextAttrs(textX, 'right');
|
|
16061
|
+
if (symbol) {
|
|
16062
|
+
const symbolX = textX - textWidth - symbolPlaceWidth + maxSize / 2;
|
|
16063
|
+
symbol.setAttributes({
|
|
16064
|
+
x: symbolX
|
|
16065
|
+
});
|
|
16071
16066
|
}
|
|
16072
|
-
|
|
16073
|
-
|
|
16074
|
-
|
|
16075
|
-
|
|
16076
|
-
|
|
16067
|
+
}
|
|
16068
|
+
if (textBaseline === 'middle') {
|
|
16069
|
+
tagY -= tagHeight / 2;
|
|
16070
|
+
if (symbol) {
|
|
16071
|
+
symbol.setAttribute('y', 0);
|
|
16072
|
+
}
|
|
16073
|
+
}
|
|
16074
|
+
else if (textBaseline === 'bottom') {
|
|
16075
|
+
tagY -= tagHeight;
|
|
16076
|
+
if (symbol) {
|
|
16077
|
+
symbol.setAttribute('y', -textHeight / 2);
|
|
16078
|
+
}
|
|
16079
|
+
group.setAttribute('y', -parsedPadding[2]);
|
|
16080
|
+
}
|
|
16081
|
+
else if (textBaseline === 'top') {
|
|
16082
|
+
group.setAttribute('y', parsedPadding[0]);
|
|
16083
|
+
if (symbol) {
|
|
16084
|
+
symbol.setAttribute('y', textHeight / 2);
|
|
16077
16085
|
}
|
|
16078
16086
|
}
|
|
16087
|
+
if (!isEmpty(state === null || state === void 0 ? void 0 : state.text)) {
|
|
16088
|
+
textShape.states = state.text;
|
|
16089
|
+
}
|
|
16079
16090
|
const { visible: bgVisible } = panel, backgroundStyle = __rest(panel, ["visible"]);
|
|
16080
16091
|
if (visible && isBoolean(bgVisible)) {
|
|
16081
16092
|
const bgRect = this.createOrUpdateChild('tag-panel', Object.assign(Object.assign({}, backgroundStyle), { visible: bgVisible && !!text, width: tagWidth, height: tagHeight, x: tagX, y: tagY }), 'rect');
|
|
@@ -20012,10 +20023,11 @@ function bitmapTool(width, height, padding = { top: 0, left: 0, right: 0, bottom
|
|
|
20012
20023
|
}
|
|
20013
20024
|
function clampRangeByBitmap($, range) {
|
|
20014
20025
|
const { x1, x2, y1, y2 } = range;
|
|
20015
|
-
const
|
|
20016
|
-
const
|
|
20017
|
-
const
|
|
20018
|
-
const
|
|
20026
|
+
const { top = 0, left = 0, right = 0, bottom = 0 } = $.padding;
|
|
20027
|
+
const _x1 = clamp(x1, -left, $.width + right);
|
|
20028
|
+
const _x2 = clamp(x2, -left, $.width + right);
|
|
20029
|
+
const _y1 = clamp(y1, -top, $.height + bottom);
|
|
20030
|
+
const _y2 = clamp(y2, -top, $.height + bottom);
|
|
20019
20031
|
return {
|
|
20020
20032
|
x1: $.x(_x1),
|
|
20021
20033
|
x2: $.x(_x2),
|
|
@@ -20186,9 +20198,18 @@ function getAnimationAttributes(textAttribute, type) {
|
|
|
20186
20198
|
return (_b = (_a = animationEffects[type]) === null || _a === void 0 ? void 0 : _a.call(animationEffects, textAttribute)) !== null && _b !== void 0 ? _b : { from: {}, to: {} };
|
|
20187
20199
|
}
|
|
20188
20200
|
function updateAnimation(prev, next, animationConfig) {
|
|
20201
|
+
const changeAttributes = (prev, next) => {
|
|
20202
|
+
const changed = {};
|
|
20203
|
+
for (const key in next.attribute) {
|
|
20204
|
+
if (prev.attribute[key] !== next.attribute[key]) {
|
|
20205
|
+
changed[key] = next.attribute[key];
|
|
20206
|
+
}
|
|
20207
|
+
}
|
|
20208
|
+
return changed;
|
|
20209
|
+
};
|
|
20189
20210
|
if (!isArray(animationConfig)) {
|
|
20190
20211
|
const { duration, easing, increaseEffect = true } = animationConfig;
|
|
20191
|
-
prev.animate().to(next
|
|
20212
|
+
prev.animate().to(changeAttributes(prev, next), duration, easing);
|
|
20192
20213
|
if (increaseEffect && prev.type === 'text' && next.type === 'text') {
|
|
20193
20214
|
playIncreaseCount(prev, next, duration, easing);
|
|
20194
20215
|
}
|
|
@@ -20198,7 +20219,7 @@ function updateAnimation(prev, next, animationConfig) {
|
|
|
20198
20219
|
const { duration, easing, increaseEffect = true, channel } = cfg;
|
|
20199
20220
|
const { to } = update(prev, next, channel, cfg.options);
|
|
20200
20221
|
if (!isEmpty(to)) {
|
|
20201
|
-
prev.animate().to(
|
|
20222
|
+
prev.animate().to(changeAttributes(prev, next), duration, easing);
|
|
20202
20223
|
}
|
|
20203
20224
|
if (increaseEffect && prev.type === 'text' && next.type === 'text') {
|
|
20204
20225
|
playIncreaseCount(prev, next, duration, easing);
|
|
@@ -20957,7 +20978,9 @@ class LabelBase extends AbstractComponent {
|
|
|
20957
20978
|
return this._overlapByStrategy(labels, option, bmpTool, bitmap);
|
|
20958
20979
|
}
|
|
20959
20980
|
_overlapGlobal(labels, option, bmpTool, bitmap) {
|
|
20960
|
-
let result = labels.filter(label => label.attribute.visible &&
|
|
20981
|
+
let result = labels.filter(label => label.attribute.visible &&
|
|
20982
|
+
label.attribute.opacity !== 0 &&
|
|
20983
|
+
this.isMarkInsideRect(this.getRelatedGraphic(label.attribute), bmpTool));
|
|
20961
20984
|
const { clampForce = true, hideOnHit = true, overlapPadding, strategy } = option;
|
|
20962
20985
|
if (clampForce) {
|
|
20963
20986
|
for (let i = 0; i < result.length; i++) {
|
|
@@ -21049,7 +21072,7 @@ class LabelBase extends AbstractComponent {
|
|
|
21049
21072
|
const text = labels[i];
|
|
21050
21073
|
const baseMark = this.getRelatedGraphic(text.attribute);
|
|
21051
21074
|
text.update();
|
|
21052
|
-
if (!
|
|
21075
|
+
if (!this.isMarkInsideRect(baseMark, bmpTool)) {
|
|
21053
21076
|
continue;
|
|
21054
21077
|
}
|
|
21055
21078
|
if (canPlace(bmpTool, bitmap, text.AABBBounds, clampForce, overlapPadding)) {
|
|
@@ -21089,6 +21112,23 @@ class LabelBase extends AbstractComponent {
|
|
|
21089
21112
|
}
|
|
21090
21113
|
return result;
|
|
21091
21114
|
}
|
|
21115
|
+
isMarkInsideRect(baseMark, bmpTool) {
|
|
21116
|
+
const { left, right, top, bottom } = bmpTool.padding;
|
|
21117
|
+
const rect = { x1: -left, x2: bmpTool.width + right, y1: -top, y2: bmpTool.height + bottom };
|
|
21118
|
+
const bounds = baseMark.AABBBounds;
|
|
21119
|
+
if (bounds.width() !== 0 && bounds.height() !== 0) {
|
|
21120
|
+
return isRectIntersect(baseMark.AABBBounds, rect, true);
|
|
21121
|
+
}
|
|
21122
|
+
const { attribute } = baseMark;
|
|
21123
|
+
if (baseMark.type === 'rect') {
|
|
21124
|
+
const { x, x1, y, y1 } = attribute;
|
|
21125
|
+
return pointInRect({ x: x !== null && x !== void 0 ? x : x1, y: y !== null && y !== void 0 ? y : y1 }, rect, true);
|
|
21126
|
+
}
|
|
21127
|
+
else if ('x' in attribute && 'y' in attribute) {
|
|
21128
|
+
return pointInRect({ x: attribute.x, y: attribute.y }, rect, true);
|
|
21129
|
+
}
|
|
21130
|
+
return false;
|
|
21131
|
+
}
|
|
21092
21132
|
getBaseMarkGroup() {
|
|
21093
21133
|
const { baseMarkGroupName } = this.attribute;
|
|
21094
21134
|
if (!baseMarkGroupName) {
|
|
@@ -31460,6 +31500,6 @@ StoryLabelItem.defaultAttributes = {
|
|
|
31460
31500
|
theme: 'default'
|
|
31461
31501
|
};
|
|
31462
31502
|
|
|
31463
|
-
const version = "0.22.
|
|
31503
|
+
const version = "0.22.7-alpha.0";
|
|
31464
31504
|
|
|
31465
31505
|
export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PolygonSectorCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, StoryLabelItem, Switch, SymbolLabel, Tag, Timeline, Title, Tooltip, TopZIndex, VTag, WeatherBox, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, getAxisBreakSymbolAttrs, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, hasOverlap, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, limitShapeInBounds, linearDiscreteTicks, loadPoptip, loadScrollbar, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, scrollbarModule, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, textIntersect, ticks, traverseGroup, version };
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
package/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAExC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.22.
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAExC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.22.7-alpha.0\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './timeline';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './empty-tip';\nexport * from './weather';\nexport * from './util';\nexport * from './switch';\nexport * from './label-item';\n"]}
|
|
@@ -44,13 +44,19 @@ export function getAnimationAttributes(textAttribute, type) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export function updateAnimation(prev, next, animationConfig) {
|
|
47
|
+
const changeAttributes = (prev, next) => {
|
|
48
|
+
const changed = {};
|
|
49
|
+
for (const key in next.attribute) prev.attribute[key] !== next.attribute[key] && (changed[key] = next.attribute[key]);
|
|
50
|
+
return changed;
|
|
51
|
+
};
|
|
47
52
|
if (!isArray(animationConfig)) {
|
|
48
53
|
const {duration: duration, easing: easing, increaseEffect: increaseEffect = !0} = animationConfig;
|
|
49
|
-
return prev.animate().to(next
|
|
54
|
+
return prev.animate().to(changeAttributes(prev, next), duration, easing), void (increaseEffect && "text" === prev.type && "text" === next.type && playIncreaseCount(prev, next, duration, easing));
|
|
50
55
|
}
|
|
51
56
|
animationConfig.forEach((cfg => {
|
|
52
57
|
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(
|
|
58
|
+
isEmpty(to) || prev.animate().to(changeAttributes(prev, next), duration, easing),
|
|
59
|
+
increaseEffect && "text" === prev.type && "text" === next.type && playIncreaseCount(prev, next, duration, easing);
|
|
54
60
|
}));
|
|
55
61
|
}
|
|
56
62
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/label/animate/animate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE1E,MAAM,MAAM,GAAG,CAAC,gBAAuC,EAAE,EAAE,EAAE;;IAC3D,OAAO;QACL,IAAI,EAAE;YACJ,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,CAAC;YACd,aAAa,EAAE,CAAC;SACjB;QACD,EAAE,EAAE;YACF,OAAO,EAAE,MAAA,aAAa,CAAC,OAAO,mCAAI,CAAC;YACnC,WAAW,EAAE,MAAA,aAAa,CAAC,WAAW,mCAAI,CAAC;YAC3C,aAAa,EAAE,MAAA,aAAa,CAAC,aAAa,mCAAI,CAAC;SAChD;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,CAAC,gBAAuC,E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,EAAE,GAAG;IACb,MAAM,EAAE,QAAsB;CAC/B,CAAC","file":"animate.js","sourcesContent":["import type { IText, ITextGraphicAttribute, EasingType } from '@visactor/vrender-core';\nimport { IncreaseCount } from '@visactor/vrender-core';\nimport type { ILabelAnimation, ILabelUpdateAnimation, ILabelUpdateChannelAnimation, LabelContent } from '../type';\nimport { array, isArray, isEmpty, isValidNumber } from '@visactor/vutils';\n\nconst fadeIn = (textAttribute: ITextGraphicAttribute = {}) => {\n return {\n from: {\n opacity: 0,\n fillOpacity: 0,\n strokeOpacity: 0\n },\n to: {\n opacity: textAttribute.opacity ?? 1,\n fillOpacity: textAttribute.fillOpacity ?? 1,\n strokeOpacity: textAttribute.strokeOpacity ?? 1\n }\n };\n};\n\nconst fadeOut = (textAttribute: ITextGraphicAttribute = {}) => {\n return {\n from: {\n opacity: textAttribute.opacity ?? 1,\n fillOpacity: textAttribute.fillOpacity ?? 1,\n strokeOpacity: textAttribute.strokeOpacity ?? 1\n },\n to: {\n opacity: 0,\n fillOpacity: 0,\n strokeOpacity: 0\n }\n };\n};\n\nconst animationEffects = { fadeIn, fadeOut };\n\nexport function getAnimationAttributes(\n textAttribute: ITextGraphicAttribute,\n type: 'fadeIn' | 'fadeOut'\n): {\n from: any;\n to: any;\n} {\n return animationEffects[type]?.(textAttribute) ?? { from: {}, to: {} };\n}\n\nexport function updateAnimation(\n prev: LabelContent['text'],\n next: LabelContent['text'],\n animationConfig: ILabelUpdateAnimation | ILabelUpdateChannelAnimation[]\n) {\n const changeAttributes = (prev: LabelContent['text'], next: LabelContent['text']) => {\n const changed = {};\n for (const key in next.attribute) {\n if (prev.attribute[key] !== next.attribute[key]) {\n changed[key] = next.attribute[key];\n }\n }\n return changed;\n };\n\n if (!isArray(animationConfig)) {\n const { duration, easing, increaseEffect = true } = animationConfig;\n\n prev.animate().to(changeAttributes(prev, next), duration, easing);\n if (increaseEffect && prev.type === 'text' && next.type === 'text') {\n playIncreaseCount(prev as IText, next as IText, duration, easing);\n }\n return;\n }\n\n animationConfig.forEach(cfg => {\n const { duration, easing, increaseEffect = true, channel } = cfg;\n const { to } = update(prev, next, channel, cfg.options);\n if (!isEmpty(to)) {\n prev.animate().to(changeAttributes(prev, next), duration, easing);\n }\n\n if (increaseEffect && prev.type === 'text' && next.type === 'text') {\n playIncreaseCount(prev as IText, next as IText, duration, easing);\n }\n });\n}\n\nexport const update = (\n prev: LabelContent['text'],\n next: LabelContent['text'],\n channel?: string[],\n options?: ILabelUpdateChannelAnimation['options']\n) => {\n const from = Object.assign({}, prev.attribute);\n const to = Object.assign({}, next.attribute);\n array(options?.excludeChannels).forEach(key => {\n delete to[key];\n });\n Object.keys(to).forEach(key => {\n if (channel && !channel.includes(key)) {\n delete to[key];\n }\n });\n return { from, to };\n};\n\nexport function playIncreaseCount(prev: IText, next: IText, duration: number, easing: EasingType) {\n if (\n prev.attribute.text !== next.attribute.text &&\n isValidNumber(Number(prev.attribute.text) * Number(next.attribute.text))\n ) {\n prev\n .animate()\n .play(\n new IncreaseCount(\n { text: prev.attribute.text as string },\n { text: next.attribute.text as string },\n duration,\n easing\n )\n );\n }\n}\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
|
@@ -52,6 +52,7 @@ 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;
|
package/es/label/base.js
CHANGED
|
@@ -10,7 +10,7 @@ var __rest = this && this.__rest || function(s, e) {
|
|
|
10
10
|
|
|
11
11
|
import { graphicCreator, AttributeUpdateType, IContainPointMode, CustomPath2D } from "@visactor/vrender-core";
|
|
12
12
|
|
|
13
|
-
import { isFunction, isEmpty, isValid, isString, merge, isRectIntersect, isNil, isArray, isObject } from "@visactor/vutils";
|
|
13
|
+
import { isFunction, isEmpty, isValid, isString, merge, isRectIntersect, isNil, isArray, isObject, pointInRect } from "@visactor/vutils";
|
|
14
14
|
|
|
15
15
|
import { AbstractComponent } from "../core/base";
|
|
16
16
|
|
|
@@ -220,7 +220,7 @@ export class LabelBase extends AbstractComponent {
|
|
|
220
220
|
"shiftY" === (null == strategy ? void 0 : strategy.type) ? this._overlapGlobal(labels, option, bmpTool, bitmap) : this._overlapByStrategy(labels, option, bmpTool, bitmap);
|
|
221
221
|
}
|
|
222
222
|
_overlapGlobal(labels, option, bmpTool, bitmap) {
|
|
223
|
-
let result = labels.filter((label => label.attribute.visible && 0 !== label.attribute.opacity));
|
|
223
|
+
let result = labels.filter((label => label.attribute.visible && 0 !== label.attribute.opacity && this.isMarkInsideRect(this.getRelatedGraphic(label.attribute), bmpTool)));
|
|
224
224
|
const {clampForce: clampForce = !0, hideOnHit: hideOnHit = !0, overlapPadding: overlapPadding, strategy: strategy} = option;
|
|
225
225
|
if (clampForce) for (let i = 0; i < result.length; i++) {
|
|
226
226
|
const text = labels[i], {dx: dx = 0, dy: dy = 0} = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
|
|
@@ -279,12 +279,7 @@ export class LabelBase extends AbstractComponent {
|
|
|
279
279
|
for (let i = 0; i < labels.length; i++) {
|
|
280
280
|
if (!1 === labels[i].attribute.visible) continue;
|
|
281
281
|
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;
|
|
282
|
+
if (text.update(), !this.isMarkInsideRect(baseMark, bmpTool)) continue;
|
|
288
283
|
if (canPlace(bmpTool, bitmap, text.AABBBounds, clampForce, overlapPadding)) {
|
|
289
284
|
if (!checkBounds) {
|
|
290
285
|
bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(text);
|
|
@@ -314,6 +309,27 @@ export class LabelBase extends AbstractComponent {
|
|
|
314
309
|
}
|
|
315
310
|
return result;
|
|
316
311
|
}
|
|
312
|
+
isMarkInsideRect(baseMark, bmpTool) {
|
|
313
|
+
const {left: left, right: right, top: top, bottom: bottom} = bmpTool.padding, rect = {
|
|
314
|
+
x1: -left,
|
|
315
|
+
x2: bmpTool.width + right,
|
|
316
|
+
y1: -top,
|
|
317
|
+
y2: bmpTool.height + bottom
|
|
318
|
+
}, bounds = baseMark.AABBBounds;
|
|
319
|
+
if (0 !== bounds.width() && 0 !== bounds.height()) return isRectIntersect(baseMark.AABBBounds, rect, !0);
|
|
320
|
+
const {attribute: attribute} = baseMark;
|
|
321
|
+
if ("rect" === baseMark.type) {
|
|
322
|
+
const {x: x, x1: x1, y: y, y1: y1} = attribute;
|
|
323
|
+
return pointInRect({
|
|
324
|
+
x: null != x ? x : x1,
|
|
325
|
+
y: null != y ? y : y1
|
|
326
|
+
}, rect, !0);
|
|
327
|
+
}
|
|
328
|
+
return "x" in attribute && "y" in attribute && pointInRect({
|
|
329
|
+
x: attribute.x,
|
|
330
|
+
y: attribute.y
|
|
331
|
+
}, rect, !0);
|
|
332
|
+
}
|
|
317
333
|
getBaseMarkGroup() {
|
|
318
334
|
const {baseMarkGroupName: baseMarkGroupName} = this.attribute;
|
|
319
335
|
if (baseMarkGroupName) return this.getRootNode().find((node => node.name === baseMarkGroupName), !0);
|