@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
package/dist/index.js
CHANGED
|
@@ -565,6 +565,9 @@ function getChildArcsFan(pd) {
|
|
|
565
565
|
const TAU = Math.PI * 2;
|
|
566
566
|
const norm = (t) => ((t % TAU) + TAU) % TAU;
|
|
567
567
|
|
|
568
|
+
const ccwDelta = (a0, a1) => (a1 - a0 + TAU) % TAU;
|
|
569
|
+
const cwDelta = (a0, a1) => (a0 - a1 + TAU) % TAU;
|
|
570
|
+
|
|
568
571
|
// Circular midpoint that travels CCW from a -> b by half the CCW span
|
|
569
572
|
function midCCW(a, b) {
|
|
570
573
|
const d = (b - a + TAU) % TAU; // CCW delta in [0, 2π)
|
|
@@ -610,20 +613,25 @@ function getChildArcsFan(pd) {
|
|
|
610
613
|
|
|
611
614
|
for (let i = 0; i < N; i++) {
|
|
612
615
|
const prev = A[(i - 1 + N) % N];
|
|
613
|
-
const cur
|
|
616
|
+
const cur = A[i];
|
|
614
617
|
const next = A[(i + 1) % N];
|
|
615
618
|
|
|
616
619
|
// “fan” wedge around the child: midpoint(prev→cur) .. midpoint(cur→next), CCW
|
|
617
620
|
const start = midCCW(prev.a, cur.a);
|
|
618
|
-
const end
|
|
621
|
+
const end = midCCW(cur.a, next.a);
|
|
622
|
+
|
|
623
|
+
// Choose the **shorter** sweep (0 = CCW, 1 = CW in our math-angle convention)
|
|
624
|
+
const ccw = ccwDelta(start, end);
|
|
625
|
+
const cw = cwDelta(start, end);
|
|
626
|
+
const sweep = ccw <= cw ? 0 : 1;
|
|
619
627
|
|
|
620
628
|
child_arcs.push({
|
|
621
629
|
parentId: pid,
|
|
622
|
-
childId:
|
|
630
|
+
childId: cur.id,
|
|
623
631
|
radius,
|
|
624
632
|
start,
|
|
625
633
|
end,
|
|
626
|
-
sweep
|
|
634
|
+
sweep
|
|
627
635
|
});
|
|
628
636
|
}
|
|
629
637
|
}
|
|
@@ -631,8 +639,6 @@ function getChildArcsFan(pd) {
|
|
|
631
639
|
return child_arcs;
|
|
632
640
|
}
|
|
633
641
|
|
|
634
|
-
// src/radial/radialLayout.js
|
|
635
|
-
|
|
636
642
|
/**
|
|
637
643
|
* radialLayout(node, opts?)
|
|
638
644
|
* opts:
|
|
@@ -678,7 +684,7 @@ function radialLayout(node, opts = {}) {
|
|
|
678
684
|
|
|
679
685
|
// per-child arcs for half-arc highlighting if you already use them
|
|
680
686
|
let child_arcs = [];
|
|
681
|
-
if (
|
|
687
|
+
if (arcsStyle === "fan") {
|
|
682
688
|
child_arcs = getChildArcsFan(pd);
|
|
683
689
|
} else {
|
|
684
690
|
child_arcs = getChildArcs(pd);
|
|
@@ -1593,7 +1599,10 @@ function drawPhylogeny(
|
|
|
1593
1599
|
lineLayer.selectAll("*").remove();
|
|
1594
1600
|
arcLayer.selectAll("*").remove();
|
|
1595
1601
|
|
|
1596
|
-
let cur = typeof target === "number"
|
|
1602
|
+
let cur = (typeof target === "number" || typeof target === "string")
|
|
1603
|
+
? byId.get(target)
|
|
1604
|
+
: target;
|
|
1605
|
+
|
|
1597
1606
|
if (!cur) return;
|
|
1598
1607
|
|
|
1599
1608
|
let first = true;
|