@visactor/vchart 1.1.1-beta.1 → 1.1.1
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/build/index.js +65 -120
- package/build/index.min.js +1 -1
- package/cjs/core/index.d.ts +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/index.js.map +1 -1
- package/esm/core/index.d.ts +1 -1
- package/esm/core/index.js +1 -1
- package/esm/core/index.js.map +1 -1
- package/package.json +3 -3
package/build/index.js
CHANGED
|
@@ -41365,24 +41365,6 @@
|
|
|
41365
41365
|
function defaultLabelPosition(type) {
|
|
41366
41366
|
return "rect" === type ? DefaultRectPositions : DefaultPositions;
|
|
41367
41367
|
}
|
|
41368
|
-
function clampText(text, width, height) {
|
|
41369
|
-
const {
|
|
41370
|
-
x1: x1,
|
|
41371
|
-
x2: x2,
|
|
41372
|
-
y1: y1,
|
|
41373
|
-
y2: y2
|
|
41374
|
-
} = text.AABBBounds,
|
|
41375
|
-
minX = Math.min(x1, x2),
|
|
41376
|
-
maxX = Math.max(x1, x2),
|
|
41377
|
-
minY = Math.min(y1, y2),
|
|
41378
|
-
maxY = Math.max(y1, y2);
|
|
41379
|
-
let dx = 0,
|
|
41380
|
-
dy = 0;
|
|
41381
|
-
return minX < 0 && maxX - minX <= width ? dx = -minX : maxX > width && minX - (maxX - width) >= 0 && (dx = width - maxX), minY < 0 && maxY - minY <= height ? dy = -minY : maxY > height && minY - (maxY - height) >= 0 && (dy = height - maxY), {
|
|
41382
|
-
dx: dx,
|
|
41383
|
-
dy: dy
|
|
41384
|
-
};
|
|
41385
|
-
}
|
|
41386
41368
|
|
|
41387
41369
|
const fadeIn = function () {
|
|
41388
41370
|
let textAttribute = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -41461,17 +41443,9 @@
|
|
|
41461
41443
|
this._bmpTool = bmpTool;
|
|
41462
41444
|
}
|
|
41463
41445
|
render() {
|
|
41464
|
-
this.
|
|
41465
|
-
|
|
41466
|
-
|
|
41467
|
-
smartInvert: smartInvert,
|
|
41468
|
-
dataFilter: dataFilter,
|
|
41469
|
-
customLayoutFunc: customLayoutFunc,
|
|
41470
|
-
customOverlapFunc: customOverlapFunc
|
|
41471
|
-
} = this.attribute;
|
|
41472
|
-
let labels,
|
|
41473
|
-
data = this.attribute.data;
|
|
41474
|
-
isFunction(dataFilter) && (data = dataFilter(data)), isFunction(customLayoutFunc) ? labels = customLayoutFunc(data, d => this._idToGraphic.get(d.id)) : (labels = this.layout(data), isFunction(customOverlapFunc) ? labels = customOverlapFunc(labels, d => this._idToGraphic.get(d.id)) : !1 !== overlap && (labels = this._overlapping(labels))), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels);
|
|
41446
|
+
const currentBaseMarks = this._checkMarks(),
|
|
41447
|
+
labels = this.layout(currentBaseMarks);
|
|
41448
|
+
this._smartInvert(labels), this._renderLabels(labels);
|
|
41475
41449
|
}
|
|
41476
41450
|
_bindEvent(target) {
|
|
41477
41451
|
if (!target) return;
|
|
@@ -41490,53 +41464,52 @@
|
|
|
41490
41464
|
const text = createText(attributes);
|
|
41491
41465
|
return this._bindEvent(text), this._setStates(text), text;
|
|
41492
41466
|
}
|
|
41493
|
-
|
|
41467
|
+
_checkMarks() {
|
|
41494
41468
|
var _a;
|
|
41495
41469
|
const baseMarks = this.getBaseMarks(),
|
|
41496
41470
|
currentBaseMarks = [];
|
|
41497
|
-
|
|
41471
|
+
return baseMarks.forEach(mark => {
|
|
41498
41472
|
"willRelease" !== mark.releaseStatus && currentBaseMarks.push(mark);
|
|
41499
|
-
}), null === (_a = this.
|
|
41473
|
+
}), this._prevRelationMap = new Map(this._relationMap), null === (_a = this._relationMap) || void 0 === _a || _a.clear(), currentBaseMarks;
|
|
41474
|
+
}
|
|
41475
|
+
layout(currentMarks) {
|
|
41500
41476
|
const {
|
|
41477
|
+
textStyle: textStyle,
|
|
41478
|
+
position: position,
|
|
41479
|
+
offset: offset
|
|
41480
|
+
} = this.attribute;
|
|
41481
|
+
let {
|
|
41501
41482
|
data: data
|
|
41502
41483
|
} = this.attribute;
|
|
41503
|
-
if (data && 0
|
|
41504
|
-
|
|
41505
|
-
|
|
41506
|
-
const textData = data[i],
|
|
41507
|
-
baseMark = currentBaseMarks[i];
|
|
41508
|
-
textData && baseMark && (isValid(textData.id) || (textData.id = `vrender-component-${this.name}-${i}`), this._idToGraphic.set(textData.id, baseMark));
|
|
41509
|
-
}
|
|
41510
|
-
}
|
|
41511
|
-
}
|
|
41512
|
-
layout() {
|
|
41513
|
-
let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
41514
|
-
const {
|
|
41515
|
-
textStyle = {},
|
|
41516
|
-
position: position,
|
|
41517
|
-
offset: offset
|
|
41518
|
-
} = this.attribute,
|
|
41519
|
-
labels = [];
|
|
41484
|
+
if (isFunction(data) && (data = data({})), !data || 0 === data.length) return [];
|
|
41485
|
+
let labels = [];
|
|
41486
|
+
isFunction(this.attribute.sort) && currentMarks && currentMarks.length && (currentMarks = currentMarks.sort(this.attribute.sort)), this._relationMap || (this._relationMap = new Map());
|
|
41520
41487
|
for (let i = 0; i < data.length; i++) {
|
|
41521
41488
|
const textData = data[i],
|
|
41522
|
-
baseMark =
|
|
41523
|
-
labelAttribute = Object.assign(Object.assign({}, textStyle), textData),
|
|
41524
|
-
|
|
41525
|
-
|
|
41526
|
-
|
|
41527
|
-
|
|
41528
|
-
|
|
41529
|
-
|
|
41530
|
-
|
|
41531
|
-
|
|
41489
|
+
baseMark = null == currentMarks ? void 0 : currentMarks[i],
|
|
41490
|
+
labelAttribute = Object.assign(Object.assign(Object.assign({}, textStyle), textData), {
|
|
41491
|
+
_relatedIndex: i
|
|
41492
|
+
});
|
|
41493
|
+
if (this._relationMap.set(i, baseMark), textData) {
|
|
41494
|
+
const text = createText(labelAttribute);
|
|
41495
|
+
text.update();
|
|
41496
|
+
const textBounds = this.getGraphicBounds(text),
|
|
41497
|
+
graphicBounds = this.getGraphicBounds(baseMark, {
|
|
41498
|
+
x: textData.x,
|
|
41499
|
+
y: textData.y
|
|
41500
|
+
}),
|
|
41501
|
+
textAttributes = this.labeling(textBounds, graphicBounds, isFunction(position) ? position(textData) : position, offset);
|
|
41502
|
+
if (!textAttributes) continue;
|
|
41503
|
+
labelAttribute.x = textAttributes.x, labelAttribute.y = textAttributes.y, labels.push(labelAttribute);
|
|
41504
|
+
}
|
|
41532
41505
|
}
|
|
41533
|
-
return labels;
|
|
41506
|
+
return this._baseMarks = currentMarks, !1 !== this.attribute.overlap && (labels = this.overlapping(labels, this.attribute.overlap)), labels;
|
|
41534
41507
|
}
|
|
41535
|
-
|
|
41536
|
-
|
|
41508
|
+
overlapping(labels) {
|
|
41509
|
+
let option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
41510
|
+
var _a, _b, _c, _d, _e;
|
|
41537
41511
|
if (0 === labels.length) return [];
|
|
41538
|
-
const
|
|
41539
|
-
result = [],
|
|
41512
|
+
const result = [],
|
|
41540
41513
|
baseMarkGroup = this.getBaseMarkGroup(),
|
|
41541
41514
|
size = null !== (_a = option.size) && void 0 !== _a ? _a : {
|
|
41542
41515
|
width: null !== (_b = null == baseMarkGroup ? void 0 : baseMarkGroup.AABBBounds.width()) && void 0 !== _b ? _b : 0,
|
|
@@ -41557,45 +41530,27 @@
|
|
|
41557
41530
|
}));
|
|
41558
41531
|
for (let i = 0; i < labels.length; i++) {
|
|
41559
41532
|
if (!1 === labels[i].visible) continue;
|
|
41560
|
-
const text = labels[i],
|
|
41561
|
-
baseMark = this.
|
|
41533
|
+
const text = createText(labels[i]),
|
|
41534
|
+
baseMark = null === (_e = this._baseMarks) || void 0 === _e ? void 0 : _e[i];
|
|
41562
41535
|
if (text.update(), canPlace(bmpTool, bitmap, text.AABBBounds, clampForce)) {
|
|
41563
41536
|
if (!checkBounds) {
|
|
41564
|
-
bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(text);
|
|
41537
|
+
bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(Object.assign({}, text.attribute));
|
|
41565
41538
|
continue;
|
|
41566
41539
|
}
|
|
41567
41540
|
if (checkBounds && (null == baseMark ? void 0 : baseMark.AABBBounds) && canPlaceInside(text.AABBBounds, null == baseMark ? void 0 : baseMark.AABBBounds)) {
|
|
41568
|
-
bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(text);
|
|
41569
|
-
continue;
|
|
41570
|
-
}
|
|
41571
|
-
}
|
|
41572
|
-
if (clampForce) {
|
|
41573
|
-
const {
|
|
41574
|
-
dx = 0,
|
|
41575
|
-
dy = 0
|
|
41576
|
-
} = clampText(text, bmpTool.width, bmpTool.height);
|
|
41577
|
-
if ((0 !== dx || 0 !== dy) && canPlace(bmpTool, bitmap, {
|
|
41578
|
-
x1: text.AABBBounds.x1 + dx,
|
|
41579
|
-
x2: text.AABBBounds.x2 + dx,
|
|
41580
|
-
y1: text.AABBBounds.y1 + dy,
|
|
41581
|
-
y2: text.AABBBounds.y2 + dy
|
|
41582
|
-
})) {
|
|
41583
|
-
text.setAttributes({
|
|
41584
|
-
x: text.attribute.x + dx,
|
|
41585
|
-
y: text.attribute.y + dy
|
|
41586
|
-
}), result.push(text);
|
|
41541
|
+
bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(Object.assign({}, text.attribute));
|
|
41587
41542
|
continue;
|
|
41588
41543
|
}
|
|
41589
41544
|
}
|
|
41590
41545
|
let hasPlace = !1;
|
|
41591
41546
|
for (let j = 0; j < strategy.length; j++) if (hasPlace = place$2(bmpTool, bitmap, strategy[j], this.attribute, text, this.getGraphicBounds(baseMark, labels[i]), this.labeling), !1 !== hasPlace) {
|
|
41592
|
-
|
|
41547
|
+
result.push(Object.assign(Object.assign({}, text.attribute), {
|
|
41593
41548
|
x: hasPlace.x,
|
|
41594
41549
|
y: hasPlace.y
|
|
41595
|
-
})
|
|
41550
|
+
}));
|
|
41596
41551
|
break;
|
|
41597
41552
|
}
|
|
41598
|
-
!hasPlace && !hideOnHit && result.push(text);
|
|
41553
|
+
!hasPlace && !hideOnHit && result.push(Object.assign({}, text.attribute));
|
|
41599
41554
|
}
|
|
41600
41555
|
return isFunction(this.onAfterLabelOverlap) && this.onAfterLabelOverlap(bitmap), result;
|
|
41601
41556
|
}
|
|
@@ -41627,16 +41582,17 @@
|
|
|
41627
41582
|
easing = null !== (_d = animationConfig.easing) && void 0 !== _d ? _d : DefaultLabelAnimation.easing,
|
|
41628
41583
|
delay = null !== (_e = animationConfig.delay) && void 0 !== _e ? _e : 0,
|
|
41629
41584
|
currentTextMap = new Map(),
|
|
41630
|
-
prevTextMap = this.
|
|
41585
|
+
prevTextMap = this._textMap || new Map(),
|
|
41631
41586
|
texts = [];
|
|
41632
|
-
labels.forEach((
|
|
41633
|
-
const
|
|
41587
|
+
labels.forEach((label, index) => {
|
|
41588
|
+
const text = this._createLabelText(label),
|
|
41589
|
+
relatedGraphic = this._relationMap.get(label._relatedIndex),
|
|
41634
41590
|
state = (null == prevTextMap ? void 0 : prevTextMap.get(relatedGraphic)) ? "update" : "enter";
|
|
41635
41591
|
if ("enter" === state) if (texts.push(text), currentTextMap.set(relatedGraphic, text), !disableAnimation && relatedGraphic) {
|
|
41636
41592
|
const {
|
|
41637
41593
|
from: from,
|
|
41638
41594
|
to: to
|
|
41639
|
-
} = getAnimationAttributes(
|
|
41595
|
+
} = getAnimationAttributes(label, "fadeIn");
|
|
41640
41596
|
this.add(text), relatedGraphic.onAnimateBind = () => {
|
|
41641
41597
|
text.setAttributes(from);
|
|
41642
41598
|
const listener = this._afterRelatedGraphicAttributeUpdate(text, texts, index, relatedGraphic, {
|
|
@@ -41661,7 +41617,7 @@
|
|
|
41661
41617
|
disableAnimation ? this.removeChild(label) : null == label || label.animate().to(getAnimationAttributes(label.attribute, "fadeOut").to, duration, easing).onEnd(() => {
|
|
41662
41618
|
this.removeChild(label);
|
|
41663
41619
|
});
|
|
41664
|
-
}), this.
|
|
41620
|
+
}), this._textMap = currentTextMap;
|
|
41665
41621
|
}
|
|
41666
41622
|
_afterRelatedGraphicAttributeUpdate(text, texts, index, relatedGraphic, _ref) {
|
|
41667
41623
|
let {
|
|
@@ -41704,32 +41660,21 @@
|
|
|
41704
41660
|
return listener;
|
|
41705
41661
|
}
|
|
41706
41662
|
_smartInvert(labels) {
|
|
41707
|
-
|
|
41708
|
-
|
|
41709
|
-
|
|
41710
|
-
contrastRatiosThreshold: contrastRatiosThreshold,
|
|
41711
|
-
alternativeColors: alternativeColors
|
|
41712
|
-
} = option;
|
|
41713
|
-
for (let i = 0; i < labels.length; i++) {
|
|
41714
|
-
const label = labels[i];
|
|
41663
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
41664
|
+
if (!1 !== this.attribute.smartInvert) for (let i = 0; i < labels.length; i++) {
|
|
41665
|
+
const label = null == labels ? void 0 : labels[i];
|
|
41715
41666
|
if (!label) continue;
|
|
41716
|
-
const
|
|
41717
|
-
|
|
41718
|
-
|
|
41719
|
-
|
|
41720
|
-
|
|
41721
|
-
|
|
41722
|
-
|
|
41723
|
-
label.
|
|
41724
|
-
|
|
41725
|
-
|
|
41726
|
-
|
|
41727
|
-
const backgroundColor = label.attribute.stroke,
|
|
41728
|
-
foregroundColor = label.attribute.fill;
|
|
41729
|
-
label.setAttributes({
|
|
41730
|
-
stroke: baseMark.attribute.fill,
|
|
41731
|
-
fill: labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors)
|
|
41732
|
-
});
|
|
41667
|
+
const isInside = canPlaceInside(createText(label).AABBBounds, null === (_a = this._relationMap.get(label._relatedIndex)) || void 0 === _a ? void 0 : _a.AABBBounds);
|
|
41668
|
+
if (label.stroke && label.lineWidth > 0) label.fill = labelSmartInvert(label.fill, label.stroke, null === (_b = this.attribute.smartInvert) || void 0 === _b ? void 0 : _b.textType, null === (_c = this.attribute.smartInvert) || void 0 === _c ? void 0 : _c.contrastRatiosThreshold, null === (_d = this.attribute.smartInvert) || void 0 === _d ? void 0 : _d.alternativeColors);else if (isInside) {
|
|
41669
|
+
const backgroundColor = this._relationMap.get(label._relatedIndex).attribute.fill,
|
|
41670
|
+
foregroundColor = label.fill;
|
|
41671
|
+
label.fill = labelSmartInvert(foregroundColor, backgroundColor, null === (_e = this.attribute.smartInvert) || void 0 === _e ? void 0 : _e.textType, null === (_f = this.attribute.smartInvert) || void 0 === _f ? void 0 : _f.contrastRatiosThreshold, null === (_g = this.attribute.smartInvert) || void 0 === _g ? void 0 : _g.alternativeColors);
|
|
41672
|
+
} else if (label.lineWidth > 0) {
|
|
41673
|
+
const baseMark = this._relationMap.get(label._relatedIndex);
|
|
41674
|
+
label.stroke = baseMark.attribute.fill;
|
|
41675
|
+
const backgroundColor = label.stroke,
|
|
41676
|
+
foregroundColor = label.fill;
|
|
41677
|
+
label.fill = labelSmartInvert(foregroundColor, backgroundColor, null === (_h = this.attribute.smartInvert) || void 0 === _h ? void 0 : _h.textType, null === (_j = this.attribute.smartInvert) || void 0 === _j ? void 0 : _j.contrastRatiosThreshold, null === (_k = this.attribute.smartInvert) || void 0 === _k ? void 0 : _k.alternativeColors);
|
|
41733
41678
|
}
|
|
41734
41679
|
}
|
|
41735
41680
|
}
|
|
@@ -58088,7 +58033,7 @@
|
|
|
58088
58033
|
VChart.useMark([ComponentMark, GroupMark, ImageMark]);
|
|
58089
58034
|
Factory.registerRegion('region', Region);
|
|
58090
58035
|
Factory.registerLayout('base', Layout);
|
|
58091
|
-
const version = "1.1.1
|
|
58036
|
+
const version = "1.1.1";
|
|
58092
58037
|
Logger.getInstance(LoggerLevel.Error);
|
|
58093
58038
|
|
|
58094
58039
|
var SeriesMarkNameEnum;
|