On Github gdiboulder / d3-slides
Wifi Info
Network: Simple Energy Guest
Password: domorefaster
Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on instruction.
Some "rules"
Wednesday March 19th
Wednesday March 26th
March 29th & 30th
Michael Kelly, designer and web-monkey specializing in data visualization and interaction
First, we need a local web server.
Mac terminal: sudo python -m SimpleHTTPServer 80
PC: Ask Kate
Final product sneak peek!
Let's starting in the console.
var body = d3.select("body"); var p = body.append("html:p"); p.text("Don't be shy...");
d3.select("body") .append("html:p") .text("...develop it!") .style("color", "pink") ;
Step1.js
var dv = { axis: {}, data: { sub: [], max: {} }, draw: {}, format: {}, get: {}, html: {}, opt: { height: 500, width: 700, pad: 30, radius: { min: 5, max: 50 }, fill: ['#0033CC', '#00CC33'], countries: ['Afghanistan','Argentina','Bangladesh','Canada','China','Egypt','Ethiopia','Greece','India','Iran','Nigeria','Russia','Saudi Arabia','Singapore','South Africa','United Kingdom','United States','Vietnam'], year: { start: 1950, end: 2012 }, speed: 750 }, setup: {}, scale: {}, state: { year: 1950 }, svg: {}, update: {} };
/* Step 1 Basic SVG // We need an SVG element in the DOM so we can append other SVG shapes and have them render properly (circles, lines, etc.) // Use the append function to add an SVG element to the main body // Use dv.opt.w and dv.opt.h for the height and width of the element // This is the main svg object dv.draw.main = function() { dv.svg.main = d3.select('CSS SELECTOR').append('svg:svg') .attr('ATTRIBUTE NAME', 'VALUE') .attr('ATTRIBUTE NAME', 'VALUE') ; };
d3.csv('folder/data.csv', function(error, data) { console.log(data); };
Let's talk about asynchronous functions.
Chaining calls together
d3.select('svg').append('svg:circle') .selectAll('circle') .data(data) .enter().append('svg:circle') .attr('cx', function(d, i { return d * i; }) .attr('cy', 10) .attr('r', 10) ;
var xScale = d3.scale.linear() .domain([0, 50000]) .range([0, 100]) ; xScale(25000); // Returns 50
dv.svg.bubbles .transition().duration(500) .attr('cx', function(d) { return d; }) .attr('cy', function(d, i) { return i; }) ;
No new d3 functions here.
Except formatters, and they're dumb.You developed it!