@euphrasiologist/lwphylo 1.2.10 → 1.2.11

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.
@@ -61,6 +61,21 @@ function describeArc(cx, cy, radius, startAngle, endAngle) {
61
61
  return `M ${p0.x} ${p0.y} A ${radius} ${radius} 0 ${largeArcFlag} ${sweepFlag} ${p1.x} ${p1.y}`;
62
62
  }
63
63
 
64
+ // src/radial/describeArcSweep.js
65
+ const TAU$1 = Math.PI * 2;
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*/) {
69
+ const delta = sweep === 0 ? norm$1(a1 - a0) : norm$1(a0 - a1);
70
+ if (!(r > 0) || delta < 1e-9) return "";
71
+ const largeArcFlag = delta > Math.PI ? 1 : 0;
72
+
73
+ const x0 = cx + r * Math.cos(a0), y0 = cy - r * Math.sin(a0);
74
+ const x1 = cx + r * Math.cos(a1), y1 = cy - r * Math.sin(a1);
75
+
76
+ return `M ${x0} ${y0} A ${r} ${r} 0 ${largeArcFlag} ${sweep} ${x1} ${y1}`;
77
+ }
78
+
64
79
  /**
65
80
  * Recursive function for pre-order traversal of tree (returns array)
66
81
  */
@@ -1130,6 +1145,7 @@ function drawPhylogeny(
1130
1145
  .scaleLinear()
1131
1146
  .domain([-scaleRadial, scaleRadial])
1132
1147
  .range([h, 0]);
1148
+
1133
1149
  const radiusPx = (r) => r * (w / (2 * scaleRadial));
1134
1150
 
1135
1151
  // ===== INDEXES / HELPERS =====
@@ -1314,7 +1330,7 @@ function drawPhylogeny(
1314
1330
 
1315
1331
  // label hover
1316
1332
  labels
1317
- .on("mouseenter", function(event, d) {
1333
+ .on("mouseenter", function(_event, d) {
1318
1334
  drawRadialPath(d, hoverLines, hoverArcs, hoverStroke, hoverWidth);
1319
1335
  d3__namespace.select(this).select("text").attr("font-weight", 600);
1320
1336
  })
@@ -1371,15 +1387,23 @@ function drawPhylogeny(
1371
1387
  if (a) {
1372
1388
  arcLayer
1373
1389
  .append("path")
1374
- .attr(
1375
- "d",
1376
- describeArc(
1377
- centerX,
1378
- centerY,
1379
- Math.max(0, radiusPx(a.radius)),
1380
- a.start,
1381
- a.end
1382
- )
1390
+ .attr("d", (d) =>
1391
+ d.sweep == null
1392
+ ? describeArc(
1393
+ centerX,
1394
+ centerY,
1395
+ radiusPx(d.radius),
1396
+ d.start,
1397
+ d.end
1398
+ )
1399
+ : describeArcSweep(
1400
+ centerX,
1401
+ centerY,
1402
+ radiusPx(d.radius),
1403
+ d.start,
1404
+ d.end,
1405
+ d.sweep
1406
+ )
1383
1407
  )
1384
1408
  .attr("fill", "none")
1385
1409
  .attr("stroke", stroke)