@visactor/vrender-components 0.16.9 → 0.16.10-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/line.js +36 -42
- package/cjs/axis/line.js.map +1 -1
- package/cjs/axis/overlap/auto-hide.js +9 -8
- package/cjs/axis/overlap/auto-hide.js.map +1 -1
- package/cjs/axis/overlap/auto-limit.js.map +1 -1
- package/cjs/axis/overlap/auto-rotate.js +3 -35
- package/cjs/axis/overlap/auto-rotate.js.map +1 -1
- package/cjs/axis/overlap/util.d.ts +3 -0
- package/cjs/axis/overlap/util.js +44 -0
- package/cjs/axis/overlap/util.js.map +1 -0
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/dist/index.js +66 -53
- package/dist/index.min.js +1 -1
- package/es/axis/line.js +36 -42
- package/es/axis/line.js.map +1 -1
- package/es/axis/overlap/auto-hide.js +10 -6
- package/es/axis/overlap/auto-hide.js.map +1 -1
- package/es/axis/overlap/auto-limit.js.map +1 -1
- package/es/axis/overlap/auto-rotate.js +3 -33
- package/es/axis/overlap/auto-rotate.js.map +1 -1
- package/es/axis/overlap/util.d.ts +3 -0
- package/es/axis/overlap/util.js +35 -0
- package/es/axis/overlap/util.js.map +1 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -24320,6 +24320,49 @@
|
|
|
24320
24320
|
}
|
|
24321
24321
|
}
|
|
24322
24322
|
|
|
24323
|
+
function rotate(x, y, deg, originX, originY) {
|
|
24324
|
+
return {
|
|
24325
|
+
x: (x - originX) * Math.cos(deg) + (y - originY) * Math.sin(deg) + originX,
|
|
24326
|
+
y: (x - originX) * Math.sin(deg) + (originY - y) * Math.cos(deg) + originY
|
|
24327
|
+
};
|
|
24328
|
+
}
|
|
24329
|
+
function genNormalBounds(item) {
|
|
24330
|
+
const bounds = item.AABBBounds;
|
|
24331
|
+
return {
|
|
24332
|
+
x1: bounds.x1,
|
|
24333
|
+
x2: bounds.x2,
|
|
24334
|
+
y1: bounds.y1,
|
|
24335
|
+
y2: bounds.y2,
|
|
24336
|
+
centerX: item.attribute.x,
|
|
24337
|
+
centerY: item.attribute.y,
|
|
24338
|
+
angle: item.attribute.angle
|
|
24339
|
+
};
|
|
24340
|
+
}
|
|
24341
|
+
function genRotateBounds(items) {
|
|
24342
|
+
items.forEach(item => {
|
|
24343
|
+
if (item.rotatedBounds || !item.attribute.angle) {
|
|
24344
|
+
return;
|
|
24345
|
+
}
|
|
24346
|
+
const bounds = genNormalBounds(item);
|
|
24347
|
+
const rotatedCenter = rotate(bounds.centerX, bounds.centerY, bounds.angle, item.attribute.x, item.attribute.y);
|
|
24348
|
+
const deltaX = rotatedCenter.x - bounds.centerX;
|
|
24349
|
+
const deltaY = rotatedCenter.y - bounds.centerY;
|
|
24350
|
+
bounds.x1 += deltaX;
|
|
24351
|
+
bounds.x2 += deltaX;
|
|
24352
|
+
bounds.y1 += deltaY;
|
|
24353
|
+
bounds.y2 += deltaY;
|
|
24354
|
+
bounds.centerX += deltaX;
|
|
24355
|
+
bounds.centerY += deltaY;
|
|
24356
|
+
item.rotatedBounds = bounds;
|
|
24357
|
+
});
|
|
24358
|
+
}
|
|
24359
|
+
function itemIntersect(item1, item2) {
|
|
24360
|
+
return (vutils.isRectIntersect(item1.AABBBounds, item2.AABBBounds, false) &&
|
|
24361
|
+
(item1.rotatedBounds && item2.rotatedBounds
|
|
24362
|
+
? vutils.isRotateAABBIntersect(item1.rotatedBounds, item2.rotatedBounds, true)
|
|
24363
|
+
: true));
|
|
24364
|
+
}
|
|
24365
|
+
|
|
24323
24366
|
const methods = {
|
|
24324
24367
|
parity: function (items) {
|
|
24325
24368
|
return items.filter((item, i) => (i % 2 ? item.setAttribute('opacity', 0) : 1));
|
|
@@ -24327,7 +24370,7 @@
|
|
|
24327
24370
|
greedy: function (items, sep) {
|
|
24328
24371
|
let a;
|
|
24329
24372
|
return items.filter((b, i) => {
|
|
24330
|
-
if (!i || !intersect(a
|
|
24373
|
+
if (!i || !intersect(a, b, sep)) {
|
|
24331
24374
|
a = b;
|
|
24332
24375
|
return 1;
|
|
24333
24376
|
}
|
|
@@ -24335,12 +24378,18 @@
|
|
|
24335
24378
|
});
|
|
24336
24379
|
}
|
|
24337
24380
|
};
|
|
24338
|
-
function intersect(
|
|
24339
|
-
|
|
24381
|
+
function intersect(textA, textB, sep) {
|
|
24382
|
+
const a = textA.AABBBounds;
|
|
24383
|
+
const b = textB.AABBBounds;
|
|
24384
|
+
return (sep > Math.max(b.x1 - a.x2, a.x1 - b.x2, b.y1 - a.y2, a.y1 - b.y2) &&
|
|
24385
|
+
(textA.rotatedBounds && textB.rotatedBounds
|
|
24386
|
+
? sep >
|
|
24387
|
+
Math.max(textB.rotatedBounds.x1 - textA.rotatedBounds.x2, textA.rotatedBounds.x1 - textB.rotatedBounds.x2, textB.rotatedBounds.y1 - textA.rotatedBounds.y2, textA.rotatedBounds.y1 - textB.rotatedBounds.y2)
|
|
24388
|
+
: true));
|
|
24340
24389
|
}
|
|
24341
24390
|
function hasOverlap(items, pad) {
|
|
24342
|
-
for (let i = 1, n = items.length, a = items[0]
|
|
24343
|
-
if (intersect(a, (b = items[i]
|
|
24391
|
+
for (let i = 1, n = items.length, a = items[0], b; i < n; a = b, ++i) {
|
|
24392
|
+
if (intersect(a, (b = items[i]), pad)) {
|
|
24344
24393
|
return true;
|
|
24345
24394
|
}
|
|
24346
24395
|
}
|
|
@@ -24363,6 +24412,7 @@
|
|
|
24363
24412
|
}
|
|
24364
24413
|
let items;
|
|
24365
24414
|
items = reset(source);
|
|
24415
|
+
genRotateBounds(items);
|
|
24366
24416
|
const { method = 'parity', separation: sep = 0 } = config;
|
|
24367
24417
|
const reduce = vutils.isFunction(method) ? method : methods[method] || methods.parity;
|
|
24368
24418
|
if (items.length >= 3 && hasOverlap(items, sep)) {
|
|
@@ -24372,6 +24422,7 @@
|
|
|
24372
24422
|
if (items.length < 3 && !vutils.last(source).attribute.opacity) {
|
|
24373
24423
|
if (items.length > 1) {
|
|
24374
24424
|
vutils.last(items).setAttribute('opacity', 0);
|
|
24425
|
+
vutils.last(source).setAttribute('opacity', 1);
|
|
24375
24426
|
}
|
|
24376
24427
|
}
|
|
24377
24428
|
}
|
|
@@ -24412,9 +24463,6 @@
|
|
|
24412
24463
|
}
|
|
24413
24464
|
return false;
|
|
24414
24465
|
}
|
|
24415
|
-
function itemIntersect(item1, item2) {
|
|
24416
|
-
return vutils.isRotateAABBIntersect(item1.rotatedBounds, item2.rotatedBounds, true);
|
|
24417
|
-
}
|
|
24418
24466
|
function tryRotate(orient, items) {
|
|
24419
24467
|
if (orient === 'bottom' || orient === 'top') {
|
|
24420
24468
|
rotateXAxis(orient, items);
|
|
@@ -24424,39 +24472,6 @@
|
|
|
24424
24472
|
}
|
|
24425
24473
|
genRotateBounds(items);
|
|
24426
24474
|
}
|
|
24427
|
-
function rotate(x, y, deg, originX, originY) {
|
|
24428
|
-
return {
|
|
24429
|
-
x: (x - originX) * Math.cos(deg) + (y - originY) * Math.sin(deg) + originX,
|
|
24430
|
-
y: (x - originX) * Math.sin(deg) + (originY - y) * Math.cos(deg) + originY
|
|
24431
|
-
};
|
|
24432
|
-
}
|
|
24433
|
-
function genNormalBounds(item) {
|
|
24434
|
-
const bounds = item.AABBBounds;
|
|
24435
|
-
return {
|
|
24436
|
-
x1: bounds.x1,
|
|
24437
|
-
x2: bounds.x2,
|
|
24438
|
-
y1: bounds.y1,
|
|
24439
|
-
y2: bounds.y2,
|
|
24440
|
-
centerX: item.attribute.x,
|
|
24441
|
-
centerY: item.attribute.y,
|
|
24442
|
-
angle: item.attribute.angle
|
|
24443
|
-
};
|
|
24444
|
-
}
|
|
24445
|
-
function genRotateBounds(items) {
|
|
24446
|
-
items.forEach(item => {
|
|
24447
|
-
const bounds = genNormalBounds(item);
|
|
24448
|
-
const rotatedCenter = rotate(bounds.centerX, bounds.centerY, bounds.angle, item.attribute.x, item.attribute.y);
|
|
24449
|
-
const deltaX = rotatedCenter.x - bounds.centerX;
|
|
24450
|
-
const deltaY = rotatedCenter.y - bounds.centerY;
|
|
24451
|
-
bounds.x1 += deltaX;
|
|
24452
|
-
bounds.x2 += deltaX;
|
|
24453
|
-
bounds.y1 += deltaY;
|
|
24454
|
-
bounds.y2 += deltaY;
|
|
24455
|
-
bounds.centerX += deltaX;
|
|
24456
|
-
bounds.centerY += deltaY;
|
|
24457
|
-
item.rotatedBounds = bounds;
|
|
24458
|
-
});
|
|
24459
|
-
}
|
|
24460
24475
|
function clampAngle(angle = 0) {
|
|
24461
24476
|
if (angle < 0) {
|
|
24462
24477
|
while (angle < 0) {
|
|
@@ -24847,16 +24862,15 @@
|
|
|
24847
24862
|
beforeLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
|
|
24848
24863
|
const { flush = false } = this.attribute.label || {};
|
|
24849
24864
|
if (flush && labelShapes.length) {
|
|
24850
|
-
const { orient, start, end } = this.attribute;
|
|
24865
|
+
const { orient, start: axisStart, end: axisEnd } = this.attribute;
|
|
24851
24866
|
const isX = orient === 'bottom' || orient === 'top';
|
|
24852
24867
|
const first = labelShapes[0];
|
|
24853
24868
|
const last = vutils.last(labelShapes);
|
|
24854
24869
|
const isInverse = isX ? first.attribute.x > last.attribute.x : first.attribute.y < last.attribute.y;
|
|
24855
24870
|
if (isX) {
|
|
24856
|
-
const width = Math.abs(start.x - end.x);
|
|
24857
24871
|
if (isInverse) {
|
|
24858
|
-
const start =
|
|
24859
|
-
const end =
|
|
24872
|
+
const start = axisEnd.x;
|
|
24873
|
+
const end = axisStart.x;
|
|
24860
24874
|
const startBound = first.AABBBounds.x2;
|
|
24861
24875
|
const endBound = last.AABBBounds.x1;
|
|
24862
24876
|
if (startBound > start) {
|
|
@@ -24873,8 +24887,8 @@
|
|
|
24873
24887
|
}
|
|
24874
24888
|
}
|
|
24875
24889
|
else {
|
|
24876
|
-
const start =
|
|
24877
|
-
const end =
|
|
24890
|
+
const start = axisStart.x;
|
|
24891
|
+
const end = axisEnd.x;
|
|
24878
24892
|
const startBound = first.AABBBounds.x1;
|
|
24879
24893
|
const endBound = last.AABBBounds.x2;
|
|
24880
24894
|
if (startBound < start) {
|
|
@@ -24892,12 +24906,11 @@
|
|
|
24892
24906
|
}
|
|
24893
24907
|
}
|
|
24894
24908
|
else {
|
|
24895
|
-
const height = Math.abs(start.y - end.y);
|
|
24896
24909
|
if (isInverse) {
|
|
24897
24910
|
const startBound = first.AABBBounds.y1;
|
|
24898
24911
|
const endBound = last.AABBBounds.y2;
|
|
24899
|
-
const start =
|
|
24900
|
-
const end =
|
|
24912
|
+
const start = axisStart.y;
|
|
24913
|
+
const end = axisEnd.y;
|
|
24901
24914
|
if (startBound < start) {
|
|
24902
24915
|
first.setAttributes({
|
|
24903
24916
|
y: start,
|
|
@@ -24912,8 +24925,8 @@
|
|
|
24912
24925
|
}
|
|
24913
24926
|
}
|
|
24914
24927
|
else {
|
|
24915
|
-
const start =
|
|
24916
|
-
const end =
|
|
24928
|
+
const start = axisEnd.y;
|
|
24929
|
+
const end = axisStart.y;
|
|
24917
24930
|
const startBound = first.AABBBounds.y2;
|
|
24918
24931
|
const endBound = last.AABBBounds.y1;
|
|
24919
24932
|
if (startBound > start) {
|
|
@@ -31246,7 +31259,7 @@
|
|
|
31246
31259
|
}
|
|
31247
31260
|
};
|
|
31248
31261
|
|
|
31249
|
-
const version = "0.16.
|
|
31262
|
+
const version = "0.16.10-alpha.1";
|
|
31250
31263
|
|
|
31251
31264
|
exports.AbstractComponent = AbstractComponent;
|
|
31252
31265
|
exports.ArcInfo = ArcInfo;
|