d3 line (2)
d3 line (2)
by Shang-De You
JavaScript
var svg = d3.select("body").append("svg")
.attr("width",400)
.attr("height",300)
var lines = [80,120,160,200,240,280,320]
var linePath = d3.svg.line()
.x(function(d){
return d
})
.y(function(d,i){
return i % 2 == 0 ? 40 : 120
})
linePath.interpolate("linear-closed")
svg.append("path")
.attr("d",linePath(lines))
.attr("stroke","black")
.attr("fill","none")