@euphrasiologist/lwphylo 1.2.23 → 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 +16 -21
- package/dist/drawPhylogeny.cjs.map +1 -1
- package/dist/drawPhylogeny.esm.js +16 -21
- 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 +16 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -21
- 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,19 +457,16 @@ function getChildArcsFan(pd) {
|
|
|
459
457
|
const TAU = Math.PI * 2;
|
|
460
458
|
const norm = (t) => ((t % TAU) + TAU) % TAU;
|
|
461
459
|
|
|
462
|
-
// Circular midpoint that travels CCW from a -> b by half the CCW span
|
|
463
460
|
function midCCW(a, b) {
|
|
464
|
-
const d = (b - a + TAU) % TAU;
|
|
461
|
+
const d = (b - a + TAU) % TAU;
|
|
465
462
|
return norm(a + d / 2);
|
|
466
463
|
}
|
|
467
464
|
|
|
468
465
|
const key = (x) => (typeof x === "string" ? +x : x);
|
|
469
|
-
|
|
470
466
|
const byId = new Map(pd.map(d => [key(d.thisId), d]));
|
|
471
467
|
const childrenByParent = new Map(
|
|
472
468
|
pd.map(d => [
|
|
473
469
|
key(d.thisId),
|
|
474
|
-
// normalize children to numeric IDs; drop anything we can't resolve
|
|
475
470
|
(d.children || [])
|
|
476
471
|
.map(ch => (typeof ch === "object" ? ch.thisId : ch))
|
|
477
472
|
.map(key)
|
|
@@ -486,7 +481,6 @@ function getChildArcsFan(pd) {
|
|
|
486
481
|
const kids = childrenByParent.get(pid) || [];
|
|
487
482
|
if (kids.length < 2) continue;
|
|
488
483
|
|
|
489
|
-
// Sort children by angle (normalized) around the circle
|
|
490
484
|
const A = kids
|
|
491
485
|
.map(id => {
|
|
492
486
|
const node = byId.get(id);
|
|
@@ -510,9 +504,9 @@ function getChildArcsFan(pd) {
|
|
|
510
504
|
const start = midCCW(prev.a, cur.a);
|
|
511
505
|
const end = midCCW(cur.a, next.a);
|
|
512
506
|
|
|
513
|
-
|
|
507
|
+
const sweep = 1; // always clockwise
|
|
514
508
|
const delta = (end - start + TAU) % TAU;
|
|
515
|
-
const
|
|
509
|
+
const largeArc = delta > Math.PI ? 1 : 0;
|
|
516
510
|
|
|
517
511
|
child_arcs.push({
|
|
518
512
|
parentId: pid,
|
|
@@ -520,10 +514,10 @@ function getChildArcsFan(pd) {
|
|
|
520
514
|
radius,
|
|
521
515
|
start,
|
|
522
516
|
end,
|
|
523
|
-
sweep
|
|
517
|
+
sweep,
|
|
518
|
+
largeArc
|
|
524
519
|
});
|
|
525
520
|
}
|
|
526
|
-
|
|
527
521
|
}
|
|
528
522
|
|
|
529
523
|
return child_arcs;
|
|
@@ -1284,7 +1278,8 @@ function drawPhylogeny(
|
|
|
1284
1278
|
radiusPx(d.radius),
|
|
1285
1279
|
d.start,
|
|
1286
1280
|
d.end,
|
|
1287
|
-
d.sweep
|
|
1281
|
+
d.sweep,
|
|
1282
|
+
d.largeArc,
|
|
1288
1283
|
)
|
|
1289
1284
|
)
|
|
1290
1285
|
.attr("fill", "none")
|
|
@@ -1473,7 +1468,7 @@ function drawPhylogeny(
|
|
|
1473
1468
|
const R = radiusPx(rec.radius);
|
|
1474
1469
|
return rec.sweep == null
|
|
1475
1470
|
? describeArc(centerX, centerY, R, rec.start, rec.end)
|
|
1476
|
-
: describeArcSweep(centerX, centerY, R, rec.start, rec.end, rec.sweep);
|
|
1471
|
+
: describeArcSweep(centerX, centerY, R, rec.start, rec.end, rec.sweep, a.largeArc);
|
|
1477
1472
|
}
|
|
1478
1473
|
|
|
1479
1474
|
if (a) {
|