Created
June 29, 2012 08:02
-
-
Save roundrobin/3016578 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:265,y:0}, | |
{x:333,y:8}]; | |
//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 nextPoint = data[temp]; | |
if(nextPoint.x > p.x){ | |
var two_point_form = (p.y - nextPoint.y ) / (p.x - nextPoint.x); | |
console.log('Steigung',two_point_form) | |
for(var j = p.x; j < nextPoint.x-1; j++){ | |
var x = j; | |
var y = j*two_point_form; | |
if(j % 7 == 0) | |
createCircle({x:x,y:y},'red') | |
console.log('Iterate',x,y,p.x,p.y) | |
//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)') | |
for (i in data1){ | |
createCircle(data1[i],'red') | |
} | |
function createCircle(pointD,color){ | |
if(!color){ | |
color = "#B40505"; | |
} | |
var circleHandler = g.append('circle') | |
.attr('r',1) | |
.attr('stroke',color) | |
.attr('stroke-width',1) | |
.attr('fill',"#C940C9") | |
.attr('cx',pointD.x) | |
.attr('cy',pointD.y) | |
.attr('class','circleHandle') | |
.on('mouseover',function(){ d3.select(this).attr('fill',"#B6B623")}) | |
.on('mouseout',function(){ d3.select(this).attr('fill',"#FFFFFF") }) | |
.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