chart = {
const width = 200;
const height = 140;
const svg = d3.select(DOM.svg(width, height))
.style("width", "100%")
.style("height", "auto");
const marker = svg.append('defs')
.append("marker")
.attr("id", "arrowhead")
.attr("markerWidth", 8)
.attr("markerHeight", 8)
.attr("refX", 6)
.attr("refY", 3)
.attr("orient", "auto")
.append('path')
.attr("d", "M 0 0 L 6 3 L 0 6")
.attr("fill", "none")
.attr("stroke", "grey")
.attr("stroke-linejoin", "miter-clip");
const dr = rayon / 2;
const decalage = rayon + 4;
const formes = svg.append("svg:g")
.attr("id", "forme");
formes
.append("rect")
.attr("x", 0)
.attr("y", 0)
.attr("width", width)
.attr("height", height)
.attr("fill", "none")
.attr("stroke", "black")
.attr("stroke-width", 1);
const ptA = formes
.append("circle")
.attr("cx", pos[0].x)
.attr("cy", pos[0].y)
.attr("r", rayon)
.attr("fill", "black")
.attr("stroke-width", 1)
.attr("stroke", "black")
.transition()
.on("start", function repeat() {
d3.active(this)
.transition().duration(vitesse)
.attr("fill", "white")
.attr("stroke", "grey")
.transition().duration(0)
.attr("fill", "black")
.attr("stroke", "black")
.on("end", repeat);
});
const ptB = formes
.append("circle")
.attr("cx", pos[1].x)
.attr("cy", pos[1].y)
.attr("r", rayon)
.attr("fill", "white")
.attr("stroke-width", 1)
.attr("stroke", "black")
.transition()
.on("start", function repeat() {
d3.active(this)
.transition().duration(vitesse)
.attr("fill", "black")
.attr("stroke", "black")
.transition().duration(0)
.attr("fill", "white")
.attr("stroke", "grey")
.on("end", repeat);
});
const LFleche = offset(pos[0], pos[1], decalage);
const posAl = LFleche[0];
const posBl = LFleche[1];
const fleche = formes
.append("line")
.attr("x1", posAl.x)
.attr("y1", posAl.y)
.attr("x2", posBl.x)
.attr("y2", posBl.y)
.attr("stroke-width", 1)
.attr("stroke", "grey")
.attr("stroke-dasharray", "4, 2")
.attr("marker-end", "url(#arrowhead)");
const vitesse = 2000;
formes
.append("circle")
.attr("cx", pos[0].x)
.attr("cy", pos[0].y)
.attr("r", rayon)
.attr("fill", "black")
.transition()
.on("start", function repeat() {
d3.active(this)
.transition().duration(vitesse)
.attr("cx", pos[1].x)
.attr("cy", pos[1].y)
.transition().duration(0)
.attr("cx", pos[0].x)
.attr("cy", pos[0].y)
.on("end", repeat);
});
return svg.node();
}