$30 off During Our Annual Pro Sale. View Details »

Extreme Data Visualisation with d3.js

Extreme Data Visualisation with d3.js

Makoto Inoue

April 14, 2013
Tweet

More Decks by Makoto Inoue

Other Decks in Technology

Transcript

  1. Topics • From BaconTo Benkyo • What is (Extreme) Data

    Visualisation? • Extreme Data Visualisation with d3.js
  2. Branding Policy Expressions likely to be considered a breach of

    the rules would include any two of the following list: "Games, Two Thousand and Twelve, 2012, Twenty-Twelve". http://bit.ly/HRyNGS
  3. Branding Policy Using one of those words with London, medals,

    sponsors, summer, gold, silver or bronze is another likely breach.
  4. BAKERS BANNED FROM ICING CAKES WITH OLYMPIC LOGO BECAUSE OF

    COPY RIGHTS!! - Daily Mail - http://www.dailymail.co.uk/news/article-2037418/London-2012-Olympics-Copyright-laws-ban-bakers-icing-cakes-logo.html
  5. AS THE GAME GOT UNDERWAY, DEVELOPERS TOOK PART IN THE

    FIRST OLYMPIC HACKDAY - Guardian Data Blog http://www.guardian.co.uk/commentisfree/2012/aug/03/london-2012-olympics-open-data
  6. SO, IS THE FIRST OPEN DATA OLYMPICS? NOT THIS TIME

    - Guardian Data Blog Where is Data?
  7. Isn’t this just a table? <table> <tr> <th>Time</th><th>Team</th><th>Player</th> </tr> <tr>

    <td>90:00</td><td class="none"></td><td class="none"></td> <td>90:30</td><td class="man_city"></td><td class="barotelli"></td> <td>91:00</td><td class="none"></td><td class="none"></td> </tr> </table> Yes
  8. What about this? <ul> <li style="width:100px;" class="none">&nbsp;</li> <li style="left:30px; width:20px;"

    class="appeared">&nbsp;</li> <li style="left:80px; width:10px;" class="appeared">&nbsp;</li> </ul> It’s a list
  9. What about this? <g transform="translate(50,1)" class="group"> <rect x="8" y="69" rx="5"

    width="3" height="500" fill="#EEC211"></rect> <rect x="385" y="331" width="18" height="18" style="fill: #e377c2;"> </rect> </g> It’s svg
  10. <g transform="translate(50,1)" class="group"> <rect x="8" y="69" rx="5" width="3" height="500" fill="#EEC211"></rect>

    <rect x="385" y="331" width="18" height="18" style="fill: #e377c2;"> </rect> </g> Appropriate Colour
  11. What did we learn so far? • Shapes, not Objects

    • Different medium => Character • Wrong Transformation => Lack of Skill
  12. What is d3.js ? D3.js is a JavaScript library for

    manipulating documents based on data.
  13. var data = [{start:30, duration:3},{start:80, duration:20}] var ul = d3.select('ul.bin')

    var bar = ul.selectAll("li") .data(data); var x = d3.scale.linear() .domain([0, 100]) .range([0, 800]); var color = d3.scale.category10().domain([1,2]) bar.enter().append('li') .attr('class', 'appeared') .style({ width:function(d){return x(d.duration) + 'px'}, left:function(d){return x(d.start) + 'px'}, 'background-color': function(d, i){return color(i)} }) .text("ɹ") Transforming Data with d3.js
  14. var data = [{start:30, duration:3},{start:80, duration:20}] var ul = d3.select('ul.bin')

    var bar = ul.selectAll("li") .data(data); var x = d3.scale.linear() .domain([0, 100]) .range([0, 800]); var color = d3.scale.category10().domain([1,2]) bar.enter().append('li') .attr('class', 'appeared') .style({ width:function(d){return x(d.duration) + 'px'}, left:function(d){return x(d.start) + 'px'}, 'background-color': function(d, i){return color(i)} }) .text("ɹ") Selector
  15. var data = [{start:30, duration:3},{start:80, duration:20}] var ul = d3.select('ul.bin')

    var bar = ul.selectAll("li") .data(data); var x = d3.scale.linear() .domain([0, 100]) .range([0, 800]); var color = d3.scale.category10().domain([1,2]) bar.enter().append('li') .attr('class', 'appeared') .style({ width:function(d){return x(d.duration) + 'px'}, left:function(d){return x(d.start) + 'px'}, 'background-color': function(d, i){return color(i)} }) .text("ɹ") Dynamic Property
  16. <ul class="bin"> <li class="appeared" style="width: 24px; left: 240px; background-color: rgb(44,

    160, 44);">ɹ </li> <li class="appeared" style="width: 160px; left: 640px; background-color: rgb(31, 119, 180);">ɹ </li> </ul> Result
  17. var data = [{start:30, duration:3},{start:80, duration:20}] var ul = d3.select('ul.bin')

    var bar = ul.selectAll("li") .data(data); var x = d3.scale.linear() .domain([0, 100]) .range([0, 800]); var color = d3.scale.category10().domain([1,2]) bar.enter().append('li') .attr('class', 'appeared') .style({ width:function(d){return x(d.duration) + 'px'}, left:function(d){return x(d.start) + 'px'}, 'background-color': function(d, i){return color(i)} }) .text("ɹ") Binding Data
  18. var data = [{start:30, duration:3},{start:80, duration:20}] var ul = d3.select('ul.bin')

    var bar = ul.selectAll("li") .data(data); var x = d3.scale.linear() .domain([0, 100]) .range([0, 800]); var color = d3.scale.category10().domain([1,2]) bar.enter().append('li') .attr('class', 'appeared') .style({ width:function(d){return x(d.duration) + 'px'}, left:function(d){return x(d.start) + 'px'}, 'background-color': function(d, i){return color(i)} }) .text("ɹ") Binding Data
  19. var data = [{start:30, duration:3},{start:80, duration:20}] var ul = d3.select('ul.bin')

    var bar = ul.selectAll("li") .data(data); var x = d3.scale.linear() .domain([0, 100]) .range([0, 800]); var color = d3.scale.category10().domain([1,2]) bar.enter().append('li') .attr('class', 'appeared') .style({ width:function(d){return x(d.duration) + 'px'}, left:function(d){return x(d.start) + 'px'}, 'background-color': function(d, i){return color(i)} }) .text("ɹ") Scaling Size
  20. var data = [{start:30, duration:3},{start:80, duration:20}] var ul = d3.select('ul.bin')

    var bar = ul.selectAll("li") .data(data); var x = d3.scale.linear() .domain([0, 100]) .range([0, 800]); var color = d3.scale.category10().domain([1,2]) bar.enter().append('li') .attr('class', 'appeared') .style({ width:function(d){return x(d.duration) + 'px'}, left:function(d){return x(d.start) + 'px'}, 'background-color': function(d, i){return color(i)} }) .text("ɹ") Scaling Size http://www.jeromecukier.net/blog/2011/08/11/d3-scales-and-color/
  21. var data = [{start:30, duration:3},{start:80, duration:20}] var ul = d3.select('ul.bin')

    var bar = ul.selectAll("li") .data(data); var x = d3.scale.linear() .domain([0, 100]) .range([0, 800]); var color = d3.scale.category10().domain([1,2]) bar.enter().append('li') .attr('class', 'appeared') .style({ width:function(d){return x(d.duration) + 'px'}, left:function(d){return x(d.start) + 'px'}, 'background-color': function(d, i){return color(i)} }) .text("ɹ") Scaling Color
  22. var data = [{start:30, duration:3},{start:80, duration:20}] var ul = d3.select('ul.bin')

    var bar = ul.selectAll("li") .data(data); var x = d3.scale.linear() .domain([0, 100]) .range([0, 800]); var color = d3.scale.category10().domain([1,2]) bar.enter().append('li') .attr('class', 'appeared') .style({ width:function(d){return x(d.duration) + 'px'}, left:function(d){return x(d.start) + 'px'}, 'background-color': function(d, i){return color(i)} }) .text("ɹ") Dynamic Property
  23. SVG? var data = [{start:30, duration:3}, {start:80, duration:20}] var svg

    = d3.select('body').append('svg') var bar = svg.selectAll("rect") .data(data); var x = d3.scale.linear() .domain([0, 100]) .range([0, 800]); var color = d3.scale.category10().domain([1,2]) bar.enter().append('rect') .attr('class', 'appeared') .attr({ width:function(d){return x(d.duration) + 'px'}, x:function(d){return x(d.start) + 'px'}, height:'10px', }) .style('fill',function(d, i){return color(i)})
  24. var data = [{start:30, duration:3}, {start:80, duration:20}] var svg =

    d3.select('body').append('svg') var bar = svg.selectAll("rect") .data(data); var x = d3.scale.linear() .domain([0, 100]) .range([0, 800]); var color = d3.scale.category10().domain([1,2]) bar.enter().append('rect') .attr('class', 'appeared') .attr({ width:function(d){return x(d.duration) + 'px'}, x:function(d){return x(d.start) + 'px'}, height:'10px', }) .style('fill',function(d, i){return color(i)}) Difference
  25. var data = [{start:30, duration:3}, {start:80, duration:20}] var svg =

    d3.select('body').append('svg') var bar = svg.selectAll("rect") .data(data); var x = d3.scale.linear() .domain([0, 100]) .range([0, 800]); var color = d3.scale.category10().domain([1,2]) bar.enter().append('rect') .attr('class', 'appeared') .attr({ width:function(d){return x(d.duration) + 'px'}, x:function(d){return x(d.start) + 'px'}, height:'10px', }) .style('fill',function(d, i){return color(i)}) Same
  26. What did we learn? • Data, Go get 'em, Tiger

    • Shapes, not Objects • D3.js for Data Transformation