function drag() {
function dragstarted() {
d3.select('#svg').select("#dragrect").attr("fill", "grey");
}
function dragged(event, d) {
console.log(event.target)
console.log(event.subject)
console.log(event.sourceEvent)
const xvalue = sticky(event.x);
const jahr = Math.round(xScale.invert(xvalue));
console.log(jahr);
d3.select('#svg').property("value", jahr);
d3.select('#svg').dispatch("input");
d3.select(this).attr("transform", `translate(${xvalue},0)`);
d3.select("#dragYear").text("\u25C0 " + jahr + " \u25B6");
}
function dragended() {
d3.select('#svg').select("#dragrect").attr("fill", "whitesmoke");
}
return d3
.drag()
.container(d3.select(this).childNode)
.on("start", dragstarted)
.on("drag", dragged)
.on("end", dragended);
}