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

d3.js: the core concepts

itszero
July 19, 2015

d3.js: the core concepts

A very introductory view of d3.js, comes with some code example people can play with.

itszero

July 19, 2015
Tweet

More Decks by itszero

Other Decks in Programming

Transcript

  1. const data = [50, 100, 200, 300]; const funNumToPx =

    (num) => `${num}px`; d3.select(‘#ex2') .selectAll('.circle') .data(data) .style('width', funNumToPx) .style('height', funNumToPx); code http://codepen.io/itszero/pen/LVrwPJ
  2. let data = []; const count = nextInt(20); for(let i=0;i<count;i++)

    { data.push(nextInt(400)); } const funNumToPx = (num) => `${num}px`; const sel = d3.select('#ex3') .selectAll('.circle') .data(data); sel.enter() .append('div') .attr('class', 'circle'); sel.transition() .duration(500) .style('width', funNumToPx) .style('height', funNumToPx); sel.exit() .remove(); code enter: create basic div exit: remove the div update: update style prep: generate an array of random numbers http://codepen.io/itszero/pen/rVKXMp
  3. references • paper • 2011 InfoVis • website (examples) •

    http://d3js.org/ • tutorials • https://square.github.io/intro-to-d3/