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"> | |
body { | |
width:700px; | |
margin:20px auto; | |
font-family: arial; | |
} | |
table { | |
border-collapse: collapse; |
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
drug | start | end | type | company | |
---|---|---|---|---|---|
Milk | 6/3/09 | 5/6/10 | Manufacturing delay | Hospira, Bbraun | |
Milk | 2/27/11 | 1/1/12 | Manufacturing delay | Hospira | |
Milk | 1/12/12 | 1/8/14 | Manufacturing delay | Hospira | |
Orange Juice | 4/28/11 | 3/25/14 | Manufacturing delay | Abbott | |
Applesauce | 10/9/12 | 3/13/13 | Failed inspection | Genzyme | |
Applesauce | 12/28/13 | 4/9/14 | Other | Genzyme | |
Jell-O | 5/5/10 | 9/10/11 | Demand increase | Teva | |
Jell-O | 12/15/11 | 3/1/12 | Demand increase | Teva, Bbraun | |
Jell-O | 2/10/13 | 4/9/14 | Other | Teva, Hospira |
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; |
A short demo of scatterplots with animated transitions, based on this example from 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
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=" |
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]) | |
} |
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
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 |
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.