plot = {
console.log ('plot redefined');
let plotArea = d3.select(maindiv).select('svg');
let x = screenX, y = screenY;
const curveColor = ["DarkBlue", "DarkGreen", "DarkRed"];
let curves = plotArea.selectAll("path.projcurve").data (mocaps);
curves.exit().remove();
curves.enter().append("path").attr("class", "projcurve").merge(curves)
.attr("stroke", (d,i) => curveColor[i%curveColor.length])
.attr("stroke-width", (d,i) => i == currentMocap ? 2.5 : 1.5)
.attr("fill", "none")
.attr("d", function (d) {
return line(d.projection)
});
let kfs = plotArea.selectAll("circle.key").data(kfProjection);
kfs.exit().remove();
console.log(!!kfCheckBox);
console.log("kfCheckBox = " + kfCheckBox);
let display = !!kfCheckBox ? "inline" : "none";
kfs.enter().append("circle").attr("class", "key")
.call (kfDrag)
.merge(kfs)
.attr("cx", d => x(d[1]))
.attr("cy", d => y(d[2]))
.attr("r", 8)
.attr("fill", "red")
.attr("opacity", 0.6)
.style("display", display);
let projection = currentMocap == null ? [] : mocaps[currentMocap].projection;
let join = plotArea.selectAll("circle.frame").data(projection);
join.exit().remove();
join.enter().append("circle")
.attr("class", "frame")
.merge(join)
.attr("cx", d => x(d[0]))
.attr("cy", d => y(d[1]))
.attr("r", 4)
.attr("fill", "black")
.attr("opacity", 0.6)
.on ("click", function (d, i) { mutable currentFrame = i })
}