A demo of decent-looking axes and axis formatting in D3. SVG also styled to help understand margins.
Line charts with circles and labels. A demonstration of the technique for a student.
An example of d3 nesting with bar charts and rangebands. Original layout based on these bar charts of Oscar favorites for the New York Times.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
date | val | indicators | |
---|---|---|---|
200309 | 4.5 | Furniture_stores | |
200312 | 5.2 | Furniture_stores | |
200403 | 9 | Furniture_stores | |
200406 | 5.9 | Furniture_stores | |
200409 | 6.7 | Furniture_stores | |
200412 | 6 | Furniture_stores | |
200503 | 5.2 | Furniture_stores | |
200506 | 6 | Furniture_stores | |
200509 | 5.2 | Furniture_stores |
A basic bar chart syntax, based off the example publised by the NYT in their series about ESPN.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(maptools) | |
get_second_element <- function(item) { | |
return (item[2]) | |
} | |
get_first_element <- function(item) { | |
return (item[1]) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get_country_data <- function(country_name) { | |
# this puts a plus instead of the space, which is how the URL behaves | |
country_name <- gsub(" ", "+", country_name) | |
#this fixes ivory coast | |
country_name <- gsub("`", "%60", country_name) | |
# first part of the url | |
first_part <- "http://adoption.state.gov/maps/statistics/map_files/statistics.php?special=NONE&year=ALL&country=" |
A short demo of scatterplots with animated transitions, based on this example from the New York Times.
A basic starter for UCB students who want to make a choropleth map. Nearly identical to Mike Bostock's many examples with counties.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style type="text/css"> | |
svg { | |
border:1px solid #f0f; | |
font: 10px arial; | |
} | |
.product-name { | |
text-anchor: end; | |
font-size:13px; | |
font-weight:bold; |