Created
April 27, 2015 02:52
-
-
Save MrMattSim/abd03d11c83919fb0996 to your computer and use it in GitHub Desktop.
Iconclass depth 1 codes, over time
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
ic_d1 | 1983 | 1984 | 1985 | 1986 | 1987 | 1988 | 1989 | 1990 | 1991 | 1992 | 1993 | 1994 | 1995 | 1996 | 1997 | 1998 | 1999 | 2000 | 2001 | 2002 | 2003 | 2004 | 2005 | 2006 | 2007 | 2008 | 2009 | 2010 | 2011 | 2012 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 0 | 6 | 0 | 0 | 2 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
1 | 0 | 0 | 9 | 1 | 0 | 0 | 1 | 0 | 1 | 5 | 6 | 3 | 0 | 2 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
2 | 36 | 0 | 91 | 17 | 39 | 21 | 24 | 32 | 18 | 40 | 56 | 68 | 56 | 28 | 16 | 12 | 5 | 9 | 7 | 2 | 4 | 5 | 4 | 3 | 7 | 9 | 1 | 3 | 0 | 0 | |
3 | 206 | 6 | 482 | 112 | 374 | 196 | 169 | 421 | 194 | 121 | 265 | 235 | 140 | 124 | 37 | 85 | 26 | 84 | 52 | 71 | 15 | 41 | 29 | 41 | 52 | 35 | 42 | 5 | 0 | 34 | |
4 | 154 | 0 | 269 | 44 | 219 | 104 | 91 | 146 | 111 | 76 | 163 | 166 | 113 | 95 | 22 | 41 | 19 | 48 | 33 | 31 | 18 | 31 | 14 | 24 | 21 | 17 | 6 | 9 | 0 | 6 | |
5 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
6 | 4 | 0 | 2 | 1 | 9 | 0 | 2 | 1 | 6 | 3 | 2 | 1 | 0 | 1 | 4 | 6 | 0 | 0 | 2 | 1 | 0 | 2 | 0 | 11 | 2 | 0 | 0 | 0 | 0 | 0 | |
7 | 1 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
8 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
9 | 2 | 0 | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
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>AIDS poster ICONCLASS</title> | |
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> | |
<style type="text/css"> | |
body { | |
background-color: white; | |
font-family: Helvetica, Arial, sans-serif; | |
} | |
h1 { | |
font-size: 24px; | |
margin: 0; | |
} | |
p { | |
font-size: 14px; | |
margin: 10px 0 0 0; | |
} | |
svg { | |
background-color: white; | |
} | |
circle:hover { | |
fill: orange; | |
} | |
.axis path, | |
.axis line { | |
fill: none; | |
stroke: black; | |
shape-rendering: crispEdges; | |
} | |
.axis text { | |
font-family: sans-serif; | |
font-size: 11px; | |
} | |
.legend {font-size: 10px;} | |
</style> | |
</head> | |
<body> | |
<h1>Iconclass depth 1 codes, over time</h1> | |
<p></p> | |
<script type="text/javascript"> | |
//Dimensions and padding | |
var w = 880; | |
var h = 450; | |
var padding = [ 20, 10, 50, 100 ]; //Top, right, bottom, left | |
//Set up date formatting and years | |
var dateFormat = d3.time.format("%Y"); | |
//Set up scales | |
var xScale = d3.time.scale() | |
.range([ padding[3], w - padding[1] - padding[3] ]); | |
var yScale = d3.scale.linear() | |
.range([ padding[0], h - padding[2] ]); | |
//Configure axis generators | |
var xAxis = d3.svg.axis() | |
.scale(xScale) | |
.orient("bottom") | |
.ticks(15) | |
.tickFormat(function(d) { | |
return dateFormat(d); | |
}); | |
var yAxis = d3.svg.axis() | |
.scale(yScale) | |
.orient("left"); | |
var legend = { | |
0 : {label:"Abstract", color:'rgb(255,255,255)'}, | |
1 : {label:"Religion", color:'rgb(225,223,85)' }, | |
2 : {label:"Nature", color:'rgb(164,231,15)' }, | |
3 : {label:"Humans", color:'rgb(15,197,149)' }, | |
4 : {label:"Culture", color:'rgb(133,95,227)' }, | |
5 : {label:"Ideas", color:'rgb(127,127,127)' }, | |
6 : {label:"History", color:'rgb(0,0,0)' }, | |
7 : {label:"Bible", color:'rgb(224,171,0)'} , | |
8 : {label:"Literature", color:'rgb(128,98,0)' }, | |
9 : {label:"Mythology", color:'rgb(113,88,143)' } | |
} | |
var legendColor = function(n){ | |
return +n < 10 ? legend[n].color : 'rgb(0,0,0)' ; | |
} | |
//Configure line generator | |
var line = d3.svg.line() | |
.x(function(d) { | |
return xScale(dateFormat.parse(d.year)); | |
}) | |
.y(function(d) { | |
return yScale(+d.value); | |
}); | |
//Create the empty SVG image | |
var svg = d3.select("body") | |
.append("svg") | |
.attr("width", w) | |
.attr("height", h); | |
//Load data | |
d3.csv("d3_ic_pivot_d1-year.csv", function(data) { | |
var years = ["1983", "1984", "1985", "1986", "1987", "1988", "1989", "1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012"]; | |
//Create a new, empty array to hold our restructured dataset | |
var dataset = []; | |
//Loop once for each row in data | |
for (var i = 0; i < data.length; i++) { | |
//Create new object with this ic_d1 name and empty array | |
dataset[i] = { | |
d1: data[i].ic_d1, | |
count: [] | |
}; | |
//Loop through all the years | |
for (var j = 0; j < years.length; j++) { | |
// If value is not empty | |
if (data[i][years[j]]) { | |
//Add a new object to the count data array | |
//for this ic_d1 | |
dataset[i].count.push({ | |
year: years[j], | |
value: data[i][years[j]] | |
}); | |
} | |
} | |
} | |
//Set scale domains | |
xScale.domain([ | |
d3.min(years, function(d) { | |
return dateFormat.parse(d); | |
}), | |
d3.max(years, function(d) { | |
return dateFormat.parse(d); | |
}) | |
]); | |
yScale.domain([ | |
d3.max(dataset, function(d) { | |
return d3.max(d.count, function(d) { | |
return +d.value; | |
}); | |
}), | |
0 | |
]); | |
//Make a group for each ic_d1 | |
var groups = svg.selectAll("g") | |
.data(dataset) | |
.enter() | |
.append("g"); | |
//Append a title with the ic_d1 name (so we get easy tooltips) | |
groups.append("title") | |
.text(function(d) { | |
return d.d1; | |
}); | |
//Within each group, create a new line/path, | |
//binding just the emissions data to each one | |
groups.selectAll("path") | |
.data(function(d) { | |
return [ d.count ]; | |
}) | |
.enter() | |
.append("path") | |
.attr("class", "line") | |
.attr("d", line) | |
.attr("fill", "none") | |
.attr("stroke", function(d){ | |
return legendColor(this.parentElement.childNodes[0].innerHTML) | |
}) | |
.attr("stroke-width", 2); | |
//Axes | |
svg.append("g") | |
.attr("class", "x axis") | |
.attr("transform", "translate(0," + (h - padding[2]) + ")") | |
.call(xAxis); | |
svg.append("g") | |
.attr("class", "y axis") | |
.attr("transform", "translate(" + (padding[3]) + ",0)") | |
.call(yAxis); | |
var lgnd = svg.append("g") | |
.attr("class","legend") | |
.attr("transform","translate(700,50)") | |
for (i=0; i < 10; i++) { | |
lgnd.append("circle") | |
.attr("fill", legendColor(i)) | |
.attr("r",6) | |
.attr("cx",0) | |
.attr("cy",i*20 - 4) | |
.attr("opacity",0.6) | |
.attr("stroke","#000") | |
.attr("stroke-width", i == 0 ? 1 : 0); | |
lgnd.append("text") | |
.attr("x",12) | |
.attr("y",i*20) | |
.text(i + " : " + legend[i].label); | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment