@euphrasiologist/lwphylo 1.2.10 → 1.2.12
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 +51 -17
- package/dist/drawPhylogeny.cjs.map +1 -1
- package/dist/drawPhylogeny.esm.js +51 -17
- 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 +36 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -40,6 +40,21 @@ function describeArc(cx, cy, radius, startAngle, endAngle) {
|
|
|
40
40
|
return `M ${p0.x} ${p0.y} A ${radius} ${radius} 0 ${largeArcFlag} ${sweepFlag} ${p1.x} ${p1.y}`;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
// src/radial/describeArcSweep.js
|
|
44
|
+
const TAU$1 = Math.PI * 2;
|
|
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*/) {
|
|
48
|
+
const delta = sweep === 0 ? norm$1(a1 - a0) : norm$1(a0 - a1);
|
|
49
|
+
if (!(r > 0) || delta < 1e-9) return "";
|
|
50
|
+
const largeArcFlag = delta > Math.PI ? 1 : 0;
|
|
51
|
+
|
|
52
|
+
const x0 = cx + r * Math.cos(a0), y0 = cy - r * Math.sin(a0);
|
|
53
|
+
const x1 = cx + r * Math.cos(a1), y1 = cy - r * Math.sin(a1);
|
|
54
|
+
|
|
55
|
+
return `M ${x0} ${y0} A ${r} ${r} 0 ${largeArcFlag} ${sweep} ${x1} ${y1}`;
|
|
56
|
+
}
|
|
57
|
+
|
|
43
58
|
/**
|
|
44
59
|
* Recursive function for pre-order traversal of tree (returns array)
|
|
45
60
|
*/
|
|
@@ -1109,6 +1124,7 @@ function drawPhylogeny(
|
|
|
1109
1124
|
.scaleLinear()
|
|
1110
1125
|
.domain([-scaleRadial, scaleRadial])
|
|
1111
1126
|
.range([h, 0]);
|
|
1127
|
+
|
|
1112
1128
|
const radiusPx = (r) => r * (w / (2 * scaleRadial));
|
|
1113
1129
|
|
|
1114
1130
|
// ===== INDEXES / HELPERS =====
|
|
@@ -1162,14 +1178,24 @@ function drawPhylogeny(
|
|
|
1162
1178
|
.data(rad.arcs)
|
|
1163
1179
|
.join("path")
|
|
1164
1180
|
.attr("d", (d) =>
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1181
|
+
d.sweep == null
|
|
1182
|
+
? describeArc(
|
|
1183
|
+
centerX,
|
|
1184
|
+
centerY,
|
|
1185
|
+
radiusPx(d.radius),
|
|
1186
|
+
d.start,
|
|
1187
|
+
d.end
|
|
1188
|
+
)
|
|
1189
|
+
: describeArcSweep(
|
|
1190
|
+
centerX,
|
|
1191
|
+
centerY,
|
|
1192
|
+
radiusPx(d.radius),
|
|
1193
|
+
d.start,
|
|
1194
|
+
d.end,
|
|
1195
|
+
d.sweep
|
|
1196
|
+
)
|
|
1172
1197
|
)
|
|
1198
|
+
|
|
1173
1199
|
.attr("fill", "none")
|
|
1174
1200
|
.attr("stroke", "#777")
|
|
1175
1201
|
.attr("stroke-width", strokeWidth);
|
|
@@ -1293,7 +1319,7 @@ function drawPhylogeny(
|
|
|
1293
1319
|
|
|
1294
1320
|
// label hover
|
|
1295
1321
|
labels
|
|
1296
|
-
.on("mouseenter", function(
|
|
1322
|
+
.on("mouseenter", function(_event, d) {
|
|
1297
1323
|
drawRadialPath(d, hoverLines, hoverArcs, hoverStroke, hoverWidth);
|
|
1298
1324
|
d3.select(this).select("text").attr("font-weight", 600);
|
|
1299
1325
|
})
|
|
@@ -1350,15 +1376,23 @@ function drawPhylogeny(
|
|
|
1350
1376
|
if (a) {
|
|
1351
1377
|
arcLayer
|
|
1352
1378
|
.append("path")
|
|
1353
|
-
.attr(
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1379
|
+
.attr("d", (d) =>
|
|
1380
|
+
d.sweep == null
|
|
1381
|
+
? describeArc(
|
|
1382
|
+
centerX,
|
|
1383
|
+
centerY,
|
|
1384
|
+
radiusPx(d.radius),
|
|
1385
|
+
d.start,
|
|
1386
|
+
d.end
|
|
1387
|
+
)
|
|
1388
|
+
: describeArcSweep(
|
|
1389
|
+
centerX,
|
|
1390
|
+
centerY,
|
|
1391
|
+
radiusPx(d.radius),
|
|
1392
|
+
d.start,
|
|
1393
|
+
d.end,
|
|
1394
|
+
d.sweep
|
|
1395
|
+
)
|
|
1362
1396
|
)
|
|
1363
1397
|
.attr("fill", "none")
|
|
1364
1398
|
.attr("stroke", stroke)
|