@visactor/vrender-components 0.14.3 → 0.14.4
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 +3 -3
- package/cjs/label/base.js +61 -44
- 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 +205 -153
- 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 +3 -3
- package/es/label/base.js +59 -46
- 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 +3 -3
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,42 +1974,67 @@
|
|
|
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 : 'invertSeries';
|
|
1981
|
+
const strokeStrategy = (_b = option.strokeStrategy) !== null && _b !== void 0 ? _b : 'series';
|
|
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) {
|
|
1989
1990
|
continue;
|
|
1990
1991
|
}
|
|
1991
1992
|
const baseMark = this._idToGraphic.get(label.attribute.id);
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
1993
|
+
const backgroundColor = baseMark.attribute.fill;
|
|
1994
|
+
const foregroundColor = label.attribute.fill;
|
|
1995
|
+
const seriesColor = backgroundColor;
|
|
1996
|
+
const invertColor = labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors);
|
|
1997
|
+
const simialrColor = contrastAccessibilityChecker(invertColor, brightColor) ? brightColor : darkColor;
|
|
1998
|
+
switch (fillStrategy) {
|
|
1999
|
+
case 'null':
|
|
2000
|
+
break;
|
|
2001
|
+
case 'series':
|
|
2002
|
+
label.setAttributes({
|
|
2003
|
+
fill: seriesColor
|
|
2004
|
+
});
|
|
2005
|
+
break;
|
|
2006
|
+
case 'invertSeries':
|
|
2007
|
+
label.setAttributes({
|
|
2008
|
+
fill: invertColor
|
|
2009
|
+
});
|
|
2010
|
+
break;
|
|
2011
|
+
case 'similarSeries':
|
|
2012
|
+
label.setAttributes({
|
|
2013
|
+
fill: simialrColor
|
|
2014
|
+
});
|
|
2015
|
+
break;
|
|
2005
2016
|
}
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
const foregroundColor = label.attribute.fill;
|
|
2009
|
-
label.setAttributes({
|
|
2010
|
-
fill: labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors)
|
|
2011
|
-
});
|
|
2017
|
+
if (label.attribute.lineWidth === 0) {
|
|
2018
|
+
continue;
|
|
2012
2019
|
}
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
+
switch (strokeStrategy) {
|
|
2021
|
+
case 'null':
|
|
2022
|
+
break;
|
|
2023
|
+
case 'series':
|
|
2024
|
+
label.setAttributes({
|
|
2025
|
+
stroke: seriesColor
|
|
2026
|
+
});
|
|
2027
|
+
break;
|
|
2028
|
+
case 'invertSeries':
|
|
2029
|
+
label.setAttributes({
|
|
2030
|
+
stroke: invertColor
|
|
2031
|
+
});
|
|
2032
|
+
break;
|
|
2033
|
+
case 'similarSeries':
|
|
2034
|
+
label.setAttributes({
|
|
2035
|
+
stroke: simialrColor
|
|
2036
|
+
});
|
|
2037
|
+
break;
|
|
2020
2038
|
}
|
|
2021
2039
|
}
|
|
2022
2040
|
}
|
|
@@ -2384,15 +2402,18 @@
|
|
|
2384
2402
|
}
|
|
2385
2403
|
return { x: 0, y: 0 };
|
|
2386
2404
|
}
|
|
2387
|
-
layoutArcLabels(position, attribute, currentMarks, data, textBoundsArray) {
|
|
2405
|
+
layoutArcLabels(position, attribute, currentMarks, data, textBoundsArray, ellipsisWidth) {
|
|
2406
|
+
var _a;
|
|
2388
2407
|
this._arcLeft.clear();
|
|
2389
2408
|
this._arcRight.clear();
|
|
2409
|
+
this._ellipsisWidth = ellipsisWidth;
|
|
2390
2410
|
const { width, height } = attribute;
|
|
2411
|
+
const centerOffset = (_a = attribute === null || attribute === void 0 ? void 0 : attribute.centerOffset) !== null && _a !== void 0 ? _a : 0;
|
|
2391
2412
|
currentMarks.forEach((currentMark, index) => {
|
|
2392
2413
|
var _a, _b;
|
|
2393
2414
|
const graphicAttribute = currentMark.attribute;
|
|
2394
2415
|
const radiusRatio = this.computeLayoutOuterRadius(graphicAttribute.outerRadius, width, height);
|
|
2395
|
-
const radius = this.computeRadius(radiusRatio, width, height);
|
|
2416
|
+
const radius = this.computeRadius(radiusRatio, width, height, centerOffset);
|
|
2396
2417
|
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
2418
|
const item = data[index];
|
|
2398
2419
|
const textBounds = textBoundsArray[index];
|
|
@@ -2402,7 +2423,7 @@
|
|
|
2402
2423
|
const arcMiddle = circlePoint(center.x, center.y, graphicAttribute.outerRadius, arcMiddleAngle);
|
|
2403
2424
|
const outerArcMiddle = circlePoint(center.x, center.y, radius + attribute.line.line1MinLength, arcMiddleAngle);
|
|
2404
2425
|
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);
|
|
2426
|
+
arc.pointA = circlePoint(center.x, center.y, this.computeDatumRadius(center.x * 2, center.y * 2, graphicAttribute.outerRadius, centerOffset), arc.middleAngle);
|
|
2406
2427
|
arc.labelSize = {
|
|
2407
2428
|
width: textBounds.x2 - textBounds.x1,
|
|
2408
2429
|
height: textBounds.y2 - textBounds.y1
|
|
@@ -2428,16 +2449,18 @@
|
|
|
2428
2449
|
return arcs;
|
|
2429
2450
|
}
|
|
2430
2451
|
_layoutInsideLabels(arcs, attribute, currentMarks) {
|
|
2431
|
-
var _a, _b, _c, _d;
|
|
2452
|
+
var _a, _b, _c, _d, _e;
|
|
2432
2453
|
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 };
|
|
2454
|
+
const centerOffset = (_e = attribute === null || attribute === void 0 ? void 0 : attribute.centerOffset) !== null && _e !== void 0 ? _e : 0;
|
|
2433
2455
|
const innerRadiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.innerRadius, attribute.width, attribute.height);
|
|
2434
2456
|
const outerRadiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height);
|
|
2435
2457
|
const labelConfig = attribute;
|
|
2436
2458
|
const spaceWidth = labelConfig.spaceWidth;
|
|
2437
2459
|
arcs.forEach((arc) => {
|
|
2460
|
+
var _a, _b;
|
|
2438
2461
|
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);
|
|
2462
|
+
const innerRadius = this.computeRadius(innerRadiusRatio, attribute.width, attribute.height, centerOffset, 1);
|
|
2463
|
+
const outerRadius = this.computeRadius(outerRadiusRatio, attribute.width, attribute.height, centerOffset, 1);
|
|
2441
2464
|
const minRadian = connectLineRadian(outerRadius, labelSize.height);
|
|
2442
2465
|
let limit;
|
|
2443
2466
|
if (radian < minRadian) {
|
|
@@ -2467,7 +2490,7 @@
|
|
|
2467
2490
|
if (!vutils.isGreater(labelWidth, 0)) {
|
|
2468
2491
|
arc.labelVisible = false;
|
|
2469
2492
|
}
|
|
2470
|
-
arc.angle = arc.middleAngle;
|
|
2493
|
+
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
2494
|
});
|
|
2472
2495
|
return arcs;
|
|
2473
2496
|
}
|
|
@@ -2525,36 +2548,33 @@
|
|
|
2525
2548
|
}
|
|
2526
2549
|
const width = center.x * 2;
|
|
2527
2550
|
arcs.forEach(arc => {
|
|
2551
|
+
var _a, _b;
|
|
2528
2552
|
if (arc.labelVisible &&
|
|
2529
2553
|
(vutils.isLess(arc.pointB.x, line2MinLength + spaceWidth) ||
|
|
2530
2554
|
vutils.isGreater(arc.pointB.x, width - line2MinLength - spaceWidth))) {
|
|
2531
2555
|
arc.labelVisible = false;
|
|
2532
2556
|
}
|
|
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)}`;
|
|
2557
|
+
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
2558
|
});
|
|
2539
2559
|
return arcs;
|
|
2540
2560
|
}
|
|
2541
2561
|
_computeX(arc, attribute, currentMarks) {
|
|
2542
|
-
var _a, _b, _c, _d, _e;
|
|
2562
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2543
2563
|
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 };
|
|
2564
|
+
const centerOffset = (_e = attribute === null || attribute === void 0 ? void 0 : attribute.centerOffset) !== null && _e !== void 0 ? _e : 0;
|
|
2544
2565
|
const plotLayout = { width: center.x * 2, height: center.y * 2 };
|
|
2545
2566
|
const radiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height);
|
|
2546
2567
|
const line1MinLength = attribute.line.line1MinLength;
|
|
2547
2568
|
const line2MinLength = attribute.line.line2MinLength;
|
|
2548
|
-
const labelLayoutAlign = (
|
|
2569
|
+
const labelLayoutAlign = (_f = attribute.layout) === null || _f === void 0 ? void 0 : _f.align;
|
|
2549
2570
|
const spaceWidth = attribute.spaceWidth;
|
|
2550
|
-
this._computeAlign(arc, attribute);
|
|
2551
2571
|
const { labelPosition, quadrant, pointB } = arc;
|
|
2552
2572
|
if (!vutils.isValidNumber(pointB.x * pointB.y)) {
|
|
2553
2573
|
arc.pointC = { x: NaN, y: NaN };
|
|
2554
2574
|
labelPosition.x = NaN;
|
|
2555
2575
|
arc.labelLimit = 0;
|
|
2556
2576
|
}
|
|
2557
|
-
const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height);
|
|
2577
|
+
const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height, centerOffset);
|
|
2558
2578
|
const flag = isQuadrantLeft(quadrant) ? -1 : 1;
|
|
2559
2579
|
let cx = 0;
|
|
2560
2580
|
const restWidth = flag > 0 ? plotLayout.width - pointB.x : pointB.x;
|
|
@@ -2578,16 +2598,17 @@
|
|
|
2578
2598
|
break;
|
|
2579
2599
|
}
|
|
2580
2600
|
labelWidth = Math.max(this._ellipsisWidth, labelWidth);
|
|
2601
|
+
arc.labelLimit = labelWidth;
|
|
2581
2602
|
arc.pointC = { x: cx, y: labelPosition.y };
|
|
2603
|
+
const targetCenterOffset = 0.5 * (arc.labelLimit < arc.labelSize.width ? arc.labelLimit : arc.labelSize.width);
|
|
2582
2604
|
if (labelLayoutAlign === 'edge') {
|
|
2583
2605
|
const alignOffset = 0;
|
|
2584
|
-
labelPosition.x = flag > 0 ? plotLayout.width + alignOffset : alignOffset;
|
|
2606
|
+
labelPosition.x = (flag > 0 ? plotLayout.width + alignOffset : alignOffset) - flag * targetCenterOffset;
|
|
2585
2607
|
}
|
|
2586
2608
|
else {
|
|
2587
2609
|
const alignOffset = 0;
|
|
2588
|
-
labelPosition.x = cx + alignOffset + flag * (spaceWidth + 0.5 *
|
|
2610
|
+
labelPosition.x = cx + alignOffset + flag * (spaceWidth + 0.5 * targetCenterOffset);
|
|
2589
2611
|
}
|
|
2590
|
-
arc.labelLimit = labelWidth;
|
|
2591
2612
|
}
|
|
2592
2613
|
_computeAlignOffset(align, labelWidth, alignFlag) {
|
|
2593
2614
|
switch (align) {
|
|
@@ -2771,7 +2792,7 @@
|
|
|
2771
2792
|
return -1;
|
|
2772
2793
|
}
|
|
2773
2794
|
_computePointB(arc, r, attribute, currentMarks) {
|
|
2774
|
-
var _a, _b, _c, _d;
|
|
2795
|
+
var _a, _b, _c, _d, _e;
|
|
2775
2796
|
const labelConfig = attribute;
|
|
2776
2797
|
const radiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height);
|
|
2777
2798
|
const line1MinLength = labelConfig.line.line1MinLength;
|
|
@@ -2784,7 +2805,8 @@
|
|
|
2784
2805
|
}
|
|
2785
2806
|
else {
|
|
2786
2807
|
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
|
|
2808
|
+
const centerOffset = (_e = attribute === null || attribute === void 0 ? void 0 : attribute.centerOffset) !== null && _e !== void 0 ? _e : 0;
|
|
2809
|
+
const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height, centerOffset);
|
|
2788
2810
|
const { labelPosition, quadrant } = arc;
|
|
2789
2811
|
const outerR = Math.max(radius + line1MinLength, currentMarks[0].attribute.outerRadius);
|
|
2790
2812
|
const rd = r - outerR;
|
|
@@ -2808,13 +2830,14 @@
|
|
|
2808
2830
|
}
|
|
2809
2831
|
}
|
|
2810
2832
|
_computeYRange(arc, attribute, currentMarks) {
|
|
2811
|
-
var _a, _b, _c, _d;
|
|
2833
|
+
var _a, _b, _c, _d, _e;
|
|
2812
2834
|
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
2835
|
const plotRect = { width: center.x * 2, height: center.y * 2 };
|
|
2814
2836
|
const radiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height);
|
|
2815
2837
|
const line1MinLength = attribute.line.line1MinLength;
|
|
2816
2838
|
const { width, height } = plotRect;
|
|
2817
|
-
const
|
|
2839
|
+
const centerOffset = (_e = attribute === null || attribute === void 0 ? void 0 : attribute.centerOffset) !== null && _e !== void 0 ? _e : 0;
|
|
2840
|
+
const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height, centerOffset);
|
|
2818
2841
|
const r = this._computeLayoutRadius(height / 2, attribute, currentMarks);
|
|
2819
2842
|
const cx = Math.abs(arc.center.x - width / 2);
|
|
2820
2843
|
const cy = arc.center.y - height / 2;
|
|
@@ -2873,11 +2896,13 @@
|
|
|
2873
2896
|
arc.labelYRange = [min, max];
|
|
2874
2897
|
}
|
|
2875
2898
|
_computeLayoutRadius(halfYLength, attribute, currentMarks) {
|
|
2899
|
+
var _a;
|
|
2876
2900
|
const labelConfig = attribute;
|
|
2877
2901
|
const layoutArcGap = labelConfig.layoutArcGap;
|
|
2878
2902
|
const line1MinLength = labelConfig.line.line1MinLength;
|
|
2879
2903
|
const radiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height);
|
|
2880
|
-
const
|
|
2904
|
+
const centerOffset = (_a = attribute === null || attribute === void 0 ? void 0 : attribute.centerOffset) !== null && _a !== void 0 ? _a : 0;
|
|
2905
|
+
const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height, centerOffset);
|
|
2881
2906
|
const outerR = radius + line1MinLength;
|
|
2882
2907
|
const a = outerR - layoutArcGap;
|
|
2883
2908
|
return Math.max((a ** 2 + halfYLength ** 2) / (2 * a), outerR);
|
|
@@ -2943,8 +2968,9 @@
|
|
|
2943
2968
|
}
|
|
2944
2969
|
}
|
|
2945
2970
|
}
|
|
2946
|
-
computeRadius(r, width, height, k) {
|
|
2947
|
-
|
|
2971
|
+
computeRadius(r, width, height, centerOffset, k) {
|
|
2972
|
+
var _a;
|
|
2973
|
+
return ((_a = this.computeLayoutRadius(width ? width : 0, height ? height : 0) * r * (vutils.isNil(k) ? 1 : k) + centerOffset) !== null && _a !== void 0 ? _a : 0);
|
|
2948
2974
|
}
|
|
2949
2975
|
computeLayoutRadius(width, height) {
|
|
2950
2976
|
return Math.min(width / 2, height / 2);
|
|
@@ -2952,9 +2978,10 @@
|
|
|
2952
2978
|
computeLayoutOuterRadius(r, width, height) {
|
|
2953
2979
|
return r / (Math.min(width, height) / 2);
|
|
2954
2980
|
}
|
|
2955
|
-
computeDatumRadius(width, height, outerRadius) {
|
|
2981
|
+
computeDatumRadius(width, height, outerRadius, centerOffset) {
|
|
2982
|
+
var _a;
|
|
2956
2983
|
const outerRadiusRatio = this.computeLayoutOuterRadius(outerRadius, width, height);
|
|
2957
|
-
return this.computeLayoutRadius(width ? width : 0, height ? height : 0) * outerRadiusRatio;
|
|
2984
|
+
return (_a = this.computeLayoutRadius(width ? width : 0, height ? height : 0) * outerRadiusRatio + centerOffset) !== null && _a !== void 0 ? _a : 0;
|
|
2958
2985
|
}
|
|
2959
2986
|
}
|
|
2960
2987
|
ArcLabel.defaultAttributes = {
|
|
@@ -3839,10 +3866,8 @@
|
|
|
3839
3866
|
textStyle = vutils.isFunction(textStyle)
|
|
3840
3867
|
? vutils.merge({}, DEFAULT_AXIS_THEME.label.style, textStyle(tickDatum, index, tickData, layer))
|
|
3841
3868
|
: textStyle;
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
textBaseline: this.getTextBaseline(vector, inside)
|
|
3845
|
-
}, textStyle);
|
|
3869
|
+
const labelAlign = this.getLabelAlign(vector, inside, textStyle.angle);
|
|
3870
|
+
textStyle = vutils.merge(labelAlign, textStyle);
|
|
3846
3871
|
if (vutils.isFunction(textStyle.text)) {
|
|
3847
3872
|
textStyle.text = textStyle.text({
|
|
3848
3873
|
label: tickDatum.label,
|
|
@@ -4008,73 +4033,70 @@
|
|
|
4008
4033
|
item.rotatedBounds = bounds;
|
|
4009
4034
|
});
|
|
4010
4035
|
}
|
|
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
|
-
}
|
|
4036
|
+
function clampAngle(angle = 0) {
|
|
4037
|
+
if (angle < 0) {
|
|
4038
|
+
while (angle < 0) {
|
|
4039
|
+
angle += Math.PI * 2;
|
|
4024
4040
|
}
|
|
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;
|
|
4041
|
+
}
|
|
4042
|
+
if (angle > 0) {
|
|
4043
|
+
while (angle >= Math.PI * 2) {
|
|
4044
|
+
angle -= Math.PI * 2;
|
|
4037
4045
|
}
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4046
|
+
}
|
|
4047
|
+
return angle;
|
|
4048
|
+
}
|
|
4049
|
+
function rotateYAxis(orient, items) {
|
|
4050
|
+
items.forEach((item, i) => {
|
|
4051
|
+
item.setAttributes(Object.assign(Object.assign({}, getYAxisLabelAlign(orient, item.attribute.angle)), { angle: clampAngle(item.attribute.angle) }));
|
|
4043
4052
|
});
|
|
4044
4053
|
}
|
|
4045
4054
|
function rotateXAxis(orient, items) {
|
|
4055
|
+
items.forEach(item => {
|
|
4056
|
+
item.setAttributes(Object.assign(Object.assign({}, getXAxisLabelAlign(orient, item.attribute.angle)), { angle: clampAngle(item.attribute.angle) }));
|
|
4057
|
+
});
|
|
4058
|
+
}
|
|
4059
|
+
function getXAxisLabelAlign(orient, angle = 0) {
|
|
4046
4060
|
let align = ['center', 'left', 'left', 'left', 'center', 'right', 'right', 'right', 'left'];
|
|
4047
4061
|
let baseline = ['top', 'top', 'middle', 'bottom', 'bottom', 'bottom', 'middle', 'top', 'top'];
|
|
4048
4062
|
if (orient === 'top') {
|
|
4049
4063
|
align = ['center', 'right', 'right', 'right', 'center', 'left', 'left', 'left', 'right'];
|
|
4050
4064
|
baseline = ['bottom', 'bottom', 'middle', 'top', 'top', 'top', 'middle', 'bottom', 'bottom'];
|
|
4051
4065
|
}
|
|
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
|
-
|
|
4066
|
+
angle = clampAngle(angle);
|
|
4067
|
+
const step = angle / (Math.PI * 0.5);
|
|
4068
|
+
let index;
|
|
4069
|
+
if (step === Math.floor(step)) {
|
|
4070
|
+
index = Math.floor(step) * 2;
|
|
4071
|
+
}
|
|
4072
|
+
else {
|
|
4073
|
+
index = Math.floor(step) * 2 + 1;
|
|
4074
|
+
}
|
|
4075
|
+
return {
|
|
4076
|
+
textAlign: align[index],
|
|
4077
|
+
textBaseline: baseline[index]
|
|
4078
|
+
};
|
|
4079
|
+
}
|
|
4080
|
+
function getYAxisLabelAlign(orient, angle = 0) {
|
|
4081
|
+
let align = ['right', 'right', 'center', 'left', 'center', 'left', 'center', 'right', 'right'];
|
|
4082
|
+
let baseline = ['middle', 'middle', 'top', 'top', 'middle', 'middle', 'bottom', 'bottom', 'middle'];
|
|
4083
|
+
if (orient === 'right') {
|
|
4084
|
+
align = ['left', 'right', 'right', 'right', 'left', 'left', 'left', 'left', 'right'];
|
|
4085
|
+
baseline = ['middle', 'bottom', 'middle', 'top', 'top', 'top', 'middle', 'bottom', 'bottom'];
|
|
4086
|
+
}
|
|
4087
|
+
angle = clampAngle(angle);
|
|
4088
|
+
const step = angle / (Math.PI * 0.5);
|
|
4089
|
+
let index;
|
|
4090
|
+
if (step === Math.floor(step)) {
|
|
4091
|
+
index = Math.floor(step) * 2;
|
|
4092
|
+
}
|
|
4093
|
+
else {
|
|
4094
|
+
index = Math.floor(step) * 2 + 1;
|
|
4095
|
+
}
|
|
4096
|
+
return {
|
|
4097
|
+
textAlign: align[index],
|
|
4098
|
+
textBaseline: baseline[index]
|
|
4099
|
+
};
|
|
4078
4100
|
}
|
|
4079
4101
|
|
|
4080
4102
|
function autoLimit(labels, config) {
|
|
@@ -4481,14 +4503,23 @@
|
|
|
4481
4503
|
}
|
|
4482
4504
|
return base;
|
|
4483
4505
|
}
|
|
4484
|
-
|
|
4506
|
+
getLabelAlign(vector, inside, angle) {
|
|
4485
4507
|
const orient = this.attribute.orient;
|
|
4486
|
-
if (
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4508
|
+
if (vutils.isValidNumber(angle)) {
|
|
4509
|
+
if (orient === 'top' || orient === 'bottom') {
|
|
4510
|
+
return getXAxisLabelAlign(orient, angle);
|
|
4511
|
+
}
|
|
4512
|
+
if (orient === 'left' || orient === 'right') {
|
|
4513
|
+
return getYAxisLabelAlign(orient, angle);
|
|
4514
|
+
}
|
|
4491
4515
|
}
|
|
4516
|
+
return {
|
|
4517
|
+
textAlign: this.getTextAlign(vector),
|
|
4518
|
+
textBaseline: this.getTextBaseline(vector, inside)
|
|
4519
|
+
};
|
|
4520
|
+
}
|
|
4521
|
+
beforeLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
|
|
4522
|
+
return;
|
|
4492
4523
|
}
|
|
4493
4524
|
handleLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
|
|
4494
4525
|
if (vutils.isEmpty(labelShapes)) {
|
|
@@ -4836,6 +4867,12 @@
|
|
|
4836
4867
|
afterLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
|
|
4837
4868
|
return;
|
|
4838
4869
|
}
|
|
4870
|
+
getLabelAlign(vector, inside, angle) {
|
|
4871
|
+
return {
|
|
4872
|
+
textAlign: this.getTextAlign(vector),
|
|
4873
|
+
textBaseline: this.getTextBaseline(vector)
|
|
4874
|
+
};
|
|
4875
|
+
}
|
|
4839
4876
|
}
|
|
4840
4877
|
CircleAxis.defaultAttributes = DEFAULT_AXIS_THEME;
|
|
4841
4878
|
|
|
@@ -6941,15 +6978,30 @@
|
|
|
6941
6978
|
this._appendDataToShape(valueShape, exports.LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueAttr === null || valueAttr === void 0 ? void 0 : valueAttr.state);
|
|
6942
6979
|
valueShape.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected);
|
|
6943
6980
|
if (this._itemWidthByUser) {
|
|
6944
|
-
|
|
6981
|
+
const layoutWidth = this._itemWidthByUser -
|
|
6945
6982
|
parsedPadding[1] -
|
|
6946
6983
|
parsedPadding[3] -
|
|
6947
6984
|
shapeSize -
|
|
6948
6985
|
shapeSpace -
|
|
6949
|
-
labelShape.AABBBounds.width() -
|
|
6950
6986
|
labelSpace -
|
|
6951
6987
|
focusSpace -
|
|
6952
|
-
valueSpace
|
|
6988
|
+
valueSpace;
|
|
6989
|
+
const valueBounds = valueShape.AABBBounds;
|
|
6990
|
+
const labelBounds = labelShape.AABBBounds;
|
|
6991
|
+
const valueWidth = valueBounds.width();
|
|
6992
|
+
const labelWidth = labelBounds.width();
|
|
6993
|
+
if (labelWidth > layoutWidth) {
|
|
6994
|
+
if ((layoutWidth - valueWidth) / labelWidth > 0.4) {
|
|
6995
|
+
labelShape.setAttribute('maxLineWidth', layoutWidth - valueWidth);
|
|
6996
|
+
}
|
|
6997
|
+
else {
|
|
6998
|
+
valueShape.setAttribute('maxLineWidth', layoutWidth * 0.5);
|
|
6999
|
+
labelShape.setAttribute('maxLineWidth', layoutWidth * 0.5);
|
|
7000
|
+
}
|
|
7001
|
+
}
|
|
7002
|
+
else {
|
|
7003
|
+
valueShape.setAttribute('maxLineWidth', layoutWidth - labelWidth);
|
|
7004
|
+
}
|
|
6953
7005
|
if (valueAttr.alignRight) {
|
|
6954
7006
|
valueShape.setAttributes({
|
|
6955
7007
|
textAlign: 'right',
|
|
@@ -10016,7 +10068,7 @@
|
|
|
10016
10068
|
}
|
|
10017
10069
|
Tooltip.defaultAttributes = defaultAttributes;
|
|
10018
10070
|
|
|
10019
|
-
const version = "0.14.
|
|
10071
|
+
const version = "0.14.4";
|
|
10020
10072
|
|
|
10021
10073
|
exports.AbstractComponent = AbstractComponent;
|
|
10022
10074
|
exports.ArcInfo = ArcInfo;
|