Created
April 9, 2015 23:19
-
-
Save mendozaline/8fdc422bccb27045a137 to your computer and use it in GitHub Desktop.
Module 4 Exercise Update #1
This file contains 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
year | stomach | colonRectum | pancreas | lungBronchus | breast | uterus | liver | |
---|---|---|---|---|---|---|---|---|
1930 | 35.2 | 27.1 | 3.8 | 2.6 | 30.1 | 36.3 | 19.3 | |
1931 | 33.8 | 27.7 | 4.1 | 2.6 | 30.6 | 36.5 | 18.6 | |
1932 | 33.7 | 28.5 | 4.5 | 2.8 | 30.9 | 36.7 | 18.6 | |
1933 | 32.5 | 28.7 | 4.3 | 3.0 | 30.8 | 35.6 | 17.4 | |
1934 | 31.6 | 29.7 | 4.4 | 3.1 | 31.6 | 35.6 | 17.0 | |
1935 | 31.4 | 30.2 | 4.7 | 3.5 | 31.3 | 35.7 | 16.5 | |
1936 | 30.9 | 31.5 | 5.1 | 3.9 | 32.0 | 36.0 | 16.1 | |
1937 | 29.2 | 31.9 | 5.0 | 3.8 | 31.6 | 35.6 | 15.4 | |
1938 | 28.9 | 32.4 | 5.4 | 4.1 | 32.4 | 34.4 | 14.9 | |
1939 | 26.9 | 33.0 | 5.6 | 4.1 | 32.5 | 34.3 | 14.1 | |
1940 | 25.7 | 33.5 | 5.4 | 4.1 | 33.8 | 34.0 | 13.6 | |
1941 | 24.6 | 33.1 | 5.7 | 4.6 | 32.7 | 32.7 | 13.3 | |
1942 | 25.0 | 33.1 | 5.6 | 4.7 | 32.8 | 32.1 | 13.4 | |
1943 | 23.5 | 34.1 | 5.2 | 4.9 | 32.6 | 32.4 | 14.1 | |
1944 | 22.5 | 34.3 | 5.5 | 5.1 | 32.0 | 31.9 | 13.7 | |
1945 | 22.2 | 34.5 | 5.9 | 5.3 | 32.9 | 31.6 | 12.9 | |
1946 | 21.1 | 34.5 | 6.0 | 5.5 | 33.0 | 30.9 | 12.3 | |
1947 | 20.7 | 35.2 | 6.2 | 6.1 | 33.5 | 30.6 | 12.2 | |
1948 | 20.6 | 34.8 | 6.7 | 6.4 | 34.6 | 29.4 | 11.3 | |
1949 | 18.5 | 33.2 | 6.9 | 5.6 | 31.9 | 27.0 | 10.5 | |
1950 | 17.6 | 32.3 | 6.8 | 5.8 | 31.9 | 26.2 | 9.8 | |
1951 | 16.5 | 31.9 | 6.7 | 5.9 | 31.6 | 24.5 | 9.4 | |
1952 | 16.1 | 31.5 | 7.1 | 6.1 | 31.6 | 23.8 | 9.5 | |
1953 | 15.6 | 31.4 | 7.1 | 6.0 | 32.2 | 23.6 | 9.2 | |
1954 | 14.8 | 31.2 | 7.3 | 6.0 | 31.8 | 22.5 | 8.7 | |
1955 | 13.7 | 31.1 | 7.3 | 6.2 | 32.5 | 22.0 | 8.4 | |
1956 | 13.5 | 30.4 | 7.9 | 6.3 | 32.3 | 21.0 | 8.1 | |
1957 | 12.7 | 30.4 | 7.6 | 6.4 | 32.1 | 20.6 | 8.0 | |
1958 | 12.3 | 29.9 | 7.8 | 6.7 | 31.3 | 20.3 | 7.7 | |
1959 | 11.8 | 29.5 | 7.8 | 6.7 | 31.1 | 19.2 | 7.5 | |
1960 | 11.5 | 29.8 | 8.0 | 6.9 | 31.8 | 18.9 | 7.3 | |
1961 | 10.7 | 29.5 | 8.1 | 7.4 | 31.7 | 18.3 | 6.9 | |
1962 | 10.4 | 29.0 | 8.3 | 7.6 | 31.4 | 17.8 | 6.7 | |
1963 | 10.2 | 28.8 | 8.3 | 8.1 | 31.2 | 17.4 | 6.5 | |
1964 | 9.2 | 28.3 | 8.2 | 8.3 | 31.6 | 16.9 | 6.4 | |
1965 | 9.0 | 27.8 | 8.3 | 8.9 | 32.0 | 16.4 | 6.4 | |
1966 | 8.7 | 28.1 | 8.4 | 9.6 | 31.9 | 15.6 | 6.1 | |
1967 | 8.2 | 27.4 | 8.4 | 10.1 | 32.1 | 15.0 | 6.2 | |
1968 | 7.9 | 27.3 | 8.5 | 11.8 | 32.4 | 14.3 | 5.9 | |
1969 | 7.5 | 27.1 | 8.7 | 12.5 | 31.7 | 13.7 | 5.7 | |
1970 | 7.1 | 26.9 | 8.6 | 13.3 | 32.2 | 13.1 | 5.5 | |
1971 | 6.8 | 26.4 | 8.4 | 14.4 | 31.7 | 12.9 | 5.3 | |
1972 | 6.6 | 26.4 | 8.3 | 15.2 | 32.3 | 12.6 | 5.2 | |
1973 | 6.3 | 25.8 | 8.4 | 15.8 | 32.4 | 12.0 | 4.9 | |
1974 | 6.1 | 25.8 | 8.6 | 16.9 | 32.1 | 11.6 | 4.9 | |
1975 | 5.9 | 25.2 | 8.4 | 17.8 | 31.4 | 10.9 | 4.7 | |
1976 | 5.7 | 25.8 | 8.6 | 19.2 | 31.8 | 10.8 | 4.5 | |
1977 | 5.4 | 25.2 | 8.8 | 20.3 | 32.5 | 10.2 | 4.5 | |
1978 | 5.5 | 25.5 | 8.8 | 21.7 | 31.7 | 10.0 | 4.5 | |
1979 | 5.2 | 25.0 | 8.8 | 22.5 | 31.2 | 9.6 | 4.5 | |
1980 | 5.1 | 24.7 | 8.8 | 24.3 | 31.7 | 9.6 | 4.5 | |
1981 | 5.0 | 24.3 | 8.9 | 25.1 | 31.9 | 9.2 | 4.3 | |
1982 | 4.9 | 23.9 | 8.8 | 26.7 | 32.2 | 9.0 | 4.4 | |
1983 | 4.8 | 23.6 | 9.1 | 28.3 | 32.1 | 8.9 | 4.2 | |
1984 | 4.7 | 23.9 | 9.2 | 29.1 | 32.9 | 8.6 | 4.2 | |
1985 | 4.4 | 23.4 | 9.0 | 30.6 | 33.0 | 8.5 | 4.3 | |
1986 | 4.2 | 22.6 | 9.2 | 31.6 | 32.9 | 8.3 | 4.2 | |
1987 | 4.2 | 22.3 | 9.2 | 32.9 | 32.7 | 8.1 | 4.1 | |
1988 | 4.2 | 21.8 | 9.0 | 34.3 | 33.2 | 8.0 | 4.1 | |
1989 | 4.2 | 21.5 | 9.2 | 35.9 | 33.2 | 7.9 | 4.2 | |
1990 | 4.2 | 21.0 | 9.3 | 37.0 | 33.1 | 8.0 | 4.2 | |
1991 | 4.0 | 20.6 | 9.3 | 37.8 | 32.7 | 7.7 | 4.3 | |
1992 | 3.9 | 20.2 | 9.3 | 38.9 | 31.6 | 7.7 | 4.3 | |
1993 | 3.8 | 20.1 | 9.4 | 39.4 | 31.4 | 7.6 | 4.4 | |
1994 | 3.7 | 19.6 | 9.3 | 39.8 | 30.9 | 7.5 | 4.4 | |
1995 | 3.7 | 19.5 | 9.2 | 40.4 | 30.6 | 7.4 | 4.5 | |
1996 | 3.5 | 18.8 | 9.2 | 40.6 | 29.5 | 7.3 | 4.4 | |
1997 | 3.4 | 18.5 | 9.1 | 40.9 | 28.2 | 7.1 | 4.4 | |
1998 | 3.4 | 18.3 | 9.2 | 41.1 | 27.5 | 7.1 | 4.3 | |
1999 | 3.3 | 18.0 | 9.3 | 40.3 | 26.6 | 6.9 | 4.4 | |
2000 | 3.2 | 17.8 | 9.3 | 41.2 | 26.6 | 6.9 | 4.3 | |
2001 | 3.1 | 17.4 | 9.3 | 41.1 | 26.0 | 6.9 | 4.4 | |
2002 | 3.0 | 16.9 | 9.2 | 41.7 | 25.6 | 6.7 | 4.3 | |
2003 | 3.0 | 16.5 | 9.3 | 41.4 | 25.3 | 6.6 | 4.3 | |
2004 | 2.9 | 15.6 | 9.3 | 41.0 | 24.5 | 6.6 | 4.5 | |
2005 | 2.7 | 15.1 | 9.5 | 40.8 | 24.1 | 6.5 | 4.5 | |
2006 | 2.7 | 15.0 | 9.6 | 40.3 | 23.6 | 6.7 | 4.5 | |
2007 | 2.6 | 14.6 | 9.5 | 40.2 | 23.0 | 6.6 | 4.4 | |
2008 | 2.5 | 14.3 | 9.7 | 39.2 | 22.6 | 6.6 | 4.4 | |
2009 | 2.4 | 13.6 | 9.5 | 38.7 | 22.2 | 6.5 | 4.5 | |
2010 | 2.5 | 13.3 | 9.6 | 38.0 | 21.9 | 6.7 | 4.7 | |
2011 | 2.3 | 13.1 | 9.5 | 37.1 | 21.5 | 6.8 | 4.7 |
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Module 4 Exercise</title> | |
<script type="text/javascript" src="http://d3js.org/d3.v3.js"></script> | |
<style type="text/css"> | |
body { | |
font-family: Segoe, Arial,sans-serif; | |
} | |
h1 { | |
font-size: 20px; | |
} | |
p { | |
font-size: 15px; | |
} | |
#description, | |
#footer { | |
width: 85%; | |
max-width: 850px; | |
text-align: left; | |
margin-left: 15px; | |
} | |
svg { | |
background-color: #FFFFFF; | |
} | |
.y.axis path { | |
opacity: 0.0; | |
} | |
.y.axis line { | |
opacity: 1.0; | |
stroke: #000000; | |
shape-rendering: crispEdges; | |
} | |
.y.axis text { | |
fill: #000000; | |
font-size: 15px; | |
font-weight: bold; | |
} | |
.x.axis path { | |
fill: none; | |
stroke: none; | |
shape-rendering: crispEdges; | |
} | |
.x.axis line { | |
fill: none; | |
stroke: #000000; | |
shape-rendering: crispEdges; | |
} | |
.x.axis text { | |
fill: #000000; | |
font-size: 15px; | |
} | |
.hover text { | |
fill: rgba(0, 0, 0, 1.0); | |
font-weight: bold; | |
} | |
.hover rect{ | |
fill: rgba(250,159,181, 1.0); | |
} | |
.gridlines { | |
stroke-width: 2; | |
stroke: #FFFFFF; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="description"> | |
<h1>Age-adjusted Stomach Cancer Death Rate Per 100,000 Women, 1930-2011</h1> | |
<p>In the United States, the stomach cancer death rate has fallen considerably from 35.2 per 100,000 women in 1930 to 2.3 in 2011 — or a decrease of 93%. According to the American Cancer Society, the increased use of antibiotics and refrigeration may have <a href="http://www.cancer.org/cancer/stomachcancer/detailedguide/stomach-cancer-key-statistics">contributed</a> to this decline.</p> | |
</div> | |
<script type="text/javascript"> | |
var w = 850; | |
var h = 850; | |
var padding = [ 15, 5, 0, 55 ]; //Top, right, bottom, left | |
var z = padding[3] | |
var widthScale = d3.scale.linear() | |
.range([ 0, w - padding[1] - padding[3] - z]); | |
var heightScale = d3.scale.ordinal() | |
.rangeRoundBands([ padding[0], h - padding[2] ], 0.2); | |
var xAxis = d3.svg.axis() | |
.scale(widthScale) | |
.tickValues([ 5, 10, 15, 20, 25, 30, 35 ]) | |
.orient("top"); | |
var yAxis = d3.svg.axis() | |
.scale(heightScale) | |
.tickValues([ 1930, 1940, 1950, 1960, 1970, 1980, 1990, 2000, 2010]) | |
.orient("left"); | |
var svg = d3.select("body") | |
.append("svg") | |
.attr({ | |
width: w, | |
height: h, | |
}); | |
d3.csv("female_cancer_death_rates.csv", function(data) { | |
console.log(data); | |
widthScale.domain([ 0, d3.max(data, function(d) { | |
return +d.stomach; }) ]); | |
heightScale.domain(data.map(function(d) { | |
return +d.year; }) ); | |
var barGroup = svg.selectAll("g") | |
.data(data) | |
.enter() | |
.append("g") | |
barGroup.append("rect") | |
.attr({ | |
x: padding[3] + z, | |
y: function(d) { return heightScale(d.year); }, | |
width: function(d) { return widthScale(d.stomach); }, | |
height: heightScale.rangeBand(), | |
"fill": "rgba(174, 1, 126, 1.0)", | |
}) | |
.append("title") | |
.text(function(d) { | |
return "In " + d.year + ", the stomach cancer death rate was " + d.stomach + " per 100,000 women."; | |
}); | |
barGroup.append("text") | |
.attr({ | |
x: (padding[3] * .7) + z, | |
y: function(d) { return heightScale(d.year) + 8; }, | |
"text-anchor": "end", | |
"font-size": "11px", | |
}) | |
.text(function(d) { return d.stomach; }); | |
svg.append("line") | |
.attr({ | |
"class": "gridlines", | |
x1: 214.5, | |
y1: 0, | |
x2: 214.5, | |
y2: 850, | |
}); | |
svg.append("line") | |
.attr({ | |
"class": "gridlines", | |
x1: 318.75, | |
y1: 0, | |
x2: 318.75, | |
y2: 850, | |
}); | |
svg.append("line") | |
.attr({ | |
"class": "gridlines", | |
x1: 423, | |
y1: 0, | |
x2: 423, | |
y2: 850, | |
}); | |
svg.append("line") | |
.attr({ | |
"class": "gridlines", | |
x1: 527.25, | |
y1: 0, | |
x2: 527.25, | |
y2: 850, | |
}); | |
svg.append("line") | |
.attr({ | |
"class": "gridlines", | |
x1: 632, | |
y1: 0, | |
x2: 632, | |
y2: 850, | |
}); | |
svg.append("line") | |
.attr({ | |
"class": "gridlines", | |
x1: 736.25, | |
y1: 0, | |
x2: 736.25, | |
y2: 850, | |
}); | |
svg.append("line") | |
.attr({ | |
"class": "gridlines", | |
x1: 840.75, | |
y1: 0, | |
x2: 840.75, | |
y2: 850, | |
}); | |
svg.append("g") | |
.attr("class", "x axis") | |
.attr("transform", "translate(" + (padding[3] + z) + ", " + 20 + ")") | |
.call(xAxis); | |
svg.append("g") | |
.attr("class", "y axis") | |
.attr("transform", "translate(" + padding[3] + ", 0)") | |
.call(yAxis); | |
barGroup.style("cursor", "pointer") | |
barGroup.on("mouseover", function() { | |
d3.select(this) | |
.classed("hover", true) | |
}); | |
barGroup.on("mouseout", function() { | |
d3.select(this) | |
.classed("hover", false) | |
}); | |
}); | |
</script> | |
<div id="footer"> | |
<p><b>Data source:</b> <a href="http://www.cancer.org/research/cancerfactsstatistics/cancerfactsfigures2015/index">American Cancer Society, Cancer Facts & Figures 2015</a>.</p> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment