Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curveStepAbove, curveStepBelow? #68

Open
mbostock opened this issue Jun 3, 2016 · 2 comments
Open

curveStepAbove, curveStepBelow? #68

mbostock opened this issue Jun 3, 2016 · 2 comments

Comments

@mbostock
Copy link
Member

mbostock commented Jun 3, 2016

Useful for drawing a halo around an area that uses d3.curveStepAfter:

function curveStepOutside(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);
    }
  };
}

As seen in Mona Lisa Histogram.

@mbostock
Copy link
Member Author

mbostock commented Jun 3, 2016

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);
    }
  };
}

@mbostock mbostock changed the title curveStepOutside? curveStepAbove, curveStepBelow? Jun 7, 2016
@mbostock
Copy link
Member Author

mbostock commented Jun 7, 2016

And two more for left and right…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant