@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.cjs
CHANGED
|
@@ -582,6 +582,54 @@ function getChildArcs(pd) {
|
|
|
582
582
|
return arcs;
|
|
583
583
|
}
|
|
584
584
|
|
|
585
|
+
function getChildArcsFan(pd) {
|
|
586
|
+
const TAU = Math.PI * 2;
|
|
587
|
+
const norm = (t) => ((t % TAU) + TAU) % TAU;
|
|
588
|
+
|
|
589
|
+
// Circular midpoint that travels CCW from a -> b by half the CCW span
|
|
590
|
+
function midCCW(a, b) {
|
|
591
|
+
const d = (b - a + TAU) % TAU; // CCW delta a->b in [0, 2π)
|
|
592
|
+
return norm(a + d / 2);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
const byId = new Map(pd.map(d => [d.thisId, d]));
|
|
596
|
+
const childrenByParent = new Map(pd.map(d => [d.thisId, d.children || []]));
|
|
597
|
+
|
|
598
|
+
const child_arcs = [];
|
|
599
|
+
|
|
600
|
+
for (const parent of pd) {
|
|
601
|
+
const kids = childrenByParent.get(parent.thisId) || [];
|
|
602
|
+
if (kids.length < 2) continue;
|
|
603
|
+
|
|
604
|
+
// Sort children by angle (normalized) around the circle
|
|
605
|
+
const A = kids
|
|
606
|
+
.map(id => ({ id, a: norm(byId.get(id).angle) }))
|
|
607
|
+
.sort((u, v) => u.a - v.a);
|
|
608
|
+
|
|
609
|
+
const N = A.length;
|
|
610
|
+
for (let i = 0; i < N; i++) {
|
|
611
|
+
const prev = A[(i - 1 + N) % N];
|
|
612
|
+
const cur = A[i];
|
|
613
|
+
const next = A[(i + 1) % N];
|
|
614
|
+
|
|
615
|
+
// “fan” wedge around the child: midpoint(prev→cur) .. midpoint(cur→next)
|
|
616
|
+
const start = midCCW(prev.a, cur.a);
|
|
617
|
+
const end = midCCW(cur.a, next.a);
|
|
618
|
+
|
|
619
|
+
child_arcs.push({
|
|
620
|
+
parentId: parent.thisId,
|
|
621
|
+
childId: cur.id,
|
|
622
|
+
radius: parent.r, // IMPORTANT: draw at the PARENT circle
|
|
623
|
+
start,
|
|
624
|
+
end,
|
|
625
|
+
sweep: 0 // CCW (matches describeArcSweep usage)
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
return child_arcs;
|
|
631
|
+
}
|
|
632
|
+
|
|
585
633
|
// src/radial/radialLayout.js
|
|
586
634
|
|
|
587
635
|
/**
|
|
@@ -628,7 +676,12 @@ function radialLayout(node, opts = {}) {
|
|
|
628
676
|
: getArcs(pd);
|
|
629
677
|
|
|
630
678
|
// per-child arcs for half-arc highlighting if you already use them
|
|
631
|
-
|
|
679
|
+
let child_arcs = [];
|
|
680
|
+
if (opts.arcsStyle === "fan") {
|
|
681
|
+
child_arcs = getChildArcsFan(pd);
|
|
682
|
+
} else {
|
|
683
|
+
child_arcs = getChildArcs(pd);
|
|
684
|
+
}
|
|
632
685
|
|
|
633
686
|
return { data: pd, radii, arcs, child_arcs };
|
|
634
687
|
}
|
|
@@ -1391,7 +1444,6 @@ function drawPhylogeny(
|
|
|
1391
1444
|
d.sweep
|
|
1392
1445
|
)
|
|
1393
1446
|
)
|
|
1394
|
-
|
|
1395
1447
|
.attr("fill", "none")
|
|
1396
1448
|
.attr("stroke", "#777")
|
|
1397
1449
|
.attr("stroke-width", strokeWidth);
|