Created
June 29, 2012 07:20
-
-
Save roundrobin/3016443 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:0,y:0}, | |
{x:210,y:-55.8}, | |
{x:333,y:-55.8}, | |
{x:409,y:57}]; | |
//A,F;G;H;I,L,X,Y,Z | |
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 = data[i].y - data[temp].y; | |
var two_point_form = (data[temp].y - data[i].y) / | |
(data[temp].x - data[i].x); | |
for(var j = p.x; j < rangeX; j++){ | |
var x = j; | |
var y = j*two_point_form; | |
path += 'L'+x+','+(y) | |
} | |
} | |
} | |
path += 'Z'; | |
//console.log('Path',path) | |
return path; | |
} | |
g.selectAll("path") | |
.data(data1) | |
.enter().append("svg:path") | |
.attr("d", toPath(data1)) | |
.attr('fill',"none") | |
.attr('stroke',"#1949C5") | |
.attr('stroke-width',4) | |
.attr('transform','translate(200,200)scale(2)') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment