Created
June 28, 2012 04:54
-
-
Save roundrobin/3009188 to your computer and use it in GitHub Desktop.
just another inlet to tributary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var type = ["linear", "step-before", | |
"step-after", "basis", | |
"basis-open", "basis-closed", | |
"bundle", "cardinal", | |
"cardinal-open", "cardinal-closed", | |
"monotone"]; | |
var line = d3.svg.line() | |
.x(function(d) { return d.x; }) | |
.y(function(d) { return d.y; }) | |
var data1 = [{x:116,y:0}, | |
{x:739,y:97}, | |
{x:841,y:25}, | |
{x:34,y:-46}, | |
{x:393,y:235},]; | |
function toPath (data){ | |
var path = 'M0,0' | |
for(i in data ){ | |
var p = data[i]; | |
path += 'L'+p.x+','+p.y; | |
var temp = parseInt(i)+1; | |
if(i < (data.length-1)){ | |
var rangeX = Math.abs(data[i].x - data[temp].x); | |
var rangeY = Math.abs(data[i].y - data[temp].y); | |
var yscale = d3.scale.linear() | |
.domain([0, rangeX]) | |
.range([0, rangeY]); | |
for(var j = p.x; j < rangeX; j++){ | |
path += 'L'+(data[i].x+j)+','+(yscale(j+Math.sin(j/20)*103)); | |
} | |
} | |
} | |
return path; | |
} | |
g.selectAll("path") | |
.data(data1) | |
.enter().append("svg:path") | |
.attr("d", toPath(data1)) | |
.attr('fill','none') | |
.attr('stroke',"#1949C5") | |
.attr('stroke-linejoin','miter') | |
.attr('stroke-width',0) | |
.attr('transform','translate(100,100)') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment