I thought the d3.js append function returns an object added to the selection, but I found that the following two blocks of code give different results:
var svg = d3.select("body") .append("svg") .attr("width", fig_width) .attr("height", fig_height); svg.append("g") .attr("class", "graph") .attr("transform", "translate(" + graph_margin.left + "," + graph_margin.top + ")");
Which, it seems, does not translate the group of graphs, compensating for it with the left and top edges and:
var svg = d3.select("body") .append("svg") .attr("width", fig_width) .attr("height", fig_height) .append("g") .attr("class", "graph") .attr("transform", "translate(" + graph_margin.left + "," + graph_margin.top + ")");
which does.
What I donโt understand about how this works in SVG / d3.js?
source share