Skip to content

Instantly share code, notes, and snippets.

@roundrobin
Created June 22, 2012 04:58
Show Gist options
  • Save roundrobin/2970310 to your computer and use it in GitHub Desktop.
Save roundrobin/2970310 to your computer and use it in GitHub Desktop.
just another inlet to tributary
//Dont change Line below
// Parameters
//var text = $('.CodeMirror-lines div > div pre').html()
// console.log('Hello',text)
//var text = $('.CodeMirror-lines div > div pre:first-child')
//text.append('')
g.append('text')
.attr('y',293)
.attr('id','pathWay')
.text('')
var addText = function(){
var text = d3.select('#pathWay')
if(text.text() != '')
text.text(text.text()+',')
var old = text.text(text.text()+'[1,2]').text()
var result = 'var pathWay = ['+ old + ']'
var text = $('.CodeMirror-lines div > div pre:first-child').html(result)
}
var button1 = createButton('Add path to Editor', addText)
.attr('transform','translate('+[32,83]+')')
var removeText = function(){
var text = $('.CodeMirror-lines div > div pre:first-child').html('var pathWay = []')
}
var button2 = createButton('Remove path from editor', removeText)
.attr('transform','translate('+[30,156]+')')
function createButton(name,callback){
var buttonGroup = g.append('g')
.on('click',callback)
var rect = buttonGroup.append('rect')
.attr('width',122)
.attr('height',45)
.attr('fill',"#922F2F")
var text = buttonGroup.append('text')
.attr('id','pathWay')
.attr('dominant-baseline','hanging')
.attr('font-size','30')
.text(name)
.attr('transform','translate('+[10,9]+')')
var textLength = text.node().getBBox().width;
rect.attr('width',textLength+20)
return buttonGroup;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment