-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
301 lines (254 loc) · 8.74 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<!DOCTYPE html>
<html>
<head>
<title>One Year of Photos</title>
<meta name="description" content="A look back on the 365 days of photos after our boys were born.">
<meta charset='utf-8'>
<meta property="og:url" content="http://oneyear.wrightkuhns.com/" />
<meta property="og:title" content="One Year of Photos" />
<meta property="og:description" content="A look back on the 365 days of photos after our boys were born.">
<meta property="og:image" content="http://oneyear.wrightkuhns.com/images/photos/og-image.v1.jpg" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="633" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.1/nv.d3.min.css" />
<link rel="stylesheet" href="css/base.css" />
<link rel="stylesheet" href="css/charts.css" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.1/nv.d3.min.js"></script>
<script>
if(!document.location.host.match(/:4000/)) {
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-25663501-4', 'auto');
ga('send', 'pageview');
}
</script>
</head>
<body>
<h1 id="intro">One Year of Photos</h1>
<p>
One year ago we had the amazing joy of <a href="http://arethetwinsbornyet.wrightkuhns.com">welcoming</a> two boys into our family.
</p>
<p>
Now, one year later, we've documented so many amazing memories!
</p>
<h2 id="total">We took <span id="total_count">over 7,000</span> photos of the boys!</h2>
<div id="total_chart" class="photo-line hide-x">
<div class="xaxis"><div></div></div>
</div>
<p>We generally took photos evenly.</p>
<div id="even">
<div>
<h2 id="dow">Photos per Day of the Week</h2>
<div id="dow_chart" class="photo-line hide-x">
<div class="xaxis"><div></div></div>
</div>
</div>
<div>
<h2 id="kid">Photos per Kid</h2>
<div id="jvg_chart" class="photo-bar hide-y hide-x-tick"></div>
</div>
</div>
<p>Some days we went overboard 😊</p>
<h2 id="top10">Most photographed days</h2>
<div id="top10_table" class="photo-table"></div>
<p>A few days we even slacked off. <span id="no_photos"></span></p>
<p>In the end, it has been a truly wonderful and awe inspiring year.</p>
<h2>Here's to another 365 days of photos and family!</h2>
<footer>© 2015 Marcos Wright-Kuhns – <a href="https://github.com/metavida/photo_stats">source code available</a> under the MIT License</footer>
<script type="text/javascript">
//nv.log = function() {
// args = [];
// for (var i = 0; i < arguments.length; i++) { args.push(arguments[i]); }
// console.log(args);
//}
var stats = {};
function calc_stats() {
d3.csv("https://dl.dropboxusercontent.com/u/422012/permanent/oneyeardata/per_day.csv")
.row(function(d) {
return {key: d['day'], value: parseInt(d['count'], 10) }
})
.get(function(error,data) {
var vals = data.map(function(d) { return d.value });
stats = {
'average' : d3.mean(vals),
'median' : d3.median(vals),
'sum' : d3.sum(vals)
}
d3.select("#total_count")
.text(d3.format(',')(stats.sum))
;
})
;
}
function cumulative_total() {
d3.csv("https://dl.dropboxusercontent.com/u/422012/permanent/oneyeardata/cumulative_total.csv")
.row(function(d) {
return {key: d['day'], value: parseInt(d['count'], 10) }
})
.get(function(error,data) {
nv.addGraph(function() {
var chart = nv.models.lineChart()
.margin(0)
.x(function(d,i) { return i })
.y(function(d,i) { return d.value })
.interpolate('cardinal')
;
chart.xAxis
.showMaxMin(false)
.tickFormat(function(d) {
d = new Date(data[d].key);
return d3.time.format('%d %b %Y')(d)
})
;
chart.yAxis
.showMaxMin(false)
.tickFormat(d3.format(',r'))
;
d3.select('#total_chart')
.append('svg')
.datum([{ values: data, key: 'Total Photos Thus Far', area: true }])
.transition()
.duration(5000)
.call(chart)
;
nv.utils.windowResize(chart.update);
return chart;
})
})
;
}
function per_day_of_week() {
d3.csv("https://dl.dropboxusercontent.com/u/422012/permanent/oneyeardata/per_day_of_week.csv")
.row(function(d) {
return {key: d['day'], value: parseInt(d['count'], 10) }
})
.get(function(error,data) {
nv.addGraph(function() {
var chart = nv.models.lineChart()
.margin(0)
.x(function(d,i) { d = new Date('2015','02',i+2); return d })
.y(function(d,i) { return d.value })
.interpolate('cardinal')
;
chart.xAxis
.showMaxMin(false)
.tickFormat(function(d) { return d3.time.format('%A')(new Date(d)) })
;
chart.yAxis
.showMaxMin(false)
.tickFormat(d3.format(',r'))
//.scale().domain([0, )
//.scale().domain([10, 1000])
;
chart.forceY([d3.min(data.map(function(d) { return d.value })) - 500, 1000]);
chart.lines.scatter.id("dow_chart_line");
d3.select('#dow_chart')
.append('svg')
.datum([{ values: data, key: 'Photos by Day of the Week', area: true }])
.transition()
.duration(0)
.call(chart)
;
nv.utils.windowResize(chart.update);
return chart;
});
})
;
}
function per_subject() {
d3.csv("https://dl.dropboxusercontent.com/u/422012/permanent/oneyeardata/per_subject.csv")
.row(function(d) {
return {key: d['subject'] || 'Both / Neither', value: parseInt(d['count'], 10) }
})
.get(function(error,data) {
nv.addGraph(function() {
var chart = nv.models.discreteBarChart()
.margin(0)
.x(function(d,i) { return d.key })
.y(function(d,i) { return d.value })
.tooltips(false)
.showValues(true)
.valueFormat(d3.format(','))
.color(function(d) { return "rgb(31, 119, 180)" })
;
d3.select('#jvg_chart')
.append('svg')
.datum([{ values: data, key: "Photos by Subject" }])
.call(chart)
;
nv.utils.windowResize(chart.update);
return chart;
});
})
;
}
function top_10() {
d3.csv("https://dl.dropboxusercontent.com/u/422012/permanent/oneyeardata/top_10.csv")
.row(function(d) {
var date = d3.time.format('%d %b %Y')(new Date(d['day']));
return {
'day':date,
'count':parseInt(d['count'], 10),
'photo':d['photo'],
'note':d['note']
};
})
.get(function(error,data) {
var photo_to_img = function(d, even) {
var photos = d['photo'].split(/\+/)
return photos.map(function(img) {
if(img.length > 0)
return '\<img src="images/photos/'+img+'" alt="'+d['note']+'" class="'+(even ? 'even' : 'odd')+'" />';
return '';
}).join(' ');
}
var row = d3.select('#top10_table').selectAll("div")
.data(data)
.enter().append("div");
;
var even = true;
row.selectAll("span")
.data(function(d) {
even = !even;
var gt_avg = (d['count']-stats.average) / stats.average;
return [
['note', d['note']],
['day', d['day']],
['photo', photo_to_img(d,even)],
['count', d['count']+' photos'],
['stat', ''+(isNaN(gt_avg) ? '' : d3.format(',%')(gt_avg)+' \<i>➤\</i> average')]
];
})
.enter()
.append("span")
.attr("class", function(d,i) { return d[0]+"_col"; })
.html(function(d,i) {
return d[1];
})
;
})
;
}
function no_photos() {
d3.csv("https://dl.dropboxusercontent.com/u/422012/permanent/oneyeardata/no_photos.csv")
.row(function(d) {
return d3.time.format('%b %d')(new Date(d['date']));
})
.get(function(error,data) {
d3.select('#no_photos')
.text('(There were '+data.length+' days with no photos at all!)')
;
})
;
}
['calc_stats','cumulative_total', 'per_day_of_week', 'per_subject', 'top_10', 'no_photos']
//['calc_stats','top_10']
//['no_photos']
.forEach(function(chart) { window[chart](); })
;
</script>
</body>
</html>