Is there a particular reason to specify offset:0 and offset:1 or could I drop the first and last line altogether, like so?
.selectAll("stop")
.data([
// {offset: 0, color: "red"},
{offset: y(threshold) / height, color: "red"},
{offset: y(threshold) / height, color: "black"},
// {offset: 1, color: "black"}
])