Adding the SVG Element
Learn how to add SVG elements to your D3 drawing.
We'll cover the following...
As the title states, the next piece of script forms and adds the SVG element to the web page that D3 will then use to draw on.
The code to add SVG
Press + to interact
var svg = d3.select("body").append("svg").attr("width", width + margin.left + margin.right).attr("height", height + margin.top + margin.bottom).append("g").attr("transform","translate(" + margin.left + "," + margin.top + ")");
What exactly does this mean?
Well D3 needs to be able to have a space defined for it to draw things. ...