@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
|
@@ -41,23 +41,21 @@ function describeArc(cx, cy, radius, startAngle, endAngle) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// src/radial/describeArcSweep.js
|
|
44
|
-
|
|
45
|
-
const norm$1 = (t) => ((t % TAU$1) + TAU$1) % TAU$1;
|
|
46
|
-
|
|
47
|
-
function describeArcSweep(cx, cy, r, a0, a1, sweep /*0=CCW,1=CW*/) {
|
|
44
|
+
function describeArcSweep(cx, cy, r, a0, a1, sweep = 1, largeArcFlag = 0) {
|
|
48
45
|
console.log("describeArcSweep input:", {
|
|
49
46
|
cx, cy, r,
|
|
50
47
|
a0Deg: (a0 * 180 / Math.PI).toFixed(2),
|
|
51
48
|
a1Deg: (a1 * 180 / Math.PI).toFixed(2),
|
|
52
|
-
sweep
|
|
49
|
+
sweep,
|
|
50
|
+
largeArcFlag
|
|
53
51
|
});
|
|
54
52
|
|
|
55
|
-
|
|
56
|
-
if (!(r > 0) || delta < 1e-9) return "";
|
|
57
|
-
const largeArcFlag = delta > Math.PI ? 1 : 0;
|
|
53
|
+
if (!(r > 0)) return "";
|
|
58
54
|
|
|
59
|
-
const x0 = cx + r * Math.cos(a0)
|
|
60
|
-
const
|
|
55
|
+
const x0 = cx + r * Math.cos(a0);
|
|
56
|
+
const y0 = cy - r * Math.sin(a0);
|
|
57
|
+
const x1 = cx + r * Math.cos(a1);
|
|
58
|
+
const y1 = cy - r * Math.sin(a1);
|
|
61
59
|
|
|
62
60
|
return `M ${x0} ${y0} A ${r} ${r} 0 ${largeArcFlag} ${sweep} ${x1} ${y1}`;
|
|
63
61
|
}
|
|
@@ -459,22 +457,16 @@ function getChildArcsFan(pd) {
|
|
|
459
457
|
const TAU = Math.PI * 2;
|
|
460
458
|
const norm = (t) => ((t % TAU) + TAU) % TAU;
|
|
461
459
|
|
|
462
|
-
const ccwDelta = (a0, a1) => (a1 - a0 + TAU) % TAU;
|
|
463
|
-
const cwDelta = (a0, a1) => (a0 - a1 + TAU) % TAU;
|
|
464
|
-
|
|
465
|
-
// Circular midpoint that travels CCW from a -> b by half the CCW span
|
|
466
460
|
function midCCW(a, b) {
|
|
467
|
-
const d = (b - a + TAU) % TAU;
|
|
461
|
+
const d = (b - a + TAU) % TAU;
|
|
468
462
|
return norm(a + d / 2);
|
|
469
463
|
}
|
|
470
464
|
|
|
471
465
|
const key = (x) => (typeof x === "string" ? +x : x);
|
|
472
|
-
|
|
473
466
|
const byId = new Map(pd.map(d => [key(d.thisId), d]));
|
|
474
467
|
const childrenByParent = new Map(
|
|
475
468
|
pd.map(d => [
|
|
476
469
|
key(d.thisId),
|
|
477
|
-
// normalize children to numeric IDs; drop anything we can't resolve
|
|
478
470
|
(d.children || [])
|
|
479
471
|
.map(ch => (typeof ch === "object" ? ch.thisId : ch))
|
|
480
472
|
.map(key)
|
|
@@ -489,7 +481,6 @@ function getChildArcsFan(pd) {
|
|
|
489
481
|
const kids = childrenByParent.get(pid) || [];
|
|
490
482
|
if (kids.length < 2) continue;
|
|
491
483
|
|
|
492
|
-
// Sort children by angle (normalized) around the circle
|
|
493
484
|
const A = kids
|
|
494
485
|
.map(id => {
|
|
495
486
|
const node = byId.get(id);
|
|
@@ -510,14 +501,12 @@ function getChildArcsFan(pd) {
|
|
|
510
501
|
const cur = A[i];
|
|
511
502
|
const next = A[(i + 1) % N];
|
|
512
503
|
|
|
513
|
-
// “fan” wedge around the child: midpoint(prev→cur) .. midpoint(cur→next), CCW
|
|
514
504
|
const start = midCCW(prev.a, cur.a);
|
|
515
505
|
const end = midCCW(cur.a, next.a);
|
|
516
506
|
|
|
517
|
-
|
|
518
|
-
const
|
|
519
|
-
const
|
|
520
|
-
const sweep = ccw <= cw ? 0 : 1;
|
|
507
|
+
const sweep = 1; // always clockwise
|
|
508
|
+
const delta = (end - start + TAU) % TAU;
|
|
509
|
+
const largeArc = delta > Math.PI ? 1 : 0;
|
|
521
510
|
|
|
522
511
|
child_arcs.push({
|
|
523
512
|
parentId: pid,
|
|
@@ -525,7 +514,8 @@ function getChildArcsFan(pd) {
|
|
|
525
514
|
radius,
|
|
526
515
|
start,
|
|
527
516
|
end,
|
|
528
|
-
sweep
|
|
517
|
+
sweep,
|
|
518
|
+
largeArc
|
|
529
519
|
});
|
|
530
520
|
}
|
|
531
521
|
}
|
|
@@ -1288,7 +1278,8 @@ function drawPhylogeny(
|
|
|
1288
1278
|
radiusPx(d.radius),
|
|
1289
1279
|
d.start,
|
|
1290
1280
|
d.end,
|
|
1291
|
-
d.sweep
|
|
1281
|
+
d.sweep,
|
|
1282
|
+
d.largeArc,
|
|
1292
1283
|
)
|
|
1293
1284
|
)
|
|
1294
1285
|
.attr("fill", "none")
|
|
@@ -1477,7 +1468,7 @@ function drawPhylogeny(
|
|
|
1477
1468
|
const R = radiusPx(rec.radius);
|
|
1478
1469
|
return rec.sweep == null
|
|
1479
1470
|
? describeArc(centerX, centerY, R, rec.start, rec.end)
|
|
1480
|
-
: describeArcSweep(centerX, centerY, R, rec.start, rec.end, rec.sweep);
|
|
1471
|
+
: describeArcSweep(centerX, centerY, R, rec.start, rec.end, rec.sweep, a.largeArc);
|
|
1481
1472
|
}
|
|
1482
1473
|
|
|
1483
1474
|
if (a) {
|