@euphrasiologist/lwphylo 1.2.11 → 1.2.13
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 +32 -26
- package/dist/drawPhylogeny.cjs.map +1 -1
- package/dist/drawPhylogeny.esm.js +32 -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 +32 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/drawPhylogeny.cjs
CHANGED
|
@@ -1115,6 +1115,10 @@ function drawPhylogeny(
|
|
|
1115
1115
|
|
|
1116
1116
|
return svg.node();
|
|
1117
1117
|
} else if (layout === "radial") {
|
|
1118
|
+
// RADIAL LAYOUT
|
|
1119
|
+
if (width !== height) {
|
|
1120
|
+
throw new Error("width and height must be the same for radial layout");
|
|
1121
|
+
}
|
|
1118
1122
|
const parsedTree = readTree(treeText);
|
|
1119
1123
|
const rad = radialLayout(parsedTree, {
|
|
1120
1124
|
angleStrategy: "fan",
|
|
@@ -1124,6 +1128,10 @@ function drawPhylogeny(
|
|
|
1124
1128
|
// ===== MODE =====
|
|
1125
1129
|
const TIP_MODE = radialMode; // "phylo" (shorten to original tips) or "outer" (project to one circle)
|
|
1126
1130
|
const isOuter = TIP_MODE === "outer";
|
|
1131
|
+
if (TIP_MODE !== "phylo" && TIP_MODE !== "outer") {
|
|
1132
|
+
throw new Error("radialMode must be either 'phylo' or 'outer'");
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1127
1135
|
|
|
1128
1136
|
// visuals (0 = let spokes reach the dots)
|
|
1129
1137
|
const DOT_R = 3;
|
|
@@ -1199,14 +1207,24 @@ function drawPhylogeny(
|
|
|
1199
1207
|
.data(rad.arcs)
|
|
1200
1208
|
.join("path")
|
|
1201
1209
|
.attr("d", (d) =>
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1210
|
+
d.sweep == null
|
|
1211
|
+
? describeArc(
|
|
1212
|
+
centerX,
|
|
1213
|
+
centerY,
|
|
1214
|
+
radiusPx(d.radius),
|
|
1215
|
+
d.start,
|
|
1216
|
+
d.end
|
|
1217
|
+
)
|
|
1218
|
+
: describeArcSweep(
|
|
1219
|
+
centerX,
|
|
1220
|
+
centerY,
|
|
1221
|
+
radiusPx(d.radius),
|
|
1222
|
+
d.start,
|
|
1223
|
+
d.end,
|
|
1224
|
+
d.sweep
|
|
1225
|
+
)
|
|
1209
1226
|
)
|
|
1227
|
+
|
|
1210
1228
|
.attr("fill", "none")
|
|
1211
1229
|
.attr("stroke", "#777")
|
|
1212
1230
|
.attr("stroke-width", strokeWidth);
|
|
@@ -1279,7 +1297,7 @@ function drawPhylogeny(
|
|
|
1279
1297
|
|
|
1280
1298
|
// maps for fast lookup on hover (childId → spoke / arc)
|
|
1281
1299
|
const spokeByChild = new Map(rad.radii.map((s) => [childIdOf(s), s]));
|
|
1282
|
-
const arcByChild = new Map(rad.child_arcs.map((a) => [a.childId, a]));
|
|
1300
|
+
const arcByChild = new Map((rad.child_arcs ?? []).map((a) => [a.childId, a]));
|
|
1283
1301
|
|
|
1284
1302
|
// ===== LABELS =====
|
|
1285
1303
|
// Labels — make them follow the tip position used by the current mode
|
|
@@ -1385,29 +1403,17 @@ function drawPhylogeny(
|
|
|
1385
1403
|
// ----- half-arc at parent radius (parent.angle → child.angle) -----
|
|
1386
1404
|
const a = arcByChild.get(cur.thisId);
|
|
1387
1405
|
if (a) {
|
|
1406
|
+
const pathD = (a.sweep == null)
|
|
1407
|
+
? describeArc(centerX, centerY, radiusPx(a.radius), a.start, a.end)
|
|
1408
|
+
: describeArcSweep(centerX, centerY, radiusPx(a.radius), a.start, a.end, a.sweep);
|
|
1409
|
+
|
|
1388
1410
|
arcLayer
|
|
1389
1411
|
.append("path")
|
|
1390
|
-
.attr("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
|
-
)
|
|
1407
|
-
)
|
|
1412
|
+
.attr("d", pathD)
|
|
1408
1413
|
.attr("fill", "none")
|
|
1409
1414
|
.attr("stroke", stroke)
|
|
1410
1415
|
.attr("stroke-width", width);
|
|
1416
|
+
|
|
1411
1417
|
}
|
|
1412
1418
|
|
|
1413
1419
|
first = false;
|