Upgrade to Pro — share decks privately, control downloads, hide ads and more …

D3

 D3

Quick and dirty introduction to D3

Avatar for David Raynes

David Raynes

August 16, 2012
Tweet

Other Decks in Programming

Transcript

  1. Fancy layouts Tags from The Walters Art Museum Circle size

    is proportional to the number of pieces with the tag Friday, August 17, 12
  2. And interesting relationships Tags from The Walters Art Museum And

    how they link to other tags Tags that appear together are linked The more often, the thicker the link Friday, August 17, 12
  3. What Does D3 Do? D3 does not draw D3 does

    provide a way to tie data to an element D3 does provide a way to define the attributes of that element based on the data Friday, August 17, 12
  4. What Else Does D3 Do? Because the data is tied

    to the elements, D3 is able to determine if data is added or removed D3 can help you manage the transition from old to new Friday, August 17, 12
  5. var data = [ { id: 15, v: 42 },

    { id: 9, v: 17 }, { id: 94, v: 72 } ]; var chart = d3.select(‘#chart’); var d = chart.selectAll(‘div’).data(data, function(d) { return d.id; }); ... Same as earlier ... data = [ { id: 15, v: 42 }, { id: 9, v: 17 }, { id: 54, v: 8 } ]; d = chart.selectAll(‘div’).data(data, function(d) { return d.id; }); d.enter()... (build new elements) d... (update current elements) d.exit()... (handle removed elements) Friday, August 17, 12
  6. Further Reading D3: http://d3js.org D3 demo screencast: http://vimeo.com/35005701 Tasseo (D3

    + Graphite goodness!): https://github.com/ obfuscurity/tasseo Rickshaw, a graphing layer on top of D3: http:// code.shutterstock.com/rickshaw/ Mailstrom http://mailstrom.co (Shameless plug) The Walters API: http://walters-api.herokuapp.com/ playground.html / https://github.com/rayners/walters- api Friday, August 17, 12