Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
The joy of d3.js
Search
Makoto Inoue
January 30, 2013
3.8k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
The joy of d3.js
Makoto Inoue
January 30, 2013
More Decks by Makoto Inoue
See All by Makoto Inoue
ENS beyond Web3
makoto_inoue
0
190
Tokyo ENS Meetup 2023 June
makoto_inoue
0
150
ENS for your community
makoto_inoue
0
370
ENS for the multi chain world @ EthPorto 2023
makoto_inoue
0
250
ENS on Starknet at StarkWare Session
makoto_inoue
0
190
Ethcc: The State of ENS 2022
makoto_inoue
0
370
EthShanghai ENS integration workshop - May 2022
makoto_inoue
0
210
ENS Integration workshop @ nfthack
makoto_inoue
0
130
ENS as your web3 username
makoto_inoue
0
450
Featured
See All Featured
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
560
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
We Have a Design System, Now What?
morganepeng
55
8.4k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
930
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
300
Transcript
THE JOY OF D3.JS @makoto_inoue London d3.js Meetup Jan 2013
Wednesday, 30 January 13
THE JOY OF STATS http://blog.new-bamboo.co.uk/2013/01/07/the-joy-of-d3-js Wednesday, 30 January 13
THE GAP MINDER http://youtu.be/jbkSRLYSojo Wednesday, 30 January 13
BY @MBOSTOCK http://bost.ocks.org/mike/nations/ Wednesday, 30 January 13
BY @MAKOTO_INOUE http://makoto.github.com/the_joy_of_d3js/ Wednesday, 30 January 13
GOAL “Understand enough basic so that you can tweak examples
by yourself” Wednesday, 30 January 13
ON BENKYO PLAYER http://benkyoplayer.com/courses/3 Wednesday, 30 January 13
TOPICS 1.Introduction 2.Drawing Circles 3.Debugging 4.Basic Transition 5.Scaling 6.Array, Group
And Event 7.Loading Multiple Data files 8.Geo https://github.com/makoto/the_joy_of_d3js/wiki Wednesday, 30 January 13
DRAWING CIRCLES http://makoto.github.com/the_joy_of_d3js/circles.html Wednesday, 30 January 13
DRAWING CIRCLES var width = 500,height = 400, data =
[ {id:1,x:163,y:10}, {id:2,x:326,y:140}, {id:3,x:490,y:270} ] var svg = d3.select("body").append("svg") .attr({ class:"svg", width:width, height:height }) var circle = svg.selectAll("circle") .data(data); circle.enter().append("circle") .attr("cx", function(d){return d.x}) .attr("cy", function(d){return d.y}) .attr("r", 5) Wednesday, 30 January 13
DRAWING CIRCLES var width = 500,height = 400, data =
[ {id:1,x:163,y:10}, {id:2,x:326,y:140}, {id:3,x:490,y:270} ] var svg = d3.select("body").append("svg") .attr({ class:"svg", width:width, height:height }) var circle = svg.selectAll("circle") .data(data); circle.enter().append("circle") .attr("cx", function(d){return d.x}) .attr("cy", function(d){return d.y}) .attr("r", 5) Wednesday, 30 January 13
DRAWING CIRCLES var width = 500,height = 400, data =
[ {id:1,x:163,y:10}, {id:2,x:326,y:140}, {id:3,x:490,y:270} ] var svg = d3.select("body").append("svg") .attr({ class:"svg", width:width, height:height }) var circle = svg.selectAll("circle") .data(data); circle.enter().append("circle") .attr("cx", function(d){return d.x}) .attr("cy", function(d){return d.y}) .attr("r", 5) Wednesday, 30 January 13
DRAWING CIRCLES var width = 500,height = 400, data =
[ {id:1,x:163,y:10}, {id:2,x:326,y:140}, {id:3,x:490,y:270} ] var svg = d3.select("body").append("svg") .attr({ class:"svg", width:width, height:height }) var circle = svg.selectAll("circle") .data(data); circle.enter().append("circle") .attr("cx", function(d){return d.x}) .attr("cy", function(d){return d.y}) .attr("r", 5) Wednesday, 30 January 13
DRAWING CIRCLES var width = 500,height = 400, data =
[ {id:1,x:163,y:10}, {id:2,x:326,y:140}, {id:3,x:490,y:270} ] var svg = d3.select("body").append("svg") .attr({ class:"svg", width:width, height:height }) var circle = svg.selectAll("circle") .data(data); circle.enter().append("circle") .attr("cx", function(d){return d.x}) .attr("cy", function(d){return d.y}) .attr("r", 5) Wednesday, 30 January 13
DRAWING CIRCLES http://bost.ocks.org/mike/join/ Wednesday, 30 January 13
DRAWING CIRCLES var width = 500,height = 400, data =
[ {id:1,x:163,y:10}, {id:2,x:326,y:140}, {id:3,x:490,y:270} ] var svg = d3.select("body").append("svg") .attr({ class:"svg", width:width, height:height }) var circle = svg.selectAll("circle") .data(data); circle.enter().append("circle") .attr("cx", function(d){return d.x}) .attr("cy", function(d){return d.y}) .attr("r", 5) Wednesday, 30 January 13
BASIC TRANSITION http://makoto.github.com/the_joy_of_d3js/transitions.html Wednesday, 30 January 13
BASIC TRANSITION var width = 500, height = 400, data1
= [ {id:1,x:163,y:10}, {id:2,x:326,y:140}, ], data2 = [ {id:2,x:400,y:340}, {id:3,x:290,y:280} ]; var svg = d3.select("body").append("svg") .attr({ class:"svg", width:width, height:height }) Wednesday, 30 January 13
BASIC TRANSITION var chart = function(data){ var circle = svg.selectAll("circle")
.data(data, function(d){ return d.id }) circle.enter().append("circle") .attr("cx", function(d){return d.x}) .attr("cy", function(d){return d.y}) .attr("r", 0) circle.transition().duration(2000) .attr("cx", function(d){return d.x}) .attr("cy", function(d){return d.y}) .attr("r", 5) circle.exit() .remove() } chart(data1) Wednesday, 30 January 13
BASIC TRANSITION var chart = function(data){ var circle = svg.selectAll("circle")
.data(data, function(d){ return d.id }) circle.enter().append("circle") .attr("cx", function(d){return d.x}) .attr("cy", function(d){return d.y}) .attr("r", 0) circle.transition().duration(2000) .attr("cx", function(d){return d.x}) .attr("cy", function(d){return d.y}) .attr("r", 5) circle.exit() .remove() } chart(data1) Wednesday, 30 January 13
BASIC TRANSITION var chart = function(data){ var circle = svg.selectAll("circle")
.data(data, function(d){ return d.id }) circle.enter().append("circle") .attr("cx", function(d){return d.x}) .attr("cy", function(d){return d.y}) .attr("r", 0) circle.transition().duration(2000) .attr("cx", function(d){return d.x}) .attr("cy", function(d){return d.y}) .attr("r", 5) circle.exit() .remove() } chart(data1) Wednesday, 30 January 13
BASIC TRANSITION var chart = function(data){ var circle = svg.selectAll("circle")
.data(data, function(d){ return d.id }) circle.enter().append("circle") .attr("cx", function(d){return d.x}) .attr("cy", function(d){return d.y}) .attr("r", 0) circle.transition().duration(2000) .attr("cx", function(d){return d.x}) .attr("cy", function(d){return d.y}) .attr("r", 5) circle.exit() .remove() } chart(data1) Wednesday, 30 January 13
BASIC TRANSITION var chart = function(data){ var circle = svg.selectAll("circle")
.data(data, function(d){ return d.id }) circle.enter().append("circle") .attr("cx", function(d){return d.x}) .attr("cy", function(d){return d.y}) .attr("r", 0) circle.transition().duration(2000) .attr("cx", function(d){return d.x}) .attr("cy", function(d){return d.y}) .attr("r", 5) circle.exit() .remove() } chart(data1) Wednesday, 30 January 13
BASIC TRANSITION var chart = function(data){ var circle = svg.selectAll("circle")
.data(data, function(d){ return d.id }) circle.enter().append("circle") .attr("cx", function(d){return d.x}) .attr("cy", function(d){return d.y}) .attr("r", 0) circle.transition().duration(2000) .attr("cx", function(d){return d.x}) .attr("cy", function(d){return d.y}) .attr("r", 5) circle.exit() .remove() } chart(data1) Wednesday, 30 January 13
BASIC TRANSITION var chart = function(data){ var circle = svg.selectAll("circle")
.data(data, function(d){ return d.id }) circle.enter().append("circle") .attr("cx", function(d){return d.x}) .attr("cy", function(d){return d.y}) .attr("r", 0) circle.transition().duration(2000) .attr("cx", function(d){return d.x}) .attr("cy", function(d){return d.y}) .attr("r", 5) circle.exit() .remove() } chart(data1) Wednesday, 30 January 13
SCALING http://makoto.github.com/the_joy_of_d3js/scaling.html Wednesday, 30 January 13
SCALING year1 = [ { id:1, region:'africa', population: 10000,lifeExpectancy:163,income:10}, {
id:2, region:'asia', population: 20000,lifeExpectancy:326,income:140 }, ] year2 = [......] Wednesday, 30 January 13
SCALING var x = d3.scale.linear() .domain([0, 400]) .range([0, width -
100]); var y = d3.scale.linear() .domain([0,200]) .range([0, width - 100]) circle.enter().append("circle") .attr("cx", function(d){ return x(d.lifeExpectancy) }) .attr("cy", function(d){ return y(d.income) }) Wednesday, 30 January 13
SCALING var x = d3.scale.linear() .domain([0, 400]) .range([0, width -
100]); var y = d3.scale.linear() .domain([0,200]) .range([0, width - 100]) circle.enter().append("circle") .attr("cx", function(d){ return x(d.lifeExpectancy) }) .attr("cy", function(d){ return y(d.income) }) Wednesday, 30 January 13
SCALING http://www.jeromecukier.net/blog/2011/08/11/d3-scales-and-color/ Wednesday, 30 January 13
SCALING var x = d3.scale.linear() .domain([0, 400]) .range([0, width -
100]); var y = d3.scale.linear() .domain([0,200]) .range([0, width - 100]) circle.enter().append("circle") .attr("cx", function(d){ return x(d.lifeExpectancy) }) .attr("cy", function(d){ return y(d.income) }) Wednesday, 30 January 13
SCALING var yAxis = d3.svg.axis() .scale(y) .orient("left") .tickSize(1) svg.append("g") .attr("class",
"y axis"); d3.select(".y.axis") .call(yAxis); svg.append("text") .attr("class", "y label") .attr("text-anchor", "end") .attr("y", -45) .attr("x", -120) .attr("dy", ".75em") .attr("transform", "rotate(-90)") .text("life expectancy (years)"); Wednesday, 30 January 13
SCALING var yAxis = d3.svg.axis() .scale(y) .orient("left") .tickSize(1) svg.append("g") .attr("class",
"y axis"); d3.select(".y.axis") .call(yAxis); svg.append("text") .attr("class", "y label") .attr("text-anchor", "end") .attr("y", -45) .attr("x", -120) .attr("dy", ".75em") .attr("transform", "rotate(-90)") .text("life expectancy (years)"); Wednesday, 30 January 13
ARRAY, GROUP, EVENT http://makoto.github.com/the_joy_of_d3js/events.html Wednesday, 30 January 13
ARRAY, GROUP, EVENT var group = svg.selectAll(".group") .data(data, function(d){return d.country});
var groupEnter = group.enter().append('g') .attr('class', 'group') var groupUpdate = group.transition().duration(2000) var groupExit = d3.transition(group.exit()) .remove() groupEnter.append("circle") .attr("cx", function(d){return x(d.income)}) .attr("cy", function(d){return y(d.lifeExpectancy)}) .attr("r", 2) .style("fill", function(d){return color(d.country)}) .on('mouseover', function(d){ d3.select(this.parentElement).select('text') .style('opacity', 1) }) Wednesday, 30 January 13
ARRAY, GROUP, EVENT Wednesday, 30 January 13
ARRAY, GROUP, EVENT var group = svg.selectAll(".group") .data(data, function(d){return d.country});
var groupEnter = group.enter().append('g') .attr('class', 'group') var groupUpdate = group.transition().duration(2000) var groupExit = d3.transition(group.exit()) .remove() groupEnter.append("circle") .attr("cx", function(d){return x(d.income)}) .attr("cy", function(d){return y(d.lifeExpectancy)}) .attr("r", 2) .style("fill", function(d){return color(d.country)}) .on('mouseover', function(d){ d3.select(this.parentElement).select('text') .style('opacity', 1) }) Wednesday, 30 January 13
ARRAY, GROUP, EVENT var group = svg.selectAll(".group") .data(data, function(d){return d.country});
var groupEnter = group.enter().append('g') .attr('class', 'group') var groupUpdate = group.transition().duration(2000) var groupExit = d3.transition(group.exit()) .remove() groupEnter.append("circle") .attr("cx", function(d){return x(d.income)}) .attr("cy", function(d){return y(d.lifeExpectancy)}) .attr("r", 2) .style("fill", function(d){return color(d.country)}) .on('mouseover', function(d){ d3.select(this.parentElement).select('text') .style('opacity', 1) }) Wednesday, 30 January 13
GEO Wednesday, 30 January 13
GEO @olivernn will explain Wednesday, 30 January 13
THANKS @makoto_inoue Wednesday, 30 January 13