Skip to content

Instantly share code, notes, and snippets.

@emagee
Created July 29, 2015 13:08
Show Gist options
  • Save emagee/1a5e994a990e7995fa67 to your computer and use it in GitHub Desktop.
Save emagee/1a5e994a990e7995fa67 to your computer and use it in GitHub Desktop.
Small mults failed attempt 1
Subject date count
Agriculture 2002 1418
Agriculture 2003 1535
Agriculture 2004 1501
Agriculture 2005 1483
Agriculture 2006 1426
Agriculture 2007 1259
Agriculture 2008 1556
Agriculture 2009 1363
Agriculture 2010 1833
Agriculture 2011 1773
Agriculture 2012 2194
Agriculture 2013 1470
Arts 2002 6574
Arts 2003 8431
Arts 2004 8779
Arts 2005 8762
Arts 2006 9201
Arts 2007 9291
Arts 2008 10304
Arts 2009 9860
Arts 2010 10910
Arts 2011 10701
Arts 2012 11320
Arts 2013 11083
Biography 2002 6873
Biography 2003 9837
Biography 2004 9765
Biography 2005 8904
Biography 2006 11271
Biography 2007 11414
Biography 2008 11375
Biography 2009 13795
Biography 2010 12291
Biography 2011 12163
Biography 2012 11333
Biography 2013 10842
Business 2002 6918
Business 2003 7614
Business 2004 7905
Business 2005 7885
Business 2006 8719
Business 2007 7722
Business 2008 8873
Business 2009 9351
Business 2010 10194
Business 2011 10109
Business 2012 13989
Business 2013 11116
Computers 2002 7564
Computers 2003 8955
Computers 2004 6928
Computers 2005 6092
Computers 2006 5472
Computers 2007 6069
Computers 2008 5638
Computers 2009 5276
Computers 2010 7553
Computers 2011 6986
Computers 2012 7028
Computers 2013 6959
Cooking 2002 1956
Cooking 2003 2590
Cooking 2004 2857
Cooking 2005 3062
Cooking 2006 2705
Cooking 2007 2836
Cooking 2008 3164
Cooking 2009 2643
Cooking 2010 3057
Cooking 2011 2963
Cooking 2012 3168
Cooking 2013 3181
Education 2002 6829
Education 2003 7562
Education 2004 7135
Education 2005 6951
Education 2006 6449
Education 2007 7162
Education 2008 9640
Education 2009 9578
Education 2010 10839
Education 2011 11820
Education 2012 11122
Education 2013 10669
Fiction 2002 25102
Fiction 2003 24666
Fiction 2004 38832
Fiction 2005 34927
Fiction 2006 42777
Fiction 2007 53590
Fiction 2008 53058
Fiction 2009 48738
Fiction 2010 46641
Fiction 2011 43016
Fiction 2012 49853
Fiction 2013 50498
General Works 2002 2085
General Works 2003 2195
General Works 2004 4266
General Works 2005 2017
General Works 2006 2078
General Works 2007 2211
General Works 2008 2400
General Works 2009 2562
General Works 2010 3004
General Works 2011 2708
General Works 2012 2507
General Works 2013 2446
History 2002 11362
History 2003 13192
History 2004 14191
History 2005 12686
History 2006 15241
History 2007 14406
History 2008 13477
History 2009 15480
History 2010 14659
History 2011 12270
History 2012 11959
History 2013 12471
Home Economics 2002 1434
Home Economics 2003 1628
Home Economics 2004 1760
Home Economics 2005 1634
Home Economics 2006 1755
Home Economics 2007 1775
Home Economics 2008 1644
Home Economics 2009 1656
Home Economics 2010 1699
Home Economics 2011 1579
Home Economics 2012 1664
Home Economics 2013 1508
Juveniles 2002 30504
Juveniles 2003 33469
Juveniles 2004 37976
Juveniles 2005 32112
Juveniles 2006 30395
Juveniles 2007 31009
Juveniles 2008 29825
Juveniles 2009 33028
Juveniles 2010 31371
Juveniles 2011 30836
Juveniles 2012 33239
Juveniles 2013 32902
Language 2002 5924
Language 2003 6899
Language 2004 6088
Language 2005 5669
Language 2006 5134
Language 2007 4879
Language 2008 6181
Language 2009 5426
Language 2010 4929
Language 2011 4358
Language 2012 4537
Language 2013 4475
Law 2002 4432
Law 2003 4675
Law 2004 4509
Law 2005 5468
Law 2006 5359
Law 2007 5195
Law 2008 5533
Law 2009 5915
Law 2010 5908
Law 2011 5795
Law 2012 5531
Law 2013 6072
Literature 2002 6261
Literature 2003 6493
Literature 2004 7972
Literature 2005 6297
Literature 2006 8227
Literature 2007 9974
Literature 2008 10843
Literature 2009 11456
Literature 2010 9315
Literature 2011 7054
Literature 2012 7004
Literature 2013 8591
Medicine 2002 9495
Medicine 2003 10522
Medicine 2004 11834
Medicine 2005 11688
Medicine 2006 10931
Medicine 2007 10777
Medicine 2008 11022
Medicine 2009 11093
Medicine 2010 12869
Medicine 2011 13690
Medicine 2012 15077
Medicine 2013 13400
Music 2002 3376
Music 2003 3740
Music 2004 4859
Music 2005 4076
Music 2006 3545
Music 2007 3540
Music 2008 4131
Music 2009 4570
Music 2010 3927
Music 2011 3948
Music 2012 4273
Music 2013 5294
Personal Finance 2002 473
Personal Finance 2003 402
Personal Finance 2004 552
Personal Finance 2005 542
Personal Finance 2006 582
Personal Finance 2007 582
Personal Finance 2008 598
Personal Finance 2009 699
Personal Finance 2010 595
Personal Finance 2011 636
Personal Finance 2012 591
Personal Finance 2013 538
Philosophy and Psychology 2002 8894
Philosophy and Psychology 2003 10040
Philosophy and Psychology 2004 11410
Philosophy and Psychology 2005 10556
Philosophy and Psychology 2006 12961
Philosophy and Psychology 2007 13098
Philosophy and Psychology 2008 12605
Philosophy and Psychology 2009 13949
Philosophy and Psychology 2010 14277
Philosophy and Psychology 2011 14011
Philosophy and Psychology 2012 15018
Philosophy and Psychology 2013 15479
Poetry and Drama 2002 5742
Poetry and Drama 2003 7007
Poetry and Drama 2004 9891
Poetry and Drama 2005 9414
Poetry and Drama 2006 10700
Poetry and Drama 2007 11610
Poetry and Drama 2008 11700
Poetry and Drama 2009 13474
Poetry and Drama 2010 11723
Poetry and Drama 2011 9653
Poetry and Drama 2012 10038
Poetry and Drama 2013 10156
Religion 2002 12253
Religion 2003 14517
Religion 2004 21669
Religion 2005 16785
Religion 2006 19854
Religion 2007 19540
Religion 2008 18296
Religion 2009 20527
Religion 2010 18937
Religion 2011 18518
Religion 2012 19854
Religion 2013 18653
Science 2002 11688
Science 2003 12962
Science 2004 12639
Science 2005 12626
Science 2006 12655
Science 2007 12714
Science 2008 14100
Science 2009 15608
Science 2010 20706
Science 2011 19010
Science 2012 18852
Science 2013 18684
Sociology and Economics 2002 20969
Sociology and Economics 2003 23530
Sociology and Economics 2004 23222
Sociology and Economics 2005 23750
Sociology and Economics 2006 27675
Sociology and Economics 2007 24546
Sociology and Economics 2008 24737
Sociology and Economics 2009 26904
Sociology and Economics 2010 28581
Sociology and Economics 2011 28356
Sociology and Economics 2012 28442
Sociology and Economics 2013 29399
Sports and Recreation 2002 5800
Sports and Recreation 2003 6323
Sports and Recreation 2004 6196
Sports and Recreation 2005 6438
Sports and Recreation 2006 6666
Sports and Recreation 2007 6362
Sports and Recreation 2008 6262
Sports and Recreation 2009 5971
Sports and Recreation 2010 6639
Sports and Recreation 2011 6198
Sports and Recreation 2012 6197
Sports and Recreation 2013 5807
Technology 2002 6896
Technology 2003 7142
Technology 2004 7753
Technology 2005 7138
Technology 2006 7262
Technology 2007 7131
Technology 2008 7666
Technology 2009 8688
Technology 2010 11599
Technology 2011 10131
Technology 2012 11564
Technology 2013 9769
Travel 2002 4316
Travel 2003 4172
Travel 2004 5304
Travel 2005 4941
Travel 2006 5376
Travel 2007 5678
Travel 2008 5101
Travel 2009 4800
Travel 2010 4572
Travel 2011 3755
Travel 2012 3603
Travel 2013 3450
subtotal (classified data) 2002 215138
subtotal (classified data) 2003 240098
subtotal (classified data) 2004 275793
subtotal (classified data) 2005 251903
subtotal (classified data) 2006 274416
subtotal (classified data) 2007 284370
subtotal (classified data) 2008 289729
subtotal (classified data) 2009 302410
subtotal (classified data) 2010 308628
subtotal (classified data) 2011 292037
subtotal (classified data) 2012 309957
subtotal (classified data) 2013 304912
non-traditional and unclassified 2002 32639
non-traditional and unclassified 2003 26224
non-traditional and unclassified 2004 19730
non-traditional and unclassified 2005 30597
non-traditional and unclassified 2006 21936
non-traditional and unclassified 2007 123276
non-traditional and unclassified 2008 271851
non-traditional and unclassified 2009 1033065
non-traditional and unclassified 2010 3844278
non-traditional and unclassified 2011 1316714
non-traditional and unclassified 2012 2042840
non-traditional and unclassified 2013 1108183
total 2002 247777
total 2003 266322
total 2004 295523
total 2005 282500
total 2006 296352
total 2007 407646
total 2008 561580
total 2009 1335475
total 2010 4152906
total 2011 1608751
total 2012 2352797
total 2013 1413095
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
margin: 0;
}
.line {
fill: none;
stroke: #666;
stroke-width: 1.5px;
}
.area {
fill: #e7e7e7;
}
</style>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script>
var margin = {top: 8, right: 10, bottom: 2, left: 10},
width = 800 - margin.left - margin.right,
height = 200 - margin.top - margin.bottom;
var parseDate = d3.time.format("%Y").parse;
var x = d3.time.scale()
.range([0, width]);
var y = d3.scale.linear()
.range([height, 0]);
var area = d3.svg.area()
.x(function(d) { return x(d.date); })
.y0(height)
.y1(function(d) { return y(d.count); });
var line = d3.svg.line()
.x(function(d) { return x(d.date); })
.y(function(d) { return y(d.count); });
d3.csv("bowker-data-clean-reformatted-2.csv", type, function(error, data) {
// Nest data by subject.
var subjects = d3.nest()
.key(function(d) { return d.subject; })
.entries(data);
// Compute the maximum count per subject, needed for the y-domain.
subjects.forEach(function(s) {
s.maxCount = d3.max(s.values, function(d) { return d.count; });
});
// Compute the minimum and maximum date across subjects.
// We assume values are sorted by date.
x.domain([
d3.min(subjects, function(s) { return s.values[0].date; }),
d3.max(subjects, function(s) { return s.values[s.values.length - 1].date; })
]);
// Add an SVG element for each subject, with the desired dimensions and margin.
var svg = d3.select("body").selectAll("svg")
.data(subjects)
.enter().append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
// Add the area path elements. Note: the y-domain is set per element.
svg.append("path")
.attr("class", "area")
.attr("d", function(d) { y.domain([0, d.maxCount]); return area(d.values); });
// Add the line path elements. Note: the y-domain is set per element.
svg.append("path")
.attr("class", "line")
.attr("d", function(d) { y.domain([0, d.maxCount]); return line(d.values); });
// Add a small label for the symbol name.
svg.append("text")
.attr("x", width - 6)
.attr("y", height - 6)
.style("text-anchor", "end")
.text(function(d) { return d.key; });
});
function type(d) {
d.count = +d.count;
d.date = parseDate(d.date);
return d;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment