@euphrasiologist/lwphylo 1.2.16 → 1.2.18
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 +13 -28
- package/dist/drawPhylogeny.cjs.map +1 -1
- package/dist/drawPhylogeny.esm.js +13 -28
- 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 +13 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -601,7 +601,7 @@ function getChildArcsFan(pd) {
|
|
|
601
601
|
radius: parent.r, // IMPORTANT: draw at the PARENT circle
|
|
602
602
|
start,
|
|
603
603
|
end,
|
|
604
|
-
sweep:
|
|
604
|
+
sweep: 1 // CCW (matches describeArcSweep usage)
|
|
605
605
|
});
|
|
606
606
|
}
|
|
607
607
|
}
|
|
@@ -1382,29 +1382,6 @@ function drawPhylogeny(
|
|
|
1382
1382
|
return { X0, Y0, X1s: X0 + dx * t, Y1s: Y0 + dy * t, len };
|
|
1383
1383
|
}
|
|
1384
1384
|
|
|
1385
|
-
// put this next to your other radial helpers (top of file or in your lib)
|
|
1386
|
-
function arcPathCCW(cx, cy, R, a0, a1) {
|
|
1387
|
-
const TAU = Math.PI * 2;
|
|
1388
|
-
const norm = (t) => ((t % TAU) + TAU) % TAU;
|
|
1389
|
-
|
|
1390
|
-
a0 = norm(a0);
|
|
1391
|
-
a1 = norm(a1);
|
|
1392
|
-
|
|
1393
|
-
const delta = (a1 - a0 + TAU) % TAU; // CCW span a0 -> a1 in [0, 2π)
|
|
1394
|
-
if (delta < 1e-9) return ""; // degenerate; draw nothing
|
|
1395
|
-
|
|
1396
|
-
// With your polarToCartesian using y = cy - r*sin(t),
|
|
1397
|
-
// sweepFlag=0 gives a visually CCW arc segment.
|
|
1398
|
-
const largeArcFlag = delta > Math.PI ? 1 : 0;
|
|
1399
|
-
const sweepFlag = 0;
|
|
1400
|
-
|
|
1401
|
-
const p0 = polarToCartesian(cx, cy, R, a0);
|
|
1402
|
-
const p1 = polarToCartesian(cx, cy, R, a1);
|
|
1403
|
-
|
|
1404
|
-
return `M ${p0.x} ${p0.y} A ${R} ${R} 0 ${largeArcFlag} ${sweepFlag} ${p1.x} ${p1.y}`;
|
|
1405
|
-
}
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
1385
|
// ===== SVG ROOT =====
|
|
1409
1386
|
const svg = d3
|
|
1410
1387
|
.create("svg")
|
|
@@ -1517,8 +1494,10 @@ function drawPhylogeny(
|
|
|
1517
1494
|
}
|
|
1518
1495
|
|
|
1519
1496
|
// maps for fast lookup on hover (childId → spoke / arc)
|
|
1520
|
-
const
|
|
1521
|
-
const
|
|
1497
|
+
const key = (x) => (typeof x === "string" ? +x : x);
|
|
1498
|
+
const spokeByChild = new Map(rad.radii.map(s => [key(s.childId ?? s.thisId ?? s.id1), s]));
|
|
1499
|
+
const arcByChild = new Map(rad.child_arcs.map(a => [key(a.childId), a]));
|
|
1500
|
+
|
|
1522
1501
|
|
|
1523
1502
|
// ===== LABELS =====
|
|
1524
1503
|
// Labels — make them follow the tip position used by the current mode
|
|
@@ -1624,11 +1603,17 @@ function drawPhylogeny(
|
|
|
1624
1603
|
// ----- half-arc at parent radius (parent.angle → child.angle) -----
|
|
1625
1604
|
const a = arcByChild.get(cur.thisId);
|
|
1626
1605
|
if (a) {
|
|
1627
|
-
|
|
1606
|
+
function pathFromArcRecord(rec) {
|
|
1607
|
+
const R = radiusPx(rec.radius);
|
|
1608
|
+
return rec.sweep == null
|
|
1609
|
+
? describeArc(centerX, centerY, R, rec.start, rec.end)
|
|
1610
|
+
: describeArcSweep(centerX, centerY, R, rec.start, rec.end, rec.sweep);
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1628
1613
|
|
|
1629
1614
|
arcLayer
|
|
1630
1615
|
.append("path")
|
|
1631
|
-
.attr("d",
|
|
1616
|
+
.attr("d", pathFromArcRecord(a))
|
|
1632
1617
|
.attr("fill", "none")
|
|
1633
1618
|
.attr("stroke", stroke)
|
|
1634
1619
|
.attr("stroke-width", width);
|