@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
|
@@ -448,6 +448,54 @@ function getChildArcs(pd) {
|
|
|
448
448
|
return arcs;
|
|
449
449
|
}
|
|
450
450
|
|
|
451
|
+
function getChildArcsFan(pd) {
|
|
452
|
+
const TAU = Math.PI * 2;
|
|
453
|
+
const norm = (t) => ((t % TAU) + TAU) % TAU;
|
|
454
|
+
|
|
455
|
+
// Circular midpoint that travels CCW from a -> b by half the CCW span
|
|
456
|
+
function midCCW(a, b) {
|
|
457
|
+
const d = (b - a + TAU) % TAU; // CCW delta a->b in [0, 2π)
|
|
458
|
+
return norm(a + d / 2);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
const byId = new Map(pd.map(d => [d.thisId, d]));
|
|
462
|
+
const childrenByParent = new Map(pd.map(d => [d.thisId, d.children || []]));
|
|
463
|
+
|
|
464
|
+
const child_arcs = [];
|
|
465
|
+
|
|
466
|
+
for (const parent of pd) {
|
|
467
|
+
const kids = childrenByParent.get(parent.thisId) || [];
|
|
468
|
+
if (kids.length < 2) continue;
|
|
469
|
+
|
|
470
|
+
// Sort children by angle (normalized) around the circle
|
|
471
|
+
const A = kids
|
|
472
|
+
.map(id => ({ id, a: norm(byId.get(id).angle) }))
|
|
473
|
+
.sort((u, v) => u.a - v.a);
|
|
474
|
+
|
|
475
|
+
const N = A.length;
|
|
476
|
+
for (let i = 0; i < N; i++) {
|
|
477
|
+
const prev = A[(i - 1 + N) % N];
|
|
478
|
+
const cur = A[i];
|
|
479
|
+
const next = A[(i + 1) % N];
|
|
480
|
+
|
|
481
|
+
// “fan” wedge around the child: midpoint(prev→cur) .. midpoint(cur→next)
|
|
482
|
+
const start = midCCW(prev.a, cur.a);
|
|
483
|
+
const end = midCCW(cur.a, next.a);
|
|
484
|
+
|
|
485
|
+
child_arcs.push({
|
|
486
|
+
parentId: parent.thisId,
|
|
487
|
+
childId: cur.id,
|
|
488
|
+
radius: parent.r, // IMPORTANT: draw at the PARENT circle
|
|
489
|
+
start,
|
|
490
|
+
end,
|
|
491
|
+
sweep: 0 // CCW (matches describeArcSweep usage)
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
return child_arcs;
|
|
497
|
+
}
|
|
498
|
+
|
|
451
499
|
// src/radial/radialLayout.js
|
|
452
500
|
|
|
453
501
|
/**
|
|
@@ -494,7 +542,12 @@ function radialLayout(node, opts = {}) {
|
|
|
494
542
|
: getArcs(pd);
|
|
495
543
|
|
|
496
544
|
// per-child arcs for half-arc highlighting if you already use them
|
|
497
|
-
|
|
545
|
+
let child_arcs = [];
|
|
546
|
+
if (opts.arcsStyle === "fan") {
|
|
547
|
+
child_arcs = getChildArcsFan(pd);
|
|
548
|
+
} else {
|
|
549
|
+
child_arcs = getChildArcs(pd);
|
|
550
|
+
}
|
|
498
551
|
|
|
499
552
|
return { data: pd, radii, arcs, child_arcs };
|
|
500
553
|
}
|
|
@@ -1203,7 +1256,6 @@ function drawPhylogeny(
|
|
|
1203
1256
|
d.sweep
|
|
1204
1257
|
)
|
|
1205
1258
|
)
|
|
1206
|
-
|
|
1207
1259
|
.attr("fill", "none")
|
|
1208
1260
|
.attr("stroke", "#777")
|
|
1209
1261
|
.attr("stroke-width", strokeWidth);
|