I'm trying to set x
and y
of svg path
elements using the D3 framework. I have written this code to add the source
/target
nodes for each path:
link.enter().insert("path", "g")
.attr("class", "link")
.attr("d", function (d) {
console.dir(d);
var s = {
x: d.source.x0,
y: d.source.y0
};
var t = {
x: d.target.x0,
y: d.target.y0
};
console.log("tx0: " + d.target.x0 + "; ty0: " + d.target.y0);
console.dir(t);
console.log("sx0: " + d.source.x0 + "; sy0: " + d.source.y0);
console.dir(s);
//console.dir(o);
return diagonal({
source: s,
target: t
});
});
When I run it, I get the following console log output:
Can somebody explain why the values of the properties x0
and y0
in the object output are different to those that are logged next, and why the target
properties are undefined?
Edited I edit this d3 example and use Chrome