Need to do this for horizontal bar charts, so figured I better get it right here before I finish them - have a look at day fifteen
Here is the code:
var size = 2
svg
.append('g')
.selectAll('line')
.data(data)
.join("line")
.attr("y1", (d, i) => yScale(i) + yScale.bandwidth() + size)
.attr("y2", (d, i) => yScale(i) - size)
.attr("x1", (d, i) => xScale(d.greater_sydney))
.attr("x2", (d, i) => xScale(d.greater_sydney))
.attr("class", "average_line")
The full code can be found on my github page here