@visactor/vrender-components 0.14.3 → 0.14.5-alpha.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/cjs/axis/base.d.ts +4 -0
- package/cjs/axis/base.js +3 -5
- package/cjs/axis/base.js.map +1 -1
- package/cjs/axis/circle.d.ts +5 -1
- package/cjs/axis/circle.js +6 -0
- package/cjs/axis/circle.js.map +1 -1
- package/cjs/axis/line.d.ts +5 -0
- package/cjs/axis/line.js +10 -3
- package/cjs/axis/line.js.map +1 -1
- package/cjs/axis/overlap/auto-rotate.d.ts +9 -1
- package/cjs/axis/overlap/auto-rotate.js +41 -30
- package/cjs/axis/overlap/auto-rotate.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/label/arc.d.ts +4 -9
- package/cjs/label/arc.js +56 -48
- package/cjs/label/arc.js.map +1 -1
- package/cjs/label/base.d.ts +5 -3
- package/cjs/label/base.js +79 -46
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/type.d.ts +7 -1
- package/cjs/label/type.js.map +1 -1
- package/cjs/legend/discrete/discrete.js +11 -6
- package/cjs/legend/discrete/discrete.js.map +1 -1
- package/cjs/util/labelSmartInvert.d.ts +2 -1
- package/cjs/util/labelSmartInvert.js +2 -2
- package/cjs/util/labelSmartInvert.js.map +1 -1
- package/dist/index.js +217 -145
- package/dist/index.min.js +1 -1
- package/es/axis/base.d.ts +4 -0
- package/es/axis/base.js +3 -5
- package/es/axis/base.js.map +1 -1
- package/es/axis/circle.d.ts +5 -1
- package/es/axis/circle.js +6 -0
- package/es/axis/circle.js.map +1 -1
- package/es/axis/line.d.ts +5 -0
- package/es/axis/line.js +11 -3
- package/es/axis/line.js.map +1 -1
- package/es/axis/overlap/auto-rotate.d.ts +9 -1
- package/es/axis/overlap/auto-rotate.js +38 -28
- package/es/axis/overlap/auto-rotate.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/label/arc.d.ts +4 -9
- package/es/label/arc.js +37 -32
- package/es/label/arc.js.map +1 -1
- package/es/label/base.d.ts +5 -3
- package/es/label/base.js +77 -48
- package/es/label/base.js.map +1 -1
- package/es/label/type.d.ts +7 -1
- package/es/label/type.js.map +1 -1
- package/es/legend/discrete/discrete.js +11 -6
- package/es/legend/discrete/discrete.js.map +1 -1
- package/es/util/labelSmartInvert.d.ts +2 -1
- package/es/util/labelSmartInvert.js +1 -1
- package/es/util/labelSmartInvert.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1587,7 +1587,7 @@
|
|
|
1587
1587
|
setBitmapTool(bmpTool) {
|
|
1588
1588
|
this._bmpTool = bmpTool;
|
|
1589
1589
|
}
|
|
1590
|
-
layoutArcLabels(position, attribute, currentMarks, data, textBoundsArray) {
|
|
1590
|
+
layoutArcLabels(position, attribute, currentMarks, data, textBoundsArray, ellipsisWidth) {
|
|
1591
1591
|
const arcs = [];
|
|
1592
1592
|
return arcs;
|
|
1593
1593
|
}
|
|
@@ -1680,7 +1680,6 @@
|
|
|
1680
1680
|
}
|
|
1681
1681
|
}
|
|
1682
1682
|
layout(data = []) {
|
|
1683
|
-
var _a;
|
|
1684
1683
|
const { textStyle = {}, position, offset } = this.attribute;
|
|
1685
1684
|
const labels = [];
|
|
1686
1685
|
const textBoundsArray = [];
|
|
@@ -1702,15 +1701,23 @@
|
|
|
1702
1701
|
labels.push(text);
|
|
1703
1702
|
}
|
|
1704
1703
|
if (this.attribute.type === 'arc') {
|
|
1705
|
-
const
|
|
1704
|
+
const ellipsisLabelAttribute = Object.assign(Object.assign({}, this.attribute.textStyle), { text: '...' });
|
|
1705
|
+
const ellipsisText = this._createLabelText(ellipsisLabelAttribute);
|
|
1706
|
+
const ellipsisTextBounds = this.getGraphicBounds(ellipsisText);
|
|
1707
|
+
const ellipsisWidth = ellipsisTextBounds.x2 - ellipsisTextBounds.x1;
|
|
1708
|
+
const arcs = this.layoutArcLabels(position, this.attribute, Array.from(this._idToGraphic.values()), data, textBoundsArray, ellipsisWidth);
|
|
1706
1709
|
for (let i = 0; i < data.length; i++) {
|
|
1707
1710
|
const textData = data[i];
|
|
1708
|
-
const basedArc = arcs.find(arc => arc.
|
|
1711
|
+
const basedArc = arcs.find(arc => arc.refDatum.id === textData.id);
|
|
1709
1712
|
const labelAttribute = {
|
|
1713
|
+
visible: basedArc.labelVisible,
|
|
1710
1714
|
x: basedArc.labelPosition.x,
|
|
1711
1715
|
y: basedArc.labelPosition.y,
|
|
1712
|
-
angle:
|
|
1713
|
-
|
|
1716
|
+
angle: basedArc.angle,
|
|
1717
|
+
maxLineWidth: basedArc.labelLimit,
|
|
1718
|
+
points: (basedArc === null || basedArc === void 0 ? void 0 : basedArc.pointA) && (basedArc === null || basedArc === void 0 ? void 0 : basedArc.pointB) && (basedArc === null || basedArc === void 0 ? void 0 : basedArc.pointC)
|
|
1719
|
+
? [basedArc.pointA, basedArc.pointB, basedArc.pointC]
|
|
1720
|
+
: undefined
|
|
1714
1721
|
};
|
|
1715
1722
|
labels[i].setAttributes(labelAttribute);
|
|
1716
1723
|
}
|
|
@@ -1772,20 +1779,6 @@
|
|
|
1772
1779
|
continue;
|
|
1773
1780
|
}
|
|
1774
1781
|
}
|
|
1775
|
-
if (clampForce) {
|
|
1776
|
-
const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height);
|
|
1777
|
-
if (!(dx === 0 && dy === 0) &&
|
|
1778
|
-
canPlace(bmpTool, bitmap, {
|
|
1779
|
-
x1: text.AABBBounds.x1 + dx,
|
|
1780
|
-
x2: text.AABBBounds.x2 + dx,
|
|
1781
|
-
y1: text.AABBBounds.y1 + dy,
|
|
1782
|
-
y2: text.AABBBounds.y2 + dy
|
|
1783
|
-
})) {
|
|
1784
|
-
text.setAttributes({ x: text.attribute.x + dx, y: text.attribute.y + dy });
|
|
1785
|
-
result.push(text);
|
|
1786
|
-
continue;
|
|
1787
|
-
}
|
|
1788
|
-
}
|
|
1789
1782
|
let hasPlace = false;
|
|
1790
1783
|
for (let j = 0; j < strategy.length; j++) {
|
|
1791
1784
|
hasPlace = place(bmpTool, bitmap, strategy[j], this.attribute, text, this.getGraphicBounds(baseMark, labels[i]), this.labeling);
|
|
@@ -1845,13 +1838,13 @@
|
|
|
1845
1838
|
const prevTextMap = this._graphicToText || new Map();
|
|
1846
1839
|
const texts = [];
|
|
1847
1840
|
labels.forEach((text, index) => {
|
|
1848
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1849
|
-
const labelLine = ((_a = text.attribute) === null || _a === void 0 ? void 0 : _a.
|
|
1850
|
-
? vrender.
|
|
1841
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
1842
|
+
const labelLine = ((_a = text.attribute) === null || _a === void 0 ? void 0 : _a.points)
|
|
1843
|
+
? vrender.createLine({
|
|
1851
1844
|
visible: (_c = (_b = text.attribute) === null || _b === void 0 ? void 0 : _b.visible) !== null && _c !== void 0 ? _c : true,
|
|
1852
1845
|
stroke: (_f = (_e = (_d = text.attribute) === null || _d === void 0 ? void 0 : _d.line) === null || _e === void 0 ? void 0 : _e.stroke) !== null && _f !== void 0 ? _f : (_g = text.attribute) === null || _g === void 0 ? void 0 : _g.fill,
|
|
1853
|
-
lineWidth: 1,
|
|
1854
|
-
|
|
1846
|
+
lineWidth: (_k = (_j = (_h = text.attribute) === null || _h === void 0 ? void 0 : _h.line) === null || _j === void 0 ? void 0 : _j.lineWidth) !== null && _k !== void 0 ? _k : 1,
|
|
1847
|
+
points: (_l = text.attribute) === null || _l === void 0 ? void 0 : _l.points
|
|
1855
1848
|
})
|
|
1856
1849
|
: undefined;
|
|
1857
1850
|
const relatedGraphic = this._idToGraphic.get(text.attribute.id);
|
|
@@ -1892,9 +1885,9 @@
|
|
|
1892
1885
|
const prevText = prevLabel.text;
|
|
1893
1886
|
prevText.animate().to(text.attribute, duration, easing);
|
|
1894
1887
|
if (prevLabel.labelLine) {
|
|
1895
|
-
prevLabel.labelLine
|
|
1896
|
-
.
|
|
1897
|
-
|
|
1888
|
+
prevLabel.labelLine.animate().to(vutils.merge({}, prevLabel.labelLine.attribute, {
|
|
1889
|
+
points: (_m = text.attribute) === null || _m === void 0 ? void 0 : _m.points
|
|
1890
|
+
}), duration, easing);
|
|
1898
1891
|
}
|
|
1899
1892
|
if (animationConfig.increaseEffect !== false &&
|
|
1900
1893
|
prevText.attribute.text !== text.attribute.text &&
|
|
@@ -1907,7 +1900,7 @@
|
|
|
1907
1900
|
else {
|
|
1908
1901
|
prevLabel.text.setAttributes(text.attribute);
|
|
1909
1902
|
if (prevLabel === null || prevLabel === void 0 ? void 0 : prevLabel.labelLine) {
|
|
1910
|
-
prevLabel.labelLine.setAttributes({
|
|
1903
|
+
prevLabel.labelLine.setAttributes({ points: (_o = text.attribute) === null || _o === void 0 ? void 0 : _o.points });
|
|
1911
1904
|
}
|
|
1912
1905
|
}
|
|
1913
1906
|
}
|
|
@@ -1981,8 +1974,16 @@
|
|
|
1981
1974
|
return listener;
|
|
1982
1975
|
}
|
|
1983
1976
|
_smartInvert(labels) {
|
|
1977
|
+
var _a, _b, _c, _d;
|
|
1984
1978
|
const option = (this.attribute.smartInvert || {});
|
|
1985
1979
|
const { textType, contrastRatiosThreshold, alternativeColors } = option;
|
|
1980
|
+
const fillStrategy = (_a = option.fillStrategy) !== null && _a !== void 0 ? _a : 'invertBase';
|
|
1981
|
+
const strokeStrategy = (_b = option.strokeStrategy) !== null && _b !== void 0 ? _b : 'base';
|
|
1982
|
+
const brightColor = (_c = option.brightColor) !== null && _c !== void 0 ? _c : '#ffffff';
|
|
1983
|
+
const darkColor = (_d = option.darkColor) !== null && _d !== void 0 ? _d : '#000000';
|
|
1984
|
+
if (fillStrategy === 'null' && strokeStrategy === 'null') {
|
|
1985
|
+
return;
|
|
1986
|
+
}
|
|
1986
1987
|
for (let i = 0; i < labels.length; i++) {
|
|
1987
1988
|
const label = labels[i];
|
|
1988
1989
|
if (!label) {
|
|
@@ -1991,33 +1992,70 @@
|
|
|
1991
1992
|
const baseMark = this._idToGraphic.get(label.attribute.id);
|
|
1992
1993
|
let isInside = canPlaceInside(label.AABBBounds, baseMark === null || baseMark === void 0 ? void 0 : baseMark.AABBBounds);
|
|
1993
1994
|
if (this.attribute.type === 'arc') {
|
|
1994
|
-
|
|
1995
|
-
|
|
1995
|
+
isInside = this.attribute.position === 'inside';
|
|
1996
|
+
}
|
|
1997
|
+
const backgroundColor = baseMark.attribute.fill;
|
|
1998
|
+
const foregroundColor = label.attribute.fill;
|
|
1999
|
+
const baseColor = backgroundColor;
|
|
2000
|
+
const invertColor = labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors);
|
|
2001
|
+
const simialrColor = contrastAccessibilityChecker(invertColor, brightColor) ? brightColor : darkColor;
|
|
2002
|
+
if (isInside) {
|
|
2003
|
+
this.setFillStrategy(fillStrategy, label, baseColor, invertColor, simialrColor);
|
|
2004
|
+
if (label.attribute.lineWidth === 0) {
|
|
2005
|
+
continue;
|
|
1996
2006
|
}
|
|
1997
|
-
|
|
1998
|
-
|
|
2007
|
+
this.setStrokeStrategy(strokeStrategy, label, baseColor, invertColor, simialrColor);
|
|
2008
|
+
}
|
|
2009
|
+
else {
|
|
2010
|
+
if (label.attribute.lineWidth === 0) {
|
|
2011
|
+
continue;
|
|
2012
|
+
}
|
|
2013
|
+
if (label.attribute.stroke) {
|
|
2014
|
+
label.setAttributes({
|
|
2015
|
+
fill: labelSmartInvert(label.attribute.fill, label.attribute.stroke, textType, contrastRatiosThreshold, alternativeColors)
|
|
2016
|
+
});
|
|
2017
|
+
continue;
|
|
1999
2018
|
}
|
|
2019
|
+
this.setFillStrategy(fillStrategy, label, baseColor, invertColor, simialrColor);
|
|
2020
|
+
this.setStrokeStrategy(strokeStrategy, label, baseColor, invertColor, simialrColor);
|
|
2000
2021
|
}
|
|
2001
|
-
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
setFillStrategy(fillStrategy, label, baseColor, invertColor, simialrColor) {
|
|
2025
|
+
switch (fillStrategy) {
|
|
2026
|
+
case 'base':
|
|
2002
2027
|
label.setAttributes({
|
|
2003
|
-
fill:
|
|
2028
|
+
fill: baseColor
|
|
2004
2029
|
});
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
const backgroundColor = baseMark.attribute.fill;
|
|
2008
|
-
const foregroundColor = label.attribute.fill;
|
|
2030
|
+
break;
|
|
2031
|
+
case 'invertBase':
|
|
2009
2032
|
label.setAttributes({
|
|
2010
|
-
fill:
|
|
2033
|
+
fill: invertColor
|
|
2011
2034
|
});
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
const backgroundColor = label.attribute.stroke;
|
|
2015
|
-
const foregroundColor = label.attribute.fill;
|
|
2035
|
+
break;
|
|
2036
|
+
case 'similarBase':
|
|
2016
2037
|
label.setAttributes({
|
|
2017
|
-
|
|
2018
|
-
fill: labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors)
|
|
2038
|
+
fill: simialrColor
|
|
2019
2039
|
});
|
|
2020
|
-
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
setStrokeStrategy(strokeStrategy, label, baseColor, invertColor, simialrColor) {
|
|
2043
|
+
switch (strokeStrategy) {
|
|
2044
|
+
case 'base':
|
|
2045
|
+
label.setAttributes({
|
|
2046
|
+
stroke: baseColor
|
|
2047
|
+
});
|
|
2048
|
+
break;
|
|
2049
|
+
case 'invertBase':
|
|
2050
|
+
label.setAttributes({
|
|
2051
|
+
stroke: invertColor
|
|
2052
|
+
});
|
|
2053
|
+
break;
|
|
2054
|
+
case 'similarBase':
|
|
2055
|
+
label.setAttributes({
|
|
2056
|
+
stroke: simialrColor
|
|
2057
|
+
});
|
|
2058
|
+
break;
|
|
2021
2059
|
}
|
|
2022
2060
|
}
|
|
2023
2061
|
setLocation(point) {
|
|
@@ -2384,15 +2422,18 @@
|
|
|
2384
2422
|
}
|
|
2385
2423
|
return { x: 0, y: 0 };
|
|
2386
2424
|
}
|
|
2387
|
-
layoutArcLabels(position, attribute, currentMarks, data, textBoundsArray) {
|
|
2425
|
+
layoutArcLabels(position, attribute, currentMarks, data, textBoundsArray, ellipsisWidth) {
|
|
2426
|
+
var _a;
|
|
2388
2427
|
this._arcLeft.clear();
|
|
2389
2428
|
this._arcRight.clear();
|
|
2429
|
+
this._ellipsisWidth = ellipsisWidth;
|
|
2390
2430
|
const { width, height } = attribute;
|
|
2431
|
+
const centerOffset = (_a = attribute === null || attribute === void 0 ? void 0 : attribute.centerOffset) !== null && _a !== void 0 ? _a : 0;
|
|
2391
2432
|
currentMarks.forEach((currentMark, index) => {
|
|
2392
2433
|
var _a, _b;
|
|
2393
2434
|
const graphicAttribute = currentMark.attribute;
|
|
2394
2435
|
const radiusRatio = this.computeLayoutOuterRadius(graphicAttribute.outerRadius, width, height);
|
|
2395
|
-
const radius = this.computeRadius(radiusRatio, width, height);
|
|
2436
|
+
const radius = this.computeRadius(radiusRatio, width, height, centerOffset);
|
|
2396
2437
|
const center = { x: (_a = graphicAttribute === null || graphicAttribute === void 0 ? void 0 : graphicAttribute.x) !== null && _a !== void 0 ? _a : 0, y: (_b = graphicAttribute === null || graphicAttribute === void 0 ? void 0 : graphicAttribute.y) !== null && _b !== void 0 ? _b : 0 };
|
|
2397
2438
|
const item = data[index];
|
|
2398
2439
|
const textBounds = textBoundsArray[index];
|
|
@@ -2402,7 +2443,7 @@
|
|
|
2402
2443
|
const arcMiddle = circlePoint(center.x, center.y, graphicAttribute.outerRadius, arcMiddleAngle);
|
|
2403
2444
|
const outerArcMiddle = circlePoint(center.x, center.y, radius + attribute.line.line1MinLength, arcMiddleAngle);
|
|
2404
2445
|
const arc = new ArcInfo(item, arcMiddle, outerArcMiddle, arcQuadrant, intervalAngle, arcMiddleAngle);
|
|
2405
|
-
arc.pointA = circlePoint(center.x, center.y, this.computeDatumRadius(center.x * 2, center.y * 2, graphicAttribute.outerRadius), arc.middleAngle);
|
|
2446
|
+
arc.pointA = circlePoint(center.x, center.y, this.computeDatumRadius(center.x * 2, center.y * 2, graphicAttribute.outerRadius, centerOffset), arc.middleAngle);
|
|
2406
2447
|
arc.labelSize = {
|
|
2407
2448
|
width: textBounds.x2 - textBounds.x1,
|
|
2408
2449
|
height: textBounds.y2 - textBounds.y1
|
|
@@ -2428,16 +2469,18 @@
|
|
|
2428
2469
|
return arcs;
|
|
2429
2470
|
}
|
|
2430
2471
|
_layoutInsideLabels(arcs, attribute, currentMarks) {
|
|
2431
|
-
var _a, _b, _c, _d;
|
|
2472
|
+
var _a, _b, _c, _d, _e;
|
|
2432
2473
|
const center = { x: (_b = (_a = currentMarks[0].attribute) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : 0, y: (_d = (_c = currentMarks[0].attribute) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : 0 };
|
|
2474
|
+
const centerOffset = (_e = attribute === null || attribute === void 0 ? void 0 : attribute.centerOffset) !== null && _e !== void 0 ? _e : 0;
|
|
2433
2475
|
const innerRadiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.innerRadius, attribute.width, attribute.height);
|
|
2434
2476
|
const outerRadiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height);
|
|
2435
2477
|
const labelConfig = attribute;
|
|
2436
2478
|
const spaceWidth = labelConfig.spaceWidth;
|
|
2437
2479
|
arcs.forEach((arc) => {
|
|
2480
|
+
var _a, _b;
|
|
2438
2481
|
const { labelSize, radian } = arc;
|
|
2439
|
-
const innerRadius = this.computeRadius(innerRadiusRatio, attribute.width, attribute.height, 1);
|
|
2440
|
-
const outerRadius = this.computeRadius(outerRadiusRatio, attribute.width, attribute.height, 1);
|
|
2482
|
+
const innerRadius = this.computeRadius(innerRadiusRatio, attribute.width, attribute.height, centerOffset, 1);
|
|
2483
|
+
const outerRadius = this.computeRadius(outerRadiusRatio, attribute.width, attribute.height, centerOffset, 1);
|
|
2441
2484
|
const minRadian = connectLineRadian(outerRadius, labelSize.height);
|
|
2442
2485
|
let limit;
|
|
2443
2486
|
if (radian < minRadian) {
|
|
@@ -2467,7 +2510,7 @@
|
|
|
2467
2510
|
if (!vutils.isGreater(labelWidth, 0)) {
|
|
2468
2511
|
arc.labelVisible = false;
|
|
2469
2512
|
}
|
|
2470
|
-
arc.angle = arc.middleAngle;
|
|
2513
|
+
arc.angle = (_b = (_a = attribute === null || attribute === void 0 ? void 0 : attribute.textStyle) === null || _a === void 0 ? void 0 : _a.angle) !== null && _b !== void 0 ? _b : arc.middleAngle;
|
|
2471
2514
|
});
|
|
2472
2515
|
return arcs;
|
|
2473
2516
|
}
|
|
@@ -2525,36 +2568,33 @@
|
|
|
2525
2568
|
}
|
|
2526
2569
|
const width = center.x * 2;
|
|
2527
2570
|
arcs.forEach(arc => {
|
|
2571
|
+
var _a, _b;
|
|
2528
2572
|
if (arc.labelVisible &&
|
|
2529
2573
|
(vutils.isLess(arc.pointB.x, line2MinLength + spaceWidth) ||
|
|
2530
2574
|
vutils.isGreater(arc.pointB.x, width - line2MinLength - spaceWidth))) {
|
|
2531
2575
|
arc.labelVisible = false;
|
|
2532
2576
|
}
|
|
2533
|
-
arc.angle = 0;
|
|
2534
|
-
arc.labelLinePath =
|
|
2535
|
-
`M${Math.round(arc.pointA.x)},${Math.round(arc.pointA.y)}` +
|
|
2536
|
-
` L${Math.round(arc.pointB.x)},${Math.round(arc.pointB.y)}` +
|
|
2537
|
-
` L${Math.round(arc.pointC.x)},${Math.round(arc.pointC.y)}`;
|
|
2577
|
+
arc.angle = (_b = (_a = attribute === null || attribute === void 0 ? void 0 : attribute.textStyle) === null || _a === void 0 ? void 0 : _a.angle) !== null && _b !== void 0 ? _b : 0;
|
|
2538
2578
|
});
|
|
2539
2579
|
return arcs;
|
|
2540
2580
|
}
|
|
2541
2581
|
_computeX(arc, attribute, currentMarks) {
|
|
2542
|
-
var _a, _b, _c, _d, _e;
|
|
2582
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2543
2583
|
const center = { x: (_b = (_a = currentMarks[0].attribute) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : 0, y: (_d = (_c = currentMarks[0].attribute) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : 0 };
|
|
2584
|
+
const centerOffset = (_e = attribute === null || attribute === void 0 ? void 0 : attribute.centerOffset) !== null && _e !== void 0 ? _e : 0;
|
|
2544
2585
|
const plotLayout = { width: center.x * 2, height: center.y * 2 };
|
|
2545
2586
|
const radiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height);
|
|
2546
2587
|
const line1MinLength = attribute.line.line1MinLength;
|
|
2547
2588
|
const line2MinLength = attribute.line.line2MinLength;
|
|
2548
|
-
const labelLayoutAlign = (
|
|
2589
|
+
const labelLayoutAlign = (_f = attribute.layout) === null || _f === void 0 ? void 0 : _f.align;
|
|
2549
2590
|
const spaceWidth = attribute.spaceWidth;
|
|
2550
|
-
this._computeAlign(arc, attribute);
|
|
2551
2591
|
const { labelPosition, quadrant, pointB } = arc;
|
|
2552
2592
|
if (!vutils.isValidNumber(pointB.x * pointB.y)) {
|
|
2553
2593
|
arc.pointC = { x: NaN, y: NaN };
|
|
2554
2594
|
labelPosition.x = NaN;
|
|
2555
2595
|
arc.labelLimit = 0;
|
|
2556
2596
|
}
|
|
2557
|
-
const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height);
|
|
2597
|
+
const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height, centerOffset);
|
|
2558
2598
|
const flag = isQuadrantLeft(quadrant) ? -1 : 1;
|
|
2559
2599
|
let cx = 0;
|
|
2560
2600
|
const restWidth = flag > 0 ? plotLayout.width - pointB.x : pointB.x;
|
|
@@ -2578,16 +2618,17 @@
|
|
|
2578
2618
|
break;
|
|
2579
2619
|
}
|
|
2580
2620
|
labelWidth = Math.max(this._ellipsisWidth, labelWidth);
|
|
2621
|
+
arc.labelLimit = labelWidth;
|
|
2581
2622
|
arc.pointC = { x: cx, y: labelPosition.y };
|
|
2623
|
+
const targetCenterOffset = 0.5 * (arc.labelLimit < arc.labelSize.width ? arc.labelLimit : arc.labelSize.width);
|
|
2582
2624
|
if (labelLayoutAlign === 'edge') {
|
|
2583
2625
|
const alignOffset = 0;
|
|
2584
|
-
labelPosition.x = flag > 0 ? plotLayout.width + alignOffset : alignOffset;
|
|
2626
|
+
labelPosition.x = (flag > 0 ? plotLayout.width + alignOffset : alignOffset) - flag * targetCenterOffset;
|
|
2585
2627
|
}
|
|
2586
2628
|
else {
|
|
2587
2629
|
const alignOffset = 0;
|
|
2588
|
-
labelPosition.x = cx + alignOffset + flag * (spaceWidth +
|
|
2630
|
+
labelPosition.x = cx + alignOffset + flag * (spaceWidth + targetCenterOffset);
|
|
2589
2631
|
}
|
|
2590
|
-
arc.labelLimit = labelWidth;
|
|
2591
2632
|
}
|
|
2592
2633
|
_computeAlignOffset(align, labelWidth, alignFlag) {
|
|
2593
2634
|
switch (align) {
|
|
@@ -2771,7 +2812,7 @@
|
|
|
2771
2812
|
return -1;
|
|
2772
2813
|
}
|
|
2773
2814
|
_computePointB(arc, r, attribute, currentMarks) {
|
|
2774
|
-
var _a, _b, _c, _d;
|
|
2815
|
+
var _a, _b, _c, _d, _e;
|
|
2775
2816
|
const labelConfig = attribute;
|
|
2776
2817
|
const radiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height);
|
|
2777
2818
|
const line1MinLength = labelConfig.line.line1MinLength;
|
|
@@ -2784,7 +2825,8 @@
|
|
|
2784
2825
|
}
|
|
2785
2826
|
else {
|
|
2786
2827
|
const center = { x: (_b = (_a = currentMarks[0].attribute) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : 0, y: (_d = (_c = currentMarks[0].attribute) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : 0 };
|
|
2787
|
-
const
|
|
2828
|
+
const centerOffset = (_e = attribute === null || attribute === void 0 ? void 0 : attribute.centerOffset) !== null && _e !== void 0 ? _e : 0;
|
|
2829
|
+
const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height, centerOffset);
|
|
2788
2830
|
const { labelPosition, quadrant } = arc;
|
|
2789
2831
|
const outerR = Math.max(radius + line1MinLength, currentMarks[0].attribute.outerRadius);
|
|
2790
2832
|
const rd = r - outerR;
|
|
@@ -2808,13 +2850,14 @@
|
|
|
2808
2850
|
}
|
|
2809
2851
|
}
|
|
2810
2852
|
_computeYRange(arc, attribute, currentMarks) {
|
|
2811
|
-
var _a, _b, _c, _d;
|
|
2853
|
+
var _a, _b, _c, _d, _e;
|
|
2812
2854
|
const center = { x: (_b = (_a = currentMarks[0].attribute) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : 0, y: (_d = (_c = currentMarks[0].attribute) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : 0 };
|
|
2813
2855
|
const plotRect = { width: center.x * 2, height: center.y * 2 };
|
|
2814
2856
|
const radiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height);
|
|
2815
2857
|
const line1MinLength = attribute.line.line1MinLength;
|
|
2816
2858
|
const { width, height } = plotRect;
|
|
2817
|
-
const
|
|
2859
|
+
const centerOffset = (_e = attribute === null || attribute === void 0 ? void 0 : attribute.centerOffset) !== null && _e !== void 0 ? _e : 0;
|
|
2860
|
+
const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height, centerOffset);
|
|
2818
2861
|
const r = this._computeLayoutRadius(height / 2, attribute, currentMarks);
|
|
2819
2862
|
const cx = Math.abs(arc.center.x - width / 2);
|
|
2820
2863
|
const cy = arc.center.y - height / 2;
|
|
@@ -2873,11 +2916,13 @@
|
|
|
2873
2916
|
arc.labelYRange = [min, max];
|
|
2874
2917
|
}
|
|
2875
2918
|
_computeLayoutRadius(halfYLength, attribute, currentMarks) {
|
|
2919
|
+
var _a;
|
|
2876
2920
|
const labelConfig = attribute;
|
|
2877
2921
|
const layoutArcGap = labelConfig.layoutArcGap;
|
|
2878
2922
|
const line1MinLength = labelConfig.line.line1MinLength;
|
|
2879
2923
|
const radiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height);
|
|
2880
|
-
const
|
|
2924
|
+
const centerOffset = (_a = attribute === null || attribute === void 0 ? void 0 : attribute.centerOffset) !== null && _a !== void 0 ? _a : 0;
|
|
2925
|
+
const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height, centerOffset);
|
|
2881
2926
|
const outerR = radius + line1MinLength;
|
|
2882
2927
|
const a = outerR - layoutArcGap;
|
|
2883
2928
|
return Math.max((a ** 2 + halfYLength ** 2) / (2 * a), outerR);
|
|
@@ -2943,8 +2988,9 @@
|
|
|
2943
2988
|
}
|
|
2944
2989
|
}
|
|
2945
2990
|
}
|
|
2946
|
-
computeRadius(r, width, height, k) {
|
|
2947
|
-
|
|
2991
|
+
computeRadius(r, width, height, centerOffset, k) {
|
|
2992
|
+
var _a;
|
|
2993
|
+
return ((_a = this.computeLayoutRadius(width ? width : 0, height ? height : 0) * r * (vutils.isNil(k) ? 1 : k) + centerOffset) !== null && _a !== void 0 ? _a : 0);
|
|
2948
2994
|
}
|
|
2949
2995
|
computeLayoutRadius(width, height) {
|
|
2950
2996
|
return Math.min(width / 2, height / 2);
|
|
@@ -2952,9 +2998,10 @@
|
|
|
2952
2998
|
computeLayoutOuterRadius(r, width, height) {
|
|
2953
2999
|
return r / (Math.min(width, height) / 2);
|
|
2954
3000
|
}
|
|
2955
|
-
computeDatumRadius(width, height, outerRadius) {
|
|
3001
|
+
computeDatumRadius(width, height, outerRadius, centerOffset) {
|
|
3002
|
+
var _a;
|
|
2956
3003
|
const outerRadiusRatio = this.computeLayoutOuterRadius(outerRadius, width, height);
|
|
2957
|
-
return this.computeLayoutRadius(width ? width : 0, height ? height : 0) * outerRadiusRatio;
|
|
3004
|
+
return (_a = this.computeLayoutRadius(width ? width : 0, height ? height : 0) * outerRadiusRatio + centerOffset) !== null && _a !== void 0 ? _a : 0;
|
|
2958
3005
|
}
|
|
2959
3006
|
}
|
|
2960
3007
|
ArcLabel.defaultAttributes = {
|
|
@@ -3839,10 +3886,8 @@
|
|
|
3839
3886
|
textStyle = vutils.isFunction(textStyle)
|
|
3840
3887
|
? vutils.merge({}, DEFAULT_AXIS_THEME.label.style, textStyle(tickDatum, index, tickData, layer))
|
|
3841
3888
|
: textStyle;
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
textBaseline: this.getTextBaseline(vector, inside)
|
|
3845
|
-
}, textStyle);
|
|
3889
|
+
const labelAlign = this.getLabelAlign(vector, inside, textStyle.angle);
|
|
3890
|
+
textStyle = vutils.merge(labelAlign, textStyle);
|
|
3846
3891
|
if (vutils.isFunction(textStyle.text)) {
|
|
3847
3892
|
textStyle.text = textStyle.text({
|
|
3848
3893
|
label: tickDatum.label,
|
|
@@ -4008,73 +4053,70 @@
|
|
|
4008
4053
|
item.rotatedBounds = bounds;
|
|
4009
4054
|
});
|
|
4010
4055
|
}
|
|
4011
|
-
function
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
align = ['left', 'right', 'right', 'right', 'left', 'left', 'left', 'left', 'right'];
|
|
4016
|
-
baseline = ['middle', 'bottom', 'middle', 'top', 'top', 'top', 'middle', 'bottom', 'bottom'];
|
|
4017
|
-
}
|
|
4018
|
-
items.forEach((item, i) => {
|
|
4019
|
-
let angle = item.attribute.angle || 0;
|
|
4020
|
-
if (angle < 0) {
|
|
4021
|
-
while (angle < 0) {
|
|
4022
|
-
angle += Math.PI * 2;
|
|
4023
|
-
}
|
|
4056
|
+
function clampAngle(angle = 0) {
|
|
4057
|
+
if (angle < 0) {
|
|
4058
|
+
while (angle < 0) {
|
|
4059
|
+
angle += Math.PI * 2;
|
|
4024
4060
|
}
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
}
|
|
4030
|
-
const step = angle / (Math.PI * 0.5);
|
|
4031
|
-
let index;
|
|
4032
|
-
if (step === Math.floor(step)) {
|
|
4033
|
-
index = Math.floor(step) * 2;
|
|
4034
|
-
}
|
|
4035
|
-
else {
|
|
4036
|
-
index = Math.floor(step) * 2 + 1;
|
|
4061
|
+
}
|
|
4062
|
+
if (angle > 0) {
|
|
4063
|
+
while (angle >= Math.PI * 2) {
|
|
4064
|
+
angle -= Math.PI * 2;
|
|
4037
4065
|
}
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4066
|
+
}
|
|
4067
|
+
return angle;
|
|
4068
|
+
}
|
|
4069
|
+
function rotateYAxis(orient, items) {
|
|
4070
|
+
items.forEach((item, i) => {
|
|
4071
|
+
item.setAttributes(Object.assign(Object.assign({}, getYAxisLabelAlign(orient, item.attribute.angle)), { angle: clampAngle(item.attribute.angle) }));
|
|
4043
4072
|
});
|
|
4044
4073
|
}
|
|
4045
4074
|
function rotateXAxis(orient, items) {
|
|
4075
|
+
items.forEach(item => {
|
|
4076
|
+
item.setAttributes(Object.assign(Object.assign({}, getXAxisLabelAlign(orient, item.attribute.angle)), { angle: clampAngle(item.attribute.angle) }));
|
|
4077
|
+
});
|
|
4078
|
+
}
|
|
4079
|
+
function getXAxisLabelAlign(orient, angle = 0) {
|
|
4046
4080
|
let align = ['center', 'left', 'left', 'left', 'center', 'right', 'right', 'right', 'left'];
|
|
4047
4081
|
let baseline = ['top', 'top', 'middle', 'bottom', 'bottom', 'bottom', 'middle', 'top', 'top'];
|
|
4048
4082
|
if (orient === 'top') {
|
|
4049
4083
|
align = ['center', 'right', 'right', 'right', 'center', 'left', 'left', 'left', 'right'];
|
|
4050
4084
|
baseline = ['bottom', 'bottom', 'middle', 'top', 'top', 'top', 'middle', 'bottom', 'bottom'];
|
|
4051
4085
|
}
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4086
|
+
angle = clampAngle(angle);
|
|
4087
|
+
const step = angle / (Math.PI * 0.5);
|
|
4088
|
+
let index;
|
|
4089
|
+
if (step === Math.floor(step)) {
|
|
4090
|
+
index = Math.floor(step) * 2;
|
|
4091
|
+
}
|
|
4092
|
+
else {
|
|
4093
|
+
index = Math.floor(step) * 2 + 1;
|
|
4094
|
+
}
|
|
4095
|
+
return {
|
|
4096
|
+
textAlign: align[index],
|
|
4097
|
+
textBaseline: baseline[index]
|
|
4098
|
+
};
|
|
4099
|
+
}
|
|
4100
|
+
function getYAxisLabelAlign(orient, angle = 0) {
|
|
4101
|
+
let align = ['right', 'right', 'center', 'left', 'center', 'left', 'center', 'right', 'right'];
|
|
4102
|
+
let baseline = ['middle', 'middle', 'top', 'top', 'middle', 'middle', 'bottom', 'bottom', 'middle'];
|
|
4103
|
+
if (orient === 'right') {
|
|
4104
|
+
align = ['left', 'right', 'right', 'right', 'left', 'left', 'left', 'left', 'right'];
|
|
4105
|
+
baseline = ['middle', 'bottom', 'middle', 'top', 'top', 'top', 'middle', 'bottom', 'bottom'];
|
|
4106
|
+
}
|
|
4107
|
+
angle = clampAngle(angle);
|
|
4108
|
+
const step = angle / (Math.PI * 0.5);
|
|
4109
|
+
let index;
|
|
4110
|
+
if (step === Math.floor(step)) {
|
|
4111
|
+
index = Math.floor(step) * 2;
|
|
4112
|
+
}
|
|
4113
|
+
else {
|
|
4114
|
+
index = Math.floor(step) * 2 + 1;
|
|
4115
|
+
}
|
|
4116
|
+
return {
|
|
4117
|
+
textAlign: align[index],
|
|
4118
|
+
textBaseline: baseline[index]
|
|
4119
|
+
};
|
|
4078
4120
|
}
|
|
4079
4121
|
|
|
4080
4122
|
function autoLimit(labels, config) {
|
|
@@ -4481,14 +4523,23 @@
|
|
|
4481
4523
|
}
|
|
4482
4524
|
return base;
|
|
4483
4525
|
}
|
|
4484
|
-
|
|
4526
|
+
getLabelAlign(vector, inside, angle) {
|
|
4485
4527
|
const orient = this.attribute.orient;
|
|
4486
|
-
if (
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4528
|
+
if (vutils.isValidNumber(angle)) {
|
|
4529
|
+
if (orient === 'top' || orient === 'bottom') {
|
|
4530
|
+
return getXAxisLabelAlign(orient, angle);
|
|
4531
|
+
}
|
|
4532
|
+
if (orient === 'left' || orient === 'right') {
|
|
4533
|
+
return getYAxisLabelAlign(orient, angle);
|
|
4534
|
+
}
|
|
4491
4535
|
}
|
|
4536
|
+
return {
|
|
4537
|
+
textAlign: this.getTextAlign(vector),
|
|
4538
|
+
textBaseline: this.getTextBaseline(vector, inside)
|
|
4539
|
+
};
|
|
4540
|
+
}
|
|
4541
|
+
beforeLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
|
|
4542
|
+
return;
|
|
4492
4543
|
}
|
|
4493
4544
|
handleLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
|
|
4494
4545
|
if (vutils.isEmpty(labelShapes)) {
|
|
@@ -4836,6 +4887,12 @@
|
|
|
4836
4887
|
afterLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
|
|
4837
4888
|
return;
|
|
4838
4889
|
}
|
|
4890
|
+
getLabelAlign(vector, inside, angle) {
|
|
4891
|
+
return {
|
|
4892
|
+
textAlign: this.getTextAlign(vector),
|
|
4893
|
+
textBaseline: this.getTextBaseline(vector)
|
|
4894
|
+
};
|
|
4895
|
+
}
|
|
4839
4896
|
}
|
|
4840
4897
|
CircleAxis.defaultAttributes = DEFAULT_AXIS_THEME;
|
|
4841
4898
|
|
|
@@ -6941,15 +6998,30 @@
|
|
|
6941
6998
|
this._appendDataToShape(valueShape, exports.LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueAttr === null || valueAttr === void 0 ? void 0 : valueAttr.state);
|
|
6942
6999
|
valueShape.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected);
|
|
6943
7000
|
if (this._itemWidthByUser) {
|
|
6944
|
-
|
|
7001
|
+
const layoutWidth = this._itemWidthByUser -
|
|
6945
7002
|
parsedPadding[1] -
|
|
6946
7003
|
parsedPadding[3] -
|
|
6947
7004
|
shapeSize -
|
|
6948
7005
|
shapeSpace -
|
|
6949
|
-
labelShape.AABBBounds.width() -
|
|
6950
7006
|
labelSpace -
|
|
6951
7007
|
focusSpace -
|
|
6952
|
-
valueSpace
|
|
7008
|
+
valueSpace;
|
|
7009
|
+
const valueBounds = valueShape.AABBBounds;
|
|
7010
|
+
const labelBounds = labelShape.AABBBounds;
|
|
7011
|
+
const valueWidth = valueBounds.width();
|
|
7012
|
+
const labelWidth = labelBounds.width();
|
|
7013
|
+
if (labelWidth > layoutWidth) {
|
|
7014
|
+
if ((layoutWidth - valueWidth) / labelWidth > 0.4) {
|
|
7015
|
+
labelShape.setAttribute('maxLineWidth', layoutWidth - valueWidth);
|
|
7016
|
+
}
|
|
7017
|
+
else {
|
|
7018
|
+
valueShape.setAttribute('maxLineWidth', layoutWidth * 0.5);
|
|
7019
|
+
labelShape.setAttribute('maxLineWidth', layoutWidth * 0.5);
|
|
7020
|
+
}
|
|
7021
|
+
}
|
|
7022
|
+
else {
|
|
7023
|
+
valueShape.setAttribute('maxLineWidth', layoutWidth - labelWidth);
|
|
7024
|
+
}
|
|
6953
7025
|
if (valueAttr.alignRight) {
|
|
6954
7026
|
valueShape.setAttributes({
|
|
6955
7027
|
textAlign: 'right',
|
|
@@ -10016,7 +10088,7 @@
|
|
|
10016
10088
|
}
|
|
10017
10089
|
Tooltip.defaultAttributes = defaultAttributes;
|
|
10018
10090
|
|
|
10019
|
-
const version = "0.14.
|
|
10091
|
+
const version = "0.14.5-alpha.1";
|
|
10020
10092
|
|
|
10021
10093
|
exports.AbstractComponent = AbstractComponent;
|
|
10022
10094
|
exports.ArcInfo = ArcInfo;
|