drag = updateGuess => {
const guesses = new Map(years.map(year => [year, 50]));
function dragstarted() {
d3.select(this).attr("fill", "#333");
}
function dragged(event, d) {
const yVal = Math.round(y.invert(event.y));
d3.select(this)
.raise()
.call(g => g.select('text').text(dotLabel(Math.round(yVal))))
.call(g => g.attr('transform', d => `translate(${x(d)}, ${y(yVal)})`));
updateGuess(d, yVal);
}
function dragended() {
d3.select(this).attr("fill", 'black');
}
return d3
.drag()
.on("start", dragstarted)
.on("drag", dragged)
.on("end", dragended);
}