@euphrasiologist/lwphylo 1.2.19 → 1.2.21
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/dist/drawPhylogeny.cjs +17 -8
- package/dist/drawPhylogeny.cjs.map +1 -1
- package/dist/drawPhylogeny.esm.js +17 -8
- package/dist/drawPhylogeny.esm.js.map +1 -1
- package/dist/drawPhylogeny.umd.js +1 -1
- package/dist/drawPhylogeny.umd.js.map +1 -1
- package/dist/index.cjs +17 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -452,6 +452,9 @@ function getChildArcsFan(pd) {
|
|
|
452
452
|
const TAU = Math.PI * 2;
|
|
453
453
|
const norm = (t) => ((t % TAU) + TAU) % TAU;
|
|
454
454
|
|
|
455
|
+
const ccwDelta = (a0, a1) => (a1 - a0 + TAU) % TAU;
|
|
456
|
+
const cwDelta = (a0, a1) => (a0 - a1 + TAU) % TAU;
|
|
457
|
+
|
|
455
458
|
// Circular midpoint that travels CCW from a -> b by half the CCW span
|
|
456
459
|
function midCCW(a, b) {
|
|
457
460
|
const d = (b - a + TAU) % TAU; // CCW delta in [0, 2π)
|
|
@@ -497,20 +500,25 @@ function getChildArcsFan(pd) {
|
|
|
497
500
|
|
|
498
501
|
for (let i = 0; i < N; i++) {
|
|
499
502
|
const prev = A[(i - 1 + N) % N];
|
|
500
|
-
const cur
|
|
503
|
+
const cur = A[i];
|
|
501
504
|
const next = A[(i + 1) % N];
|
|
502
505
|
|
|
503
506
|
// “fan” wedge around the child: midpoint(prev→cur) .. midpoint(cur→next), CCW
|
|
504
507
|
const start = midCCW(prev.a, cur.a);
|
|
505
|
-
const end
|
|
508
|
+
const end = midCCW(cur.a, next.a);
|
|
509
|
+
|
|
510
|
+
// Choose the **shorter** sweep (0 = CCW, 1 = CW in our math-angle convention)
|
|
511
|
+
const ccw = ccwDelta(start, end);
|
|
512
|
+
const cw = cwDelta(start, end);
|
|
513
|
+
const sweep = ccw <= cw ? 0 : 1;
|
|
506
514
|
|
|
507
515
|
child_arcs.push({
|
|
508
516
|
parentId: pid,
|
|
509
|
-
childId:
|
|
517
|
+
childId: cur.id,
|
|
510
518
|
radius,
|
|
511
519
|
start,
|
|
512
520
|
end,
|
|
513
|
-
sweep
|
|
521
|
+
sweep
|
|
514
522
|
});
|
|
515
523
|
}
|
|
516
524
|
}
|
|
@@ -518,8 +526,6 @@ function getChildArcsFan(pd) {
|
|
|
518
526
|
return child_arcs;
|
|
519
527
|
}
|
|
520
528
|
|
|
521
|
-
// src/radial/radialLayout.js
|
|
522
|
-
|
|
523
529
|
/**
|
|
524
530
|
* radialLayout(node, opts?)
|
|
525
531
|
* opts:
|
|
@@ -565,7 +571,7 @@ function radialLayout(node, opts = {}) {
|
|
|
565
571
|
|
|
566
572
|
// per-child arcs for half-arc highlighting if you already use them
|
|
567
573
|
let child_arcs = [];
|
|
568
|
-
if (
|
|
574
|
+
if (arcsStyle === "fan") {
|
|
569
575
|
child_arcs = getChildArcsFan(pd);
|
|
570
576
|
} else {
|
|
571
577
|
child_arcs = getChildArcs(pd);
|
|
@@ -1426,7 +1432,10 @@ function drawPhylogeny(
|
|
|
1426
1432
|
lineLayer.selectAll("*").remove();
|
|
1427
1433
|
arcLayer.selectAll("*").remove();
|
|
1428
1434
|
|
|
1429
|
-
let cur = typeof target === "number"
|
|
1435
|
+
let cur = (typeof target === "number" || typeof target === "string")
|
|
1436
|
+
? byId.get(target)
|
|
1437
|
+
: target;
|
|
1438
|
+
|
|
1430
1439
|
if (!cur) return;
|
|
1431
1440
|
|
|
1432
1441
|
let first = true;
|