Skip to content

Instantly share code, notes, and snippets.

@roundrobin
Created June 28, 2012 04:38
Show Gist options
  • Save roundrobin/3009112 to your computer and use it in GitHub Desktop.
Save roundrobin/3009112 to your computer and use it in GitHub Desktop.
just another inlet to tributary
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:41,y:0},
{x:515,y:127},
{x:516,y:15}];
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(p.x - data[temp].x);
var rangeY = p.y - data[temp].y;
var yscale = d3.scale.linear()
.range([p.x, data[temp].x])
.domain([403, rangeY]);
var toogle = 1;
for(var j = 0; j < rangeX; j++){
var y_effect = yscale(j+Math.sin(j/4)*20);
y_effect = yscale(j);
var x_effect = (data[i].x+j);
//path += 'Q'+p.x+','+p.y+' '+(x_effect)+','+(y_effect);
path += 'L'+(x_effect)+','+(y_effect);
toogle *= -1;
}
}
}
return path;
}
g.selectAll("path")
.data(data1)
.enter().append("svg:path")
.attr("d", toPath(data1))
.attr('fill','none')
.attr('stroke',"#1949C5")
.attr('stroke-width',3)
.attr('transform','translate(100,100)')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment