Created by Victor Powell / @vicapow
ok.. no more ads
D3 is not a collection of charts
$('.foo');
$('.foo'); // jQuery
d3.selectAll('.foo'); // D3
$('div'); // jQuery
d3.selectAll('div'); // D3
$('a').attr('href', 'http://vctr.me')
d3.selectAll('a').attr('href', 'http://vctr.me')
$('div').css('color', 'red')
d3.selectAll('div').style('color', 'red')
How are they different?
$('div');
d3.selectAll('div');
d3.selectAll('div').data([18, 4, 7]);
data binding
d3.selectAll('div').data(['red', 'green', 'blue']) .style('color', function(d){ return d})
data binding
d3.selectAll('div').data([18, 4, 7]) .attr('width', function(d){ return d + '%' })
d3.selectAll('div').data([18, 4, 7]);
d3.selectAll('div').data([18, 4, 7]) .enter().append('div');
d3.selectAll('div').data([18, 4, 7, 11]) .enter().append('div');
d3.selectAll('div').data([18, 4]) .exit().remove();
d3.selectAll('div').data([8, 3, 7]) .enter().append('div').style('opacity', 0)
d3.selectAll('div').data([8, 3, 7]) .enter().append('div').style('opacity', 0) .text('hello world') .transition().style('opacity', 1)