@euphrasiologist/lwphylo 1.2.22 → 1.2.24
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 -26
- package/dist/drawPhylogeny.cjs.map +1 -1
- package/dist/drawPhylogeny.esm.js +17 -26
- 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 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/drawPhylogeny.cjs
CHANGED
|
@@ -62,23 +62,21 @@ function describeArc(cx, cy, radius, startAngle, endAngle) {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
// src/radial/describeArcSweep.js
|
|
65
|
-
|
|
66
|
-
const norm$1 = (t) => ((t % TAU$1) + TAU$1) % TAU$1;
|
|
67
|
-
|
|
68
|
-
function describeArcSweep(cx, cy, r, a0, a1, sweep /*0=CCW,1=CW*/) {
|
|
65
|
+
function describeArcSweep(cx, cy, r, a0, a1, sweep = 1, largeArcFlag = 0) {
|
|
69
66
|
console.log("describeArcSweep input:", {
|
|
70
67
|
cx, cy, r,
|
|
71
68
|
a0Deg: (a0 * 180 / Math.PI).toFixed(2),
|
|
72
69
|
a1Deg: (a1 * 180 / Math.PI).toFixed(2),
|
|
73
|
-
sweep
|
|
70
|
+
sweep,
|
|
71
|
+
largeArcFlag
|
|
74
72
|
});
|
|
75
73
|
|
|
76
|
-
|
|
77
|
-
if (!(r > 0) || delta < 1e-9) return "";
|
|
78
|
-
const largeArcFlag = delta > Math.PI ? 1 : 0;
|
|
74
|
+
if (!(r > 0)) return "";
|
|
79
75
|
|
|
80
|
-
const x0 = cx + r * Math.cos(a0)
|
|
81
|
-
const
|
|
76
|
+
const x0 = cx + r * Math.cos(a0);
|
|
77
|
+
const y0 = cy - r * Math.sin(a0);
|
|
78
|
+
const x1 = cx + r * Math.cos(a1);
|
|
79
|
+
const y1 = cy - r * Math.sin(a1);
|
|
82
80
|
|
|
83
81
|
return `M ${x0} ${y0} A ${r} ${r} 0 ${largeArcFlag} ${sweep} ${x1} ${y1}`;
|
|
84
82
|
}
|
|
@@ -480,22 +478,16 @@ function getChildArcsFan(pd) {
|
|
|
480
478
|
const TAU = Math.PI * 2;
|
|
481
479
|
const norm = (t) => ((t % TAU) + TAU) % TAU;
|
|
482
480
|
|
|
483
|
-
const ccwDelta = (a0, a1) => (a1 - a0 + TAU) % TAU;
|
|
484
|
-
const cwDelta = (a0, a1) => (a0 - a1 + TAU) % TAU;
|
|
485
|
-
|
|
486
|
-
// Circular midpoint that travels CCW from a -> b by half the CCW span
|
|
487
481
|
function midCCW(a, b) {
|
|
488
|
-
const d = (b - a + TAU) % TAU;
|
|
482
|
+
const d = (b - a + TAU) % TAU;
|
|
489
483
|
return norm(a + d / 2);
|
|
490
484
|
}
|
|
491
485
|
|
|
492
486
|
const key = (x) => (typeof x === "string" ? +x : x);
|
|
493
|
-
|
|
494
487
|
const byId = new Map(pd.map(d => [key(d.thisId), d]));
|
|
495
488
|
const childrenByParent = new Map(
|
|
496
489
|
pd.map(d => [
|
|
497
490
|
key(d.thisId),
|
|
498
|
-
// normalize children to numeric IDs; drop anything we can't resolve
|
|
499
491
|
(d.children || [])
|
|
500
492
|
.map(ch => (typeof ch === "object" ? ch.thisId : ch))
|
|
501
493
|
.map(key)
|
|
@@ -510,7 +502,6 @@ function getChildArcsFan(pd) {
|
|
|
510
502
|
const kids = childrenByParent.get(pid) || [];
|
|
511
503
|
if (kids.length < 2) continue;
|
|
512
504
|
|
|
513
|
-
// Sort children by angle (normalized) around the circle
|
|
514
505
|
const A = kids
|
|
515
506
|
.map(id => {
|
|
516
507
|
const node = byId.get(id);
|
|
@@ -531,14 +522,12 @@ function getChildArcsFan(pd) {
|
|
|
531
522
|
const cur = A[i];
|
|
532
523
|
const next = A[(i + 1) % N];
|
|
533
524
|
|
|
534
|
-
// “fan” wedge around the child: midpoint(prev→cur) .. midpoint(cur→next), CCW
|
|
535
525
|
const start = midCCW(prev.a, cur.a);
|
|
536
526
|
const end = midCCW(cur.a, next.a);
|
|
537
527
|
|
|
538
|
-
|
|
539
|
-
const
|
|
540
|
-
const
|
|
541
|
-
const sweep = ccw <= cw ? 0 : 1;
|
|
528
|
+
const sweep = 1; // always clockwise
|
|
529
|
+
const delta = (end - start + TAU) % TAU;
|
|
530
|
+
const largeArc = delta > Math.PI ? 1 : 0;
|
|
542
531
|
|
|
543
532
|
child_arcs.push({
|
|
544
533
|
parentId: pid,
|
|
@@ -546,7 +535,8 @@ function getChildArcsFan(pd) {
|
|
|
546
535
|
radius,
|
|
547
536
|
start,
|
|
548
537
|
end,
|
|
549
|
-
sweep
|
|
538
|
+
sweep,
|
|
539
|
+
largeArc
|
|
550
540
|
});
|
|
551
541
|
}
|
|
552
542
|
}
|
|
@@ -1309,7 +1299,8 @@ function drawPhylogeny(
|
|
|
1309
1299
|
radiusPx(d.radius),
|
|
1310
1300
|
d.start,
|
|
1311
1301
|
d.end,
|
|
1312
|
-
d.sweep
|
|
1302
|
+
d.sweep,
|
|
1303
|
+
d.largeArc,
|
|
1313
1304
|
)
|
|
1314
1305
|
)
|
|
1315
1306
|
.attr("fill", "none")
|
|
@@ -1498,7 +1489,7 @@ function drawPhylogeny(
|
|
|
1498
1489
|
const R = radiusPx(rec.radius);
|
|
1499
1490
|
return rec.sweep == null
|
|
1500
1491
|
? describeArc(centerX, centerY, R, rec.start, rec.end)
|
|
1501
|
-
: describeArcSweep(centerX, centerY, R, rec.start, rec.end, rec.sweep);
|
|
1492
|
+
: describeArcSweep(centerX, centerY, R, rec.start, rec.end, rec.sweep, a.largeArc);
|
|
1502
1493
|
}
|
|
1503
1494
|
|
|
1504
1495
|
if (a) {
|