@euphrasiologist/lwphylo 1.2.13 → 1.2.15
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 +54 -2
- package/dist/drawPhylogeny.cjs.map +1 -1
- package/dist/drawPhylogeny.esm.js +54 -2
- 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 +54 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +54 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -561,6 +561,54 @@ function getChildArcs(pd) {
|
|
|
561
561
|
return arcs;
|
|
562
562
|
}
|
|
563
563
|
|
|
564
|
+
function getChildArcsFan(pd) {
|
|
565
|
+
const TAU = Math.PI * 2;
|
|
566
|
+
const norm = (t) => ((t % TAU) + TAU) % TAU;
|
|
567
|
+
|
|
568
|
+
// Circular midpoint that travels CCW from a -> b by half the CCW span
|
|
569
|
+
function midCCW(a, b) {
|
|
570
|
+
const d = (b - a + TAU) % TAU; // CCW delta a->b in [0, 2π)
|
|
571
|
+
return norm(a + d / 2);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
const byId = new Map(pd.map(d => [d.thisId, d]));
|
|
575
|
+
const childrenByParent = new Map(pd.map(d => [d.thisId, d.children || []]));
|
|
576
|
+
|
|
577
|
+
const child_arcs = [];
|
|
578
|
+
|
|
579
|
+
for (const parent of pd) {
|
|
580
|
+
const kids = childrenByParent.get(parent.thisId) || [];
|
|
581
|
+
if (kids.length < 2) continue;
|
|
582
|
+
|
|
583
|
+
// Sort children by angle (normalized) around the circle
|
|
584
|
+
const A = kids
|
|
585
|
+
.map(id => ({ id, a: norm(byId.get(id).angle) }))
|
|
586
|
+
.sort((u, v) => u.a - v.a);
|
|
587
|
+
|
|
588
|
+
const N = A.length;
|
|
589
|
+
for (let i = 0; i < N; i++) {
|
|
590
|
+
const prev = A[(i - 1 + N) % N];
|
|
591
|
+
const cur = A[i];
|
|
592
|
+
const next = A[(i + 1) % N];
|
|
593
|
+
|
|
594
|
+
// “fan” wedge around the child: midpoint(prev→cur) .. midpoint(cur→next)
|
|
595
|
+
const start = midCCW(prev.a, cur.a);
|
|
596
|
+
const end = midCCW(cur.a, next.a);
|
|
597
|
+
|
|
598
|
+
child_arcs.push({
|
|
599
|
+
parentId: parent.thisId,
|
|
600
|
+
childId: cur.id,
|
|
601
|
+
radius: parent.r, // IMPORTANT: draw at the PARENT circle
|
|
602
|
+
start,
|
|
603
|
+
end,
|
|
604
|
+
sweep: 0 // CCW (matches describeArcSweep usage)
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
return child_arcs;
|
|
610
|
+
}
|
|
611
|
+
|
|
564
612
|
// src/radial/radialLayout.js
|
|
565
613
|
|
|
566
614
|
/**
|
|
@@ -607,7 +655,12 @@ function radialLayout(node, opts = {}) {
|
|
|
607
655
|
: getArcs(pd);
|
|
608
656
|
|
|
609
657
|
// per-child arcs for half-arc highlighting if you already use them
|
|
610
|
-
|
|
658
|
+
let child_arcs = [];
|
|
659
|
+
if (opts.arcsStyle === "fan") {
|
|
660
|
+
child_arcs = getChildArcsFan(pd);
|
|
661
|
+
} else {
|
|
662
|
+
child_arcs = getChildArcs(pd);
|
|
663
|
+
}
|
|
611
664
|
|
|
612
665
|
return { data: pd, radii, arcs, child_arcs };
|
|
613
666
|
}
|
|
@@ -1370,7 +1423,6 @@ function drawPhylogeny(
|
|
|
1370
1423
|
d.sweep
|
|
1371
1424
|
)
|
|
1372
1425
|
)
|
|
1373
|
-
|
|
1374
1426
|
.attr("fill", "none")
|
|
1375
1427
|
.attr("stroke", "#777")
|
|
1376
1428
|
.attr("stroke-width", strokeWidth);
|