Open mbostock opened 8 years ago
Probably want two versions for above (or top?) and below (bottom?):
function curveStepBelow(context) {
var y0, i;
return {
lineStart: function() { y0 = NaN, i = 0; },
lineEnd: function() {},
point: function(x, y) {
x -= y0 < y ? -0.5 : +0.5, y += 0.5;
if (++i === 1) context.moveTo(x, y0 = y);
else context.lineTo(x, y0), context.lineTo(x, y0 = y);
}
};
}
And two more for left and right…
Useful for drawing a halo around an area that uses d3.curveStepAfter:
As seen in Mona Lisa Histogram.