@euphrasiologist/lwphylo 1.2.19 → 1.2.21

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.
@@ -452,6 +452,9 @@ function getChildArcsFan(pd) {
452
452
  const TAU = Math.PI * 2;
453
453
  const norm = (t) => ((t % TAU) + TAU) % TAU;
454
454
 
455
+ const ccwDelta = (a0, a1) => (a1 - a0 + TAU) % TAU;
456
+ const cwDelta = (a0, a1) => (a0 - a1 + TAU) % TAU;
457
+
455
458
  // Circular midpoint that travels CCW from a -> b by half the CCW span
456
459
  function midCCW(a, b) {
457
460
  const d = (b - a + TAU) % TAU; // CCW delta in [0, 2π)
@@ -497,20 +500,25 @@ function getChildArcsFan(pd) {
497
500
 
498
501
  for (let i = 0; i < N; i++) {
499
502
  const prev = A[(i - 1 + N) % N];
500
- const cur = A[i];
503
+ const cur = A[i];
501
504
  const next = A[(i + 1) % N];
502
505
 
503
506
  // “fan” wedge around the child: midpoint(prev→cur) .. midpoint(cur→next), CCW
504
507
  const start = midCCW(prev.a, cur.a);
505
- const end = midCCW(cur.a, next.a);
508
+ const end = midCCW(cur.a, next.a);
509
+
510
+ // Choose the **shorter** sweep (0 = CCW, 1 = CW in our math-angle convention)
511
+ const ccw = ccwDelta(start, end);
512
+ const cw = cwDelta(start, end);
513
+ const sweep = ccw <= cw ? 0 : 1;
506
514
 
507
515
  child_arcs.push({
508
516
  parentId: pid,
509
- childId: cur.id,
517
+ childId: cur.id,
510
518
  radius,
511
519
  start,
512
520
  end,
513
- sweep: 0 // CCW (consistent with describeArcSweep and your y-flip)
521
+ sweep
514
522
  });
515
523
  }
516
524
  }
@@ -518,8 +526,6 @@ function getChildArcsFan(pd) {
518
526
  return child_arcs;
519
527
  }
520
528
 
521
- // src/radial/radialLayout.js
522
-
523
529
  /**
524
530
  * radialLayout(node, opts?)
525
531
  * opts:
@@ -565,7 +571,7 @@ function radialLayout(node, opts = {}) {
565
571
 
566
572
  // per-child arcs for half-arc highlighting if you already use them
567
573
  let child_arcs = [];
568
- if (opts.arcsStyle === "fan") {
574
+ if (arcsStyle === "fan") {
569
575
  child_arcs = getChildArcsFan(pd);
570
576
  } else {
571
577
  child_arcs = getChildArcs(pd);
@@ -1426,7 +1432,10 @@ function drawPhylogeny(
1426
1432
  lineLayer.selectAll("*").remove();
1427
1433
  arcLayer.selectAll("*").remove();
1428
1434
 
1429
- let cur = typeof target === "number" ? byId.get(target) : target;
1435
+ let cur = (typeof target === "number" || typeof target === "string")
1436
+ ? byId.get(target)
1437
+ : target;
1438
+
1430
1439
  if (!cur) return;
1431
1440
 
1432
1441
  let first = true;