How do I update data bound in d3.js?
Why can I only access the bound data but not modifying it?
Also I would like to modify cx using the bound data. But in order to do that I need to update the data.
var dataset = [10, 110];
var svg = d3.select("body").append("svg:svg")
.attr("width", 960)
.attr("height", 500);
var g = svg.append("svg:g");
g.selectAll("circle")
.data(dataset)
.enter()
.append("svg:circle")
.attr("cx", function(d) {return d;} )
.attr("cy", 10 )
.attr("r", 5)
.style("fill", "rgb(125,125,125)")
.call(d3.behavior.drag().on("drag", move));
function move(d){
var dragTarget = d3.select(this);
dragTarget
.attr("cx", d3.event.dx + parseInt(dragTarget.attr("cx")))
.attr("cy", function(){return d3.event.dy + parseInt(dragTarget.attr("cy"))});
d = d + d3.event.dx;
console.log(d);
};