I am trying to create a text input control in D3 that needs to insert data into text input. I can set the initial value with
d3.selectAll('#textfield')
.data([number])
.attr('value', function(d) { return d })
but it is useless if someone edits the text and then tries to perform an external update. Is there a way to set the content to some arbitrary value?
I have code in JsFiddle .
Update:
I found a workaround :
var node = d3.selectAll('#textfield')
.data([number])
.node()
node.value = number
But I'm not sure if this is the right approach. Any clues?
source
share