On Github mkfreeman / info343
Michael Freeman
Building blocks of charts
<!-- Container Div --> <div> <!-- Container svg for visual elements --> <svg> <!-- Rectangle element --> <rect x="10" y="10" height="20" width="100"></rect> </svg> </div>
<script src="http://d3js.org/d3.v3.min.js"></script>
So what can D3 do?
(and D3 can help)
Appending elements to the page
d3.select('#my-div')Append an element
d3.select('#my-div').append('svg')Assign attributes and styles
d3.select('#my-div').append('svg') .attr('width', 100) .attr('height', 100) .style('border', '1px solid black')
// State paths svg.selectAll("path") .data(stateShapes) .enter() .append('path') .attr("d", function(d) { return pathGenerator(d)}) // the "d" attribute defines the shape of the path
In which U.S. states were people born?
All you have to do is learn how to arrange elements into charts
(and D3 can help)Michael Freeman
mikefree@uw.edu
@mf_viz
D3 website
S. Murray's Interactive Data Visualization
Reusable charts by NVD3