transitMorph = {
const svg = d3
.create("svg")
.attr("width", width)
.attr("height", height)
.attr("viewBox", [0, 0, 1100, 850])
.style("font", "10px sans-serif");
svg.call(appendDefs);
const linesGroup = svg.append("g").attr("id", "lines");
const stopsGroup = svg.append("g").attr("id", "stops");
var nextLines = geographicLines;
var currentLines = schematicLines;
var nextLabels = geographicLabels;
var currentLabels = schematicLabels;
while (true) {
const t = svg.transition().duration(duration);
stopsGroup
.selectAll("text")
.data(currentLabels, (d) => d.halte)
.join(
(enter) =>
enter
.append("text")
.attr("transform", (d) => d.transform)
.attr("fill", "black")
.attr("font-size", 8.5)
.text((d) => d.halte)
.attr("stroke", "white")
.attr("paint-order", "stroke")
.attr("stroke-linejoin", "round")
.attr("stroke-width", 2),
(update) =>
update.call((update) =>
update.transition(t).attrTween("transform", function (d) {
var previous = d3.select(this).attr("transform");
var current = d.transform;
return d3.interpolateTransformSvg(previous, current);
})
)
);
linesGroup
.selectAll("path")
.data(currentLines, (d) => d.lijn)
.join(
(enter) =>
enter
.append("path")
.attr("fill", "none")
.attr("stroke-linejoin", "round")
.attr("stroke", (d) => d.stroke)
.attr("stroke-width", 5)
.attr("d", (d) => d.d)
.attr("marker-end", (d) => `url(#marker-${d.lijn})`)
.attr("marker-start", (d) => `url(#marker-${d.lijn})`)
.append("title")
.text((d) => d.lijn),
(update) =>
update.call((update) =>
update.transition(t).attrTween("d", function (d) {
var previous = d3.select(this).attr("d");
var current = d.d;
return d3.interpolatePath(previous, current);
})
)
);
yield Promises.delay(duration + pause, svg.node());
[nextLabels, currentLabels] = [currentLabels, nextLabels];
[nextLines, currentLines] = [currentLines, nextLines];
}
}