Friday, 18 July 2014

Putting D3 into a div

So using information from:

  • http://www.w3schools.com/html/tryit.asp?filename=tryhtml_layout_divs
  • http://christopheviau.com/d3_tutorial/
I have managed to put my d3 script into a "div" - i.e. a division of a webpage. 

The key piece of code is here:

"var svg = d3.select("#content")

.append("svg")
    .attr("width", width)
    .attr("height", height);"

when the svg variable is made, it should direct to a "div" using the name of the div after a hash mark (#). 

This then targets the graphic into that div. 

This will allow me to place more than one "div" on the same page. 

This is a VERY good result!

Previous version of the var svg declaration was directed towards "body".

More to learn for sure but this is a good one!




No comments:

Post a Comment