var points = [{x:0,y:0.01},{x:1,y:0.05}, ...];var y = d3.scale.linear().domain([0, 0.8]).range([0+bottomMargin, height]);var x = d3.scale.linear().domain([0, 6.3]).range([0+leftMargin, width]);var line = d3.svg.line().x(function(p){return x(p.x);}).y(function(p){return -y(p.y);}).interpolate("basis");g.append("svg:path").attr("d", line(points));
g.append("svg:line").classed("threshold", true).attr("x1", x(4.3)).attr("y1", 0).attr("x2", x(4.3)).attr("y2", -y(1));
The interpolated value is not exposed, or even calculated directly—D3
generates cubic Bézier segments and then passes it along to the SVG
renderer. So, you could compute it if you had to, but you'd need to
evaluate a cubic Bézier.
Fortunately there's an easy solution in this case, which is to use
clipping. Use an svg:defs element to define your area, then define a
clip path for the area. Then, render the area with an svg:use element,
and clip the line using the previously-defined clip path. Here's an
earlier example that uses clipping:
Mike