/
data-driven-documents.html
531 lines (485 loc) · 68.9 KB
/
data-driven-documents.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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>The Open Digital Archaeology Textbook</title>
<meta name="description" content="The Open Digital Archaeology Textbook combines instructive text with a computational DA laboratory">
<meta name="generator" content="bookdown 0.7 and GitBook 2.6.7">
<meta property="og:title" content="The Open Digital Archaeology Textbook" />
<meta property="og:type" content="book" />
<meta property="og:image" content="images/brandon-green-321795-unsplash.jpg" />
<meta property="og:description" content="The Open Digital Archaeology Textbook combines instructive text with a computational DA laboratory" />
<meta name="github-repo" content="o-date/draft" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="The Open Digital Archaeology Textbook" />
<meta name="twitter:description" content="The Open Digital Archaeology Textbook combines instructive text with a computational DA laboratory" />
<meta name="twitter:image" content="images/brandon-green-321795-unsplash.jpg" />
<meta name="author" content="Shawn Graham, Neha Gupta, Jolene Smith, Andreas Angourakis, Andrew Reinhard, Kate Ellenberger, Zack Batist, Joel Rivard, Ben Marwick, Michael Carter, Beth Compton, Rob Blades, & Cristina Wood">
<meta name="date" content="2018-12-14">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="prev" href="statistical-computing-with-r-and-python-notebooks-reproducible-code.html">
<link rel="next" href="storytelling-and-the-archaeological-cms-omeka-kora-and-mukurtu.html">
<script src="libs/jquery-2.2.3/jquery.min.js"></script>
<link href="libs/gitbook-2.6.7/css/style.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-bookdown.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-highlight.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-search.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-fontsettings.css" rel="stylesheet" />
<script src="https://hypothes.is/embed.js" async></script>
<link rel="stylesheet" href="css/custom.css">
<style type="text/css">
div.sourceCode { overflow-x: auto; }
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
margin: 0; padding: 0; vertical-align: baseline; border: none; }
table.sourceCode { width: 100%; line-height: 100%; }
td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
td.sourceCode { padding-left: 5px; }
code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
code > span.dt { color: #902000; } /* DataType */
code > span.dv { color: #40a070; } /* DecVal */
code > span.bn { color: #40a070; } /* BaseN */
code > span.fl { color: #40a070; } /* Float */
code > span.ch { color: #4070a0; } /* Char */
code > span.st { color: #4070a0; } /* String */
code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
code > span.ot { color: #007020; } /* Other */
code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
code > span.fu { color: #06287e; } /* Function */
code > span.er { color: #ff0000; font-weight: bold; } /* Error */
code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
code > span.cn { color: #880000; } /* Constant */
code > span.sc { color: #4070a0; } /* SpecialChar */
code > span.vs { color: #4070a0; } /* VerbatimString */
code > span.ss { color: #bb6688; } /* SpecialString */
code > span.im { } /* Import */
code > span.va { color: #19177c; } /* Variable */
code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code > span.op { color: #666666; } /* Operator */
code > span.bu { } /* BuiltIn */
code > span.ex { } /* Extension */
code > span.pp { color: #bc7a00; } /* Preprocessor */
code > span.at { color: #7d9029; } /* Attribute */
code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
</style>
<link rel="stylesheet" href="css/style.css" type="text/css" />
</head>
<body>
<div class="book without-animation with-summary font-size-2 font-family-1" data-basepath=".">
<div class="book-summary">
<nav role="navigation">
<ul class="summary">
<li><a href="./">ODATE</a></li>
<li class="divider"></li>
<li class="chapter" data-level="" data-path="index.html"><a href="index.html"><i class="fa fa-check"></i>notice</a></li>
<li class="chapter" data-level="" data-path="about-the-authors.html"><a href="about-the-authors.html"><i class="fa fa-check"></i>About the Authors</a><ul>
<li class="chapter" data-level="" data-path="about-the-authors.html"><a href="about-the-authors.html#shawn-graham"><i class="fa fa-check"></i>Shawn Graham</a></li>
<li class="chapter" data-level="" data-path="about-the-authors.html"><a href="about-the-authors.html#neha-gupta"><i class="fa fa-check"></i>Neha Gupta</a></li>
<li class="chapter" data-level="" data-path="about-the-authors.html"><a href="about-the-authors.html#michael-carter"><i class="fa fa-check"></i>Michael Carter</a></li>
<li class="chapter" data-level="" data-path="about-the-authors.html"><a href="about-the-authors.html#beth-compton"><i class="fa fa-check"></i>Beth Compton</a></li>
<li class="chapter" data-level="" data-path="about-the-authors.html"><a href="about-the-authors.html#jolene-smith"><i class="fa fa-check"></i>Jolene Smith</a></li>
<li class="chapter" data-level="" data-path="about-the-authors.html"><a href="about-the-authors.html#andreas-angourakis"><i class="fa fa-check"></i>Andreas Angourakis</a></li>
<li class="chapter" data-level="" data-path="about-the-authors.html"><a href="about-the-authors.html#andrew-reinhard"><i class="fa fa-check"></i>Andrew Reinhard</a></li>
<li class="chapter" data-level="" data-path="about-the-authors.html"><a href="about-the-authors.html#kate-ellenberger"><i class="fa fa-check"></i>Kate Ellenberger</a></li>
<li class="chapter" data-level="" data-path="about-the-authors.html"><a href="about-the-authors.html#zack-batist"><i class="fa fa-check"></i>Zack Batist</a></li>
<li class="chapter" data-level="" data-path="about-the-authors.html"><a href="about-the-authors.html#joel-rivard"><i class="fa fa-check"></i>Joel Rivard</a></li>
<li class="chapter" data-level="" data-path="about-the-authors.html"><a href="about-the-authors.html#ben-marwick"><i class="fa fa-check"></i>Ben Marwick</a></li>
<li class="chapter" data-level="" data-path="about-the-authors.html"><a href="about-the-authors.html#rob-blades"><i class="fa fa-check"></i>Rob Blades</a></li>
<li class="chapter" data-level="" data-path="about-the-authors.html"><a href="about-the-authors.html#cristina-wood"><i class="fa fa-check"></i>Cristina Wood</a></li>
<li class="chapter" data-level="" data-path="about-the-authors.html"><a href="about-the-authors.html#editorial-board"><i class="fa fa-check"></i>Editorial Board</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="getting-started.html"><a href="getting-started.html"><i class="fa fa-check"></i>Getting Started</a><ul>
<li class="chapter" data-level="" data-path="instructors-how-to-use-this-text.html"><a href="instructors-how-to-use-this-text.html"><i class="fa fa-check"></i>Instructors: How to use this text</a></li>
<li class="chapter" data-level="" data-path="students-how-to-use-this-text.html"><a href="students-how-to-use-this-text.html"><i class="fa fa-check"></i>Students: How to use this text</a></li>
<li class="chapter" data-level="" data-path="how-to-contribute-changes-or-make-your-own-version.html"><a href="how-to-contribute-changes-or-make-your-own-version.html"><i class="fa fa-check"></i>How to contribute changes, or make your own version</a></li>
<li class="chapter" data-level="" data-path="how-to-access-and-use-the-computational-environment.html"><a href="how-to-access-and-use-the-computational-environment.html"><i class="fa fa-check"></i>How to access and use the computational environment</a></li>
<li class="chapter" data-level="" data-path="colophon.html"><a href="colophon.html"><i class="fa fa-check"></i>Colophon</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="welcome.html"><a href="welcome.html"><i class="fa fa-check"></i>Welcome!</a></li>
<li class="chapter" data-level="1" data-path="going-digital.html"><a href="going-digital.html"><i class="fa fa-check"></i><b>1</b> Going Digital</a><ul>
<li class="chapter" data-level="1.0.1" data-path="going-digital.html"><a href="going-digital.html#further-reading"><i class="fa fa-check"></i><b>1.0.1</b> Further Reading</a></li>
<li class="chapter" data-level="1.1" data-path="so-what-is-digital-archaeology.html"><a href="so-what-is-digital-archaeology.html"><i class="fa fa-check"></i><b>1.1</b> So what is Digital Archaeology?</a><ul>
<li class="chapter" data-level="1.1.1" data-path="so-what-is-digital-archaeology.html"><a href="so-what-is-digital-archaeology.html#a-distant-view"><i class="fa fa-check"></i><b>1.1.1</b> A distant view</a></li>
<li class="chapter" data-level="1.1.2" data-path="so-what-is-digital-archaeology.html"><a href="so-what-is-digital-archaeology.html#is-digital-archaeology-part-of-the-digital-humanities"><i class="fa fa-check"></i><b>1.1.2</b> Is digital archaeology part of the digital humanities?</a></li>
<li class="chapter" data-level="1.1.3" data-path="so-what-is-digital-archaeology.html"><a href="so-what-is-digital-archaeology.html#archaeological-glitch-art"><i class="fa fa-check"></i><b>1.1.3</b> Archaeological Glitch Art</a></li>
<li class="chapter" data-level="1.1.4" data-path="so-what-is-digital-archaeology.html"><a href="so-what-is-digital-archaeology.html#the-cool-factor-and-the-tensions-of-cool"><i class="fa fa-check"></i><b>1.1.4</b> The ‘cool’ factor and the tensions of cool</a></li>
<li class="chapter" data-level="1.1.5" data-path="so-what-is-digital-archaeology.html"><a href="so-what-is-digital-archaeology.html#takeaways"><i class="fa fa-check"></i><b>1.1.5</b> Takeaways</a></li>
<li class="chapter" data-level="1.1.6" data-path="so-what-is-digital-archaeology.html"><a href="so-what-is-digital-archaeology.html#exercises"><i class="fa fa-check"></i><b>1.1.6</b> Exercises</a></li>
</ul></li>
<li class="chapter" data-level="1.2" data-path="project-management-basics.html"><a href="project-management-basics.html"><i class="fa fa-check"></i><b>1.2</b> Project Management Basics</a><ul>
<li class="chapter" data-level="1.2.1" data-path="project-management-basics.html"><a href="project-management-basics.html#take-aways"><i class="fa fa-check"></i><b>1.2.1</b> Take-aways</a></li>
<li class="chapter" data-level="1.2.2" data-path="project-management-basics.html"><a href="project-management-basics.html#exercises-1"><i class="fa fa-check"></i><b>1.2.2</b> exercises</a></li>
</ul></li>
<li class="chapter" data-level="1.3" data-path="github-version-control.html"><a href="github-version-control.html"><i class="fa fa-check"></i><b>1.3</b> Github & Version Control</a><ul>
<li class="chapter" data-level="1.3.1" data-path="github-version-control.html"><a href="github-version-control.html#the-core-functions-of-git"><i class="fa fa-check"></i><b>1.3.1</b> The core functions of Git</a></li>
<li class="chapter" data-level="1.3.2" data-path="github-version-control.html"><a href="github-version-control.html#key-terms"><i class="fa fa-check"></i><b>1.3.2</b> Key Terms</a></li>
<li class="chapter" data-level="1.3.3" data-path="github-version-control.html"><a href="github-version-control.html#take-aways-1"><i class="fa fa-check"></i><b>1.3.3</b> Take-aways</a></li>
<li class="chapter" data-level="1.3.4" data-path="github-version-control.html"><a href="github-version-control.html#further-reading-1"><i class="fa fa-check"></i><b>1.3.4</b> Further Reading</a></li>
<li class="chapter" data-level="1.3.5" data-path="github-version-control.html"><a href="github-version-control.html#exercises-2"><i class="fa fa-check"></i><b>1.3.5</b> Exercises</a></li>
<li class="chapter" data-level="1.3.6" data-path="github-version-control.html"><a href="github-version-control.html#warnings"><i class="fa fa-check"></i><b>1.3.6</b> Warnings</a></li>
</ul></li>
<li class="chapter" data-level="1.4" data-path="open-notebook-research-scholarly-communication.html"><a href="open-notebook-research-scholarly-communication.html"><i class="fa fa-check"></i><b>1.4</b> Open Notebook Research & Scholarly Communication</a><ul>
<li class="chapter" data-level="1.4.1" data-path="open-notebook-research-scholarly-communication.html"><a href="open-notebook-research-scholarly-communication.html#how-to-ask-questions"><i class="fa fa-check"></i><b>1.4.1</b> How to Ask Questions</a></li>
<li class="chapter" data-level="1.4.2" data-path="open-notebook-research-scholarly-communication.html"><a href="open-notebook-research-scholarly-communication.html#discussion"><i class="fa fa-check"></i><b>1.4.2</b> discussion</a></li>
<li class="chapter" data-level="1.4.3" data-path="open-notebook-research-scholarly-communication.html"><a href="open-notebook-research-scholarly-communication.html#take-aways-2"><i class="fa fa-check"></i><b>1.4.3</b> Take-aways</a></li>
<li class="chapter" data-level="1.4.4" data-path="open-notebook-research-scholarly-communication.html"><a href="open-notebook-research-scholarly-communication.html#further-reading-2"><i class="fa fa-check"></i><b>1.4.4</b> Further Reading</a></li>
<li class="chapter" data-level="1.4.5" data-path="open-notebook-research-scholarly-communication.html"><a href="open-notebook-research-scholarly-communication.html#on-privilege-and-open-notebooks"><i class="fa fa-check"></i><b>1.4.5</b> On Privilege and Open Notebooks</a></li>
<li class="chapter" data-level="1.4.6" data-path="open-notebook-research-scholarly-communication.html"><a href="open-notebook-research-scholarly-communication.html#exercises-3"><i class="fa fa-check"></i><b>1.4.6</b> exercises</a></li>
</ul></li>
<li class="chapter" data-level="1.5" data-path="failing-productively.html"><a href="failing-productively.html"><i class="fa fa-check"></i><b>1.5</b> Failing Productively</a><ul>
<li class="chapter" data-level="1.5.1" data-path="failing-productively.html"><a href="failing-productively.html#a-taxonomy-of-fails"><i class="fa fa-check"></i><b>1.5.1</b> A taxonomy of fails</a></li>
<li class="chapter" data-level="1.5.2" data-path="failing-productively.html"><a href="failing-productively.html#exercises-4"><i class="fa fa-check"></i><b>1.5.2</b> Exercises</a></li>
</ul></li>
<li class="chapter" data-level="1.6" data-path="the-ethics-of-big-data-in-archaeology.html"><a href="the-ethics-of-big-data-in-archaeology.html"><i class="fa fa-check"></i><b>1.6</b> The Ethics of Big Data in Archaeology</a><ul>
<li class="chapter" data-level="1.6.1" data-path="the-ethics-of-big-data-in-archaeology.html"><a href="the-ethics-of-big-data-in-archaeology.html#exercises-5"><i class="fa fa-check"></i><b>1.6.1</b> exercises</a></li>
</ul></li>
<li class="chapter" data-level="1.7" data-path="effective-collaboration.html"><a href="effective-collaboration.html"><i class="fa fa-check"></i><b>1.7</b> Effective Collaboration</a><ul>
<li class="chapter" data-level="1.7.1" data-path="effective-collaboration.html"><a href="effective-collaboration.html#the-two-sentence-pitch"><i class="fa fa-check"></i><b>1.7.1</b> The Two-Sentence Pitch</a></li>
<li class="chapter" data-level="1.7.2" data-path="effective-collaboration.html"><a href="effective-collaboration.html#consulting-colleagues-and-stakeholders"><i class="fa fa-check"></i><b>1.7.2</b> Consulting Colleagues and Stakeholders</a></li>
<li class="chapter" data-level="1.7.3" data-path="effective-collaboration.html"><a href="effective-collaboration.html#making-a-plan"><i class="fa fa-check"></i><b>1.7.3</b> Making a Plan</a></li>
<li class="chapter" data-level="1.7.4" data-path="effective-collaboration.html"><a href="effective-collaboration.html#persisting-and-adapting-your-plan"><i class="fa fa-check"></i><b>1.7.4</b> Persisting and Adapting your Plan</a></li>
<li class="chapter" data-level="1.7.5" data-path="effective-collaboration.html"><a href="effective-collaboration.html#exercises-6"><i class="fa fa-check"></i><b>1.7.5</b> Exercises</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="2" data-path="making-data-useful.html"><a href="making-data-useful.html"><i class="fa fa-check"></i><b>2</b> Making Data Useful</a><ul>
<li class="chapter" data-level="2.1" data-path="proper-prior-planning.html"><a href="proper-prior-planning.html"><i class="fa fa-check"></i><b>2.1</b> Proper Prior Planning</a><ul>
<li class="chapter" data-level="2.1.1" data-path="proper-prior-planning.html"><a href="proper-prior-planning.html#making-data-sensible-pre-planning"><i class="fa fa-check"></i><b>2.1.1</b> Making Data Sensible: Pre-Planning</a></li>
<li class="chapter" data-level="2.1.2" data-path="proper-prior-planning.html"><a href="proper-prior-planning.html#making-data-durable-preservation-and-longevity"><i class="fa fa-check"></i><b>2.1.2</b> Making Data Durable: Preservation and Longevity</a></li>
<li class="chapter" data-level="2.1.3" data-path="proper-prior-planning.html"><a href="proper-prior-planning.html#takeaways-1"><i class="fa fa-check"></i><b>2.1.3</b> Takeaways</a></li>
<li class="chapter" data-level="2.1.4" data-path="proper-prior-planning.html"><a href="proper-prior-planning.html#further-reading-3"><i class="fa fa-check"></i><b>2.1.4</b> Further Reading</a></li>
</ul></li>
<li class="chapter" data-level="2.2" data-path="designing-data-collection-and-curation.html"><a href="designing-data-collection-and-curation.html"><i class="fa fa-check"></i><b>2.2</b> Designing Data Collection and Curation</a><ul>
<li class="chapter" data-level="2.2.1" data-path="designing-data-collection-and-curation.html"><a href="designing-data-collection-and-curation.html#takeaways-2"><i class="fa fa-check"></i><b>2.2.1</b> Takeaways</a></li>
<li class="chapter" data-level="2.2.2" data-path="designing-data-collection-and-curation.html"><a href="designing-data-collection-and-curation.html#further-reading-4"><i class="fa fa-check"></i><b>2.2.2</b> Further Reading</a></li>
</ul></li>
<li class="chapter" data-level="2.3" data-path="cleaning-data.html"><a href="cleaning-data.html"><i class="fa fa-check"></i><b>2.3</b> Cleaning Data</a><ul>
<li class="chapter" data-level="2.3.1" data-path="cleaning-data.html"><a href="cleaning-data.html#tools"><i class="fa fa-check"></i><b>2.3.1</b> Tools</a></li>
<li class="chapter" data-level="2.3.2" data-path="cleaning-data.html"><a href="cleaning-data.html#cleaning-tasks"><i class="fa fa-check"></i><b>2.3.2</b> Cleaning Tasks</a></li>
<li class="chapter" data-level="2.3.3" data-path="cleaning-data.html"><a href="cleaning-data.html#takeaways-3"><i class="fa fa-check"></i><b>2.3.3</b> Takeaways</a></li>
<li class="chapter" data-level="2.3.4" data-path="cleaning-data.html"><a href="cleaning-data.html#further-reading-5"><i class="fa fa-check"></i><b>2.3.4</b> Further Reading</a></li>
</ul></li>
<li class="chapter" data-level="2.4" data-path="arranging-and-storing-data-for-the-long-haul-databases.html"><a href="arranging-and-storing-data-for-the-long-haul-databases.html"><i class="fa fa-check"></i><b>2.4</b> Arranging and Storing Data for the Long Haul (Databases!)</a><ul>
<li class="chapter" data-level="" data-path="arranging-and-storing-data-for-the-long-haul-databases.html"><a href="arranging-and-storing-data-for-the-long-haul-databases.html#flat-tables"><i class="fa fa-check"></i>Flat tables</a></li>
<li class="chapter" data-level="2.4.1" data-path="arranging-and-storing-data-for-the-long-haul-databases.html"><a href="arranging-and-storing-data-for-the-long-haul-databases.html#takeaways-4"><i class="fa fa-check"></i><b>2.4.1</b> Takeaways</a></li>
<li class="chapter" data-level="2.4.2" data-path="arranging-and-storing-data-for-the-long-haul-databases.html"><a href="arranging-and-storing-data-for-the-long-haul-databases.html#further-reading-6"><i class="fa fa-check"></i><b>2.4.2</b> Further Reading</a></li>
<li class="chapter" data-level="2.4.3" data-path="arranging-and-storing-data-for-the-long-haul-databases.html"><a href="arranging-and-storing-data-for-the-long-haul-databases.html#exercises-7"><i class="fa fa-check"></i><b>2.4.3</b> Exercises</a></li>
</ul></li>
<li class="chapter" data-level="2.5" data-path="linked-open-data-and-data-publishing.html"><a href="linked-open-data-and-data-publishing.html"><i class="fa fa-check"></i><b>2.5</b> Linked Open Data and Data Publishing</a></li>
<li class="chapter" data-level="2.6" data-path="using-application-programming-interfaces-apis-to-retrieve-data.html"><a href="using-application-programming-interfaces-apis-to-retrieve-data.html"><i class="fa fa-check"></i><b>2.6</b> Using Application Programming Interfaces (APIS) to Retrieve Data</a><ul>
<li class="chapter" data-level="2.6.1" data-path="using-application-programming-interfaces-apis-to-retrieve-data.html"><a href="using-application-programming-interfaces-apis-to-retrieve-data.html#exercises-8"><i class="fa fa-check"></i><b>2.6.1</b> Exercises</a></li>
</ul></li>
<li class="chapter" data-level="2.7" data-path="scraping-data.html"><a href="scraping-data.html"><i class="fa fa-check"></i><b>2.7</b> Scraping Data</a><ul>
<li class="chapter" data-level="2.7.1" data-path="scraping-data.html"><a href="scraping-data.html#exercises-9"><i class="fa fa-check"></i><b>2.7.1</b> Exercises</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="3" data-path="finding-and-communicating-the-compelling-story.html"><a href="finding-and-communicating-the-compelling-story.html"><i class="fa fa-check"></i><b>3</b> Finding and Communicating the Compelling Story</a><ul>
<li class="chapter" data-level="3.1" data-path="designing-for-accessibility.html"><a href="designing-for-accessibility.html"><i class="fa fa-check"></i><b>3.1</b> Designing for Accessibility</a><ul>
<li class="chapter" data-level="3.1.1" data-path="designing-for-accessibility.html"><a href="designing-for-accessibility.html#screen-readers-text-browsers-html-labels-and-headings"><i class="fa fa-check"></i><b>3.1.1</b> Screen Readers, Text Browsers, HTML Labels, and Headings</a></li>
<li class="chapter" data-level="3.1.2" data-path="designing-for-accessibility.html"><a href="designing-for-accessibility.html#contrast-and-styles"><i class="fa fa-check"></i><b>3.1.2</b> Contrast and Styles</a></li>
<li class="chapter" data-level="3.1.3" data-path="designing-for-accessibility.html"><a href="designing-for-accessibility.html#font"><i class="fa fa-check"></i><b>3.1.3</b> Font</a></li>
<li class="chapter" data-level="3.1.4" data-path="designing-for-accessibility.html"><a href="designing-for-accessibility.html#going-forward"><i class="fa fa-check"></i><b>3.1.4</b> Going Forward</a></li>
<li class="chapter" data-level="3.1.5" data-path="designing-for-accessibility.html"><a href="designing-for-accessibility.html#exercises-10"><i class="fa fa-check"></i><b>3.1.5</b> Exercises</a></li>
<li class="chapter" data-level="3.1.6" data-path="designing-for-accessibility.html"><a href="designing-for-accessibility.html#further-reading-7"><i class="fa fa-check"></i><b>3.1.6</b> Further Reading</a></li>
</ul></li>
<li class="chapter" data-level="3.2" data-path="statistical-computing-with-r-and-python-notebooks-reproducible-code.html"><a href="statistical-computing-with-r-and-python-notebooks-reproducible-code.html"><i class="fa fa-check"></i><b>3.2</b> Statistical Computing with R and Python Notebooks; Reproducible code</a><ul>
<li class="chapter" data-level="3.2.1" data-path="statistical-computing-with-r-and-python-notebooks-reproducible-code.html"><a href="statistical-computing-with-r-and-python-notebooks-reproducible-code.html#reproducible-methods"><i class="fa fa-check"></i><b>3.2.1</b> Reproducible Methods</a></li>
<li class="chapter" data-level="3.2.2" data-path="statistical-computing-with-r-and-python-notebooks-reproducible-code.html"><a href="statistical-computing-with-r-and-python-notebooks-reproducible-code.html#exercises-11"><i class="fa fa-check"></i><b>3.2.2</b> exercises</a></li>
</ul></li>
<li class="chapter" data-level="3.3" data-path="data-driven-documents.html"><a href="data-driven-documents.html"><i class="fa fa-check"></i><b>3.3</b> Data Driven Documents</a><ul>
<li class="chapter" data-level="3.3.1" data-path="data-driven-documents.html"><a href="data-driven-documents.html#d3"><i class="fa fa-check"></i><b>3.3.1</b> D3</a></li>
<li class="chapter" data-level="3.3.2" data-path="data-driven-documents.html"><a href="data-driven-documents.html#discussion-1"><i class="fa fa-check"></i><b>3.3.2</b> discussion</a></li>
<li class="chapter" data-level="3.3.3" data-path="data-driven-documents.html"><a href="data-driven-documents.html#exercises-12"><i class="fa fa-check"></i><b>3.3.3</b> exercises</a></li>
</ul></li>
<li class="chapter" data-level="3.4" data-path="storytelling-and-the-archaeological-cms-omeka-kora-and-mukurtu.html"><a href="storytelling-and-the-archaeological-cms-omeka-kora-and-mukurtu.html"><i class="fa fa-check"></i><b>3.4</b> Storytelling and the Archaeological CMS: Omeka, Kora, and Mukurtu</a><ul>
<li class="chapter" data-level="3.4.1" data-path="storytelling-and-the-archaeological-cms-omeka-kora-and-mukurtu.html"><a href="storytelling-and-the-archaeological-cms-omeka-kora-and-mukurtu.html#the-content-management-system"><i class="fa fa-check"></i><b>3.4.1</b> The Content Management System</a></li>
<li class="chapter" data-level="3.4.2" data-path="storytelling-and-the-archaeological-cms-omeka-kora-and-mukurtu.html"><a href="storytelling-and-the-archaeological-cms-omeka-kora-and-mukurtu.html#omeka"><i class="fa fa-check"></i><b>3.4.2</b> Omeka</a></li>
<li class="chapter" data-level="3.4.3" data-path="storytelling-and-the-archaeological-cms-omeka-kora-and-mukurtu.html"><a href="storytelling-and-the-archaeological-cms-omeka-kora-and-mukurtu.html#kora"><i class="fa fa-check"></i><b>3.4.3</b> Kora</a></li>
<li class="chapter" data-level="3.4.4" data-path="storytelling-and-the-archaeological-cms-omeka-kora-and-mukurtu.html"><a href="storytelling-and-the-archaeological-cms-omeka-kora-and-mukurtu.html#mukurtu"><i class="fa fa-check"></i><b>3.4.4</b> Mukurtu</a></li>
<li class="chapter" data-level="3.4.5" data-path="storytelling-and-the-archaeological-cms-omeka-kora-and-mukurtu.html"><a href="storytelling-and-the-archaeological-cms-omeka-kora-and-mukurtu.html#exercises-13"><i class="fa fa-check"></i><b>3.4.5</b> Exercises</a></li>
</ul></li>
<li class="chapter" data-level="3.5" data-path="what-is-web-mapping.html"><a href="what-is-web-mapping.html"><i class="fa fa-check"></i><b>3.5</b> What is Web Mapping?</a><ul>
<li class="chapter" data-level="3.5.1" data-path="what-is-web-mapping.html"><a href="what-is-web-mapping.html#overview-of-map-services"><i class="fa fa-check"></i><b>3.5.1</b> Overview of Map Services</a></li>
<li class="chapter" data-level="3.5.2" data-path="what-is-web-mapping.html"><a href="what-is-web-mapping.html#making-a-web-map-with-leaflet"><i class="fa fa-check"></i><b>3.5.2</b> Making a web map with Leaflet</a></li>
<li class="chapter" data-level="3.5.3" data-path="what-is-web-mapping.html"><a href="what-is-web-mapping.html#exercises-14"><i class="fa fa-check"></i><b>3.5.3</b> Exercises</a></li>
<li class="chapter" data-level="3.5.4" data-path="what-is-web-mapping.html"><a href="what-is-web-mapping.html#resources"><i class="fa fa-check"></i><b>3.5.4</b> Resources</a></li>
</ul></li>
<li class="chapter" data-level="3.6" data-path="virtual-archaeology.html"><a href="virtual-archaeology.html"><i class="fa fa-check"></i><b>3.6</b> Virtual Archaeology</a><ul>
<li class="chapter" data-level="3.6.1" data-path="virtual-archaeology.html"><a href="virtual-archaeology.html#basic-principles"><i class="fa fa-check"></i><b>3.6.1</b> Basic principles</a></li>
<li class="chapter" data-level="3.6.2" data-path="virtual-archaeology.html"><a href="virtual-archaeology.html#main-challenge"><i class="fa fa-check"></i><b>3.6.2</b> Main Challenge</a></li>
<li class="chapter" data-level="3.6.3" data-path="virtual-archaeology.html"><a href="virtual-archaeology.html#the-archaeological-narrative"><i class="fa fa-check"></i><b>3.6.3</b> The Archaeological Narrative</a></li>
<li class="chapter" data-level="3.6.4" data-path="virtual-archaeology.html"><a href="virtual-archaeology.html#theoretical-pragmatism"><i class="fa fa-check"></i><b>3.6.4</b> Theoretical Pragmatism</a></li>
<li class="chapter" data-level="3.6.5" data-path="virtual-archaeology.html"><a href="virtual-archaeology.html#phenomenology-and-virtual-archaeology"><i class="fa fa-check"></i><b>3.6.5</b> Phenomenology and Virtual Archaeology</a></li>
<li class="chapter" data-level="3.6.6" data-path="virtual-archaeology.html"><a href="virtual-archaeology.html#lasting-considerations"><i class="fa fa-check"></i><b>3.6.6</b> Lasting Considerations</a></li>
<li class="chapter" data-level="3.6.7" data-path="virtual-archaeology.html"><a href="virtual-archaeology.html#exercises-15"><i class="fa fa-check"></i><b>3.6.7</b> Exercises</a></li>
</ul></li>
<li class="chapter" data-level="3.7" data-path="archaeogaming.html"><a href="archaeogaming.html"><i class="fa fa-check"></i><b>3.7</b> Archaeogaming</a><ul>
<li class="chapter" data-level="3.7.1" data-path="archaeogaming.html"><a href="archaeogaming.html#archaeological-reception"><i class="fa fa-check"></i><b>3.7.1</b> Archaeological Reception</a></li>
<li class="chapter" data-level="3.7.2" data-path="archaeogaming.html"><a href="archaeogaming.html#games-as-archaeology"><i class="fa fa-check"></i><b>3.7.2</b> Games as Archaeology</a></li>
<li class="chapter" data-level="3.7.3" data-path="archaeogaming.html"><a href="archaeogaming.html#archaeogaming-projects-past-and-present"><i class="fa fa-check"></i><b>3.7.3</b> Archaeogaming Projects Past and Present</a></li>
<li class="chapter" data-level="3.7.4" data-path="archaeogaming.html"><a href="archaeogaming.html#is-archaeogaming-archaeology-a-future-of-the-discipline."><i class="fa fa-check"></i><b>3.7.4</b> Is Archaeogaming Archaeology? A Future of the Discipline.</a></li>
<li class="chapter" data-level="3.7.5" data-path="archaeogaming.html"><a href="archaeogaming.html#exercises-16"><i class="fa fa-check"></i><b>3.7.5</b> Exercises</a></li>
<li class="chapter" data-level="3.7.6" data-path="archaeogaming.html"><a href="archaeogaming.html#further-reading-8"><i class="fa fa-check"></i><b>3.7.6</b> Further Reading</a></li>
</ul></li>
<li class="chapter" data-level="3.8" data-path="social-media-as-public-engagement-scholarly-communication-in-archaeology.html"><a href="social-media-as-public-engagement-scholarly-communication-in-archaeology.html"><i class="fa fa-check"></i><b>3.8</b> Social Media as Public Engagement & Scholarly Communication in Archaeology</a><ul>
<li class="chapter" data-level="3.8.1" data-path="social-media-as-public-engagement-scholarly-communication-in-archaeology.html"><a href="social-media-as-public-engagement-scholarly-communication-in-archaeology.html#social-media-as-outreach"><i class="fa fa-check"></i><b>3.8.1</b> Social Media as Outreach</a></li>
<li class="chapter" data-level="3.8.2" data-path="social-media-as-public-engagement-scholarly-communication-in-archaeology.html"><a href="social-media-as-public-engagement-scholarly-communication-in-archaeology.html#social-media-to-keep-current-on-research"><i class="fa fa-check"></i><b>3.8.2</b> Social Media to Keep Current on Research</a></li>
<li class="chapter" data-level="3.8.3" data-path="social-media-as-public-engagement-scholarly-communication-in-archaeology.html"><a href="social-media-as-public-engagement-scholarly-communication-in-archaeology.html#four-moves-or-getting-at-the-truth"><i class="fa fa-check"></i><b>3.8.3</b> Four Moves, or, Getting at the Truth</a></li>
<li class="chapter" data-level="3.8.4" data-path="social-media-as-public-engagement-scholarly-communication-in-archaeology.html"><a href="social-media-as-public-engagement-scholarly-communication-in-archaeology.html#exercises-17"><i class="fa fa-check"></i><b>3.8.4</b> exercises</a></li>
</ul></li>
<li class="chapter" data-level="3.9" data-path="computational-creativity.html"><a href="computational-creativity.html"><i class="fa fa-check"></i><b>3.9</b> Computational Creativity</a><ul>
<li class="chapter" data-level="3.9.1" data-path="computational-creativity.html"><a href="computational-creativity.html#twitterbots-with-tracery"><i class="fa fa-check"></i><b>3.9.1</b> Twitterbots with Tracery</a></li>
<li class="chapter" data-level="3.9.2" data-path="computational-creativity.html"><a href="computational-creativity.html#chatbots"><i class="fa fa-check"></i><b>3.9.2</b> Chatbots</a></li>
<li class="chapter" data-level="3.9.3" data-path="computational-creativity.html"><a href="computational-creativity.html#sonification"><i class="fa fa-check"></i><b>3.9.3</b> Sonification</a></li>
<li class="chapter" data-level="3.9.4" data-path="computational-creativity.html"><a href="computational-creativity.html#worldbuilding"><i class="fa fa-check"></i><b>3.9.4</b> Worldbuilding</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="4" data-path="eliding-the-digital-and-the-physical.html"><a href="eliding-the-digital-and-the-physical.html"><i class="fa fa-check"></i><b>4</b> Eliding the Digital and the Physical</a><ul>
<li class="chapter" data-level="4.1" data-path="d-photogrammetry.html"><a href="d-photogrammetry.html"><i class="fa fa-check"></i><b>4.1</b> 3D Photogrammetry</a><ul>
<li class="chapter" data-level="4.1.1" data-path="d-photogrammetry.html"><a href="d-photogrammetry.html#basic-principles-1"><i class="fa fa-check"></i><b>4.1.1</b> Basic principles</a></li>
<li class="chapter" data-level="4.1.2" data-path="d-photogrammetry.html"><a href="d-photogrammetry.html#further-readings"><i class="fa fa-check"></i><b>4.1.2</b> Further Readings</a></li>
<li class="chapter" data-level="4.1.3" data-path="d-photogrammetry.html"><a href="d-photogrammetry.html#exercises-19"><i class="fa fa-check"></i><b>4.1.3</b> exercises</a></li>
</ul></li>
<li class="chapter" data-level="4.2" data-path="d-printing-raspberry-pi-and-maker-archaeology.html"><a href="d-printing-raspberry-pi-and-maker-archaeology.html"><i class="fa fa-check"></i><b>4.2</b> 3D Printing, Raspberry Pi and “Maker” Archaeology</a><ul>
<li class="chapter" data-level="4.2.1" data-path="d-printing-raspberry-pi-and-maker-archaeology.html"><a href="d-printing-raspberry-pi-and-maker-archaeology.html#overview"><i class="fa fa-check"></i><b>4.2.1</b> Overview</a></li>
<li class="chapter" data-level="4.2.2" data-path="d-printing-raspberry-pi-and-maker-archaeology.html"><a href="d-printing-raspberry-pi-and-maker-archaeology.html#d-printing---a-workflow"><i class="fa fa-check"></i><b>4.2.2</b> 3d Printing - a Workflow</a></li>
<li class="chapter" data-level="4.2.3" data-path="d-printing-raspberry-pi-and-maker-archaeology.html"><a href="d-printing-raspberry-pi-and-maker-archaeology.html#using-raspberry-pi-in-the-field"><i class="fa fa-check"></i><b>4.2.3</b> Using Raspberry Pi in the Field</a></li>
<li class="chapter" data-level="4.2.4" data-path="d-printing-raspberry-pi-and-maker-archaeology.html"><a href="d-printing-raspberry-pi-and-maker-archaeology.html#discussion-2"><i class="fa fa-check"></i><b>4.2.4</b> Discussion</a></li>
<li class="chapter" data-level="4.2.5" data-path="d-printing-raspberry-pi-and-maker-archaeology.html"><a href="d-printing-raspberry-pi-and-maker-archaeology.html#further-reading-9"><i class="fa fa-check"></i><b>4.2.5</b> Further Reading</a></li>
</ul></li>
<li class="chapter" data-level="4.3" data-path="place-based-interpretation-with-locative-augmented-reality.html"><a href="place-based-interpretation-with-locative-augmented-reality.html"><i class="fa fa-check"></i><b>4.3</b> Place-based Interpretation with Locative Augmented Reality</a><ul>
<li class="chapter" data-level="4.3.1" data-path="place-based-interpretation-with-locative-augmented-reality.html"><a href="place-based-interpretation-with-locative-augmented-reality.html#projection-mapping"><i class="fa fa-check"></i><b>4.3.1</b> Projection Mapping</a></li>
<li class="chapter" data-level="4.3.2" data-path="place-based-interpretation-with-locative-augmented-reality.html"><a href="place-based-interpretation-with-locative-augmented-reality.html#exercises-20"><i class="fa fa-check"></i><b>4.3.2</b> exercises</a></li>
</ul></li>
<li class="chapter" data-level="4.4" data-path="artificial-intelligence-in-digital-archaeology.html"><a href="artificial-intelligence-in-digital-archaeology.html"><i class="fa fa-check"></i><b>4.4</b> Artificial Intelligence in Digital Archaeology</a><ul>
<li class="chapter" data-level="4.4.1" data-path="artificial-intelligence-in-digital-archaeology.html"><a href="artificial-intelligence-in-digital-archaeology.html#agent-based-modeling-abm"><i class="fa fa-check"></i><b>4.4.1</b> Agent-based modeling (ABM)</a></li>
</ul></li>
<li class="chapter" data-level="4.5" data-path="computer-vision-and-archaeology.html"><a href="computer-vision-and-archaeology.html"><i class="fa fa-check"></i><b>4.5</b> Computer Vision and Archaeology</a><ul>
<li class="chapter" data-level="4.5.1" data-path="computer-vision-and-archaeology.html"><a href="computer-vision-and-archaeology.html#convolutional-neural-networks"><i class="fa fa-check"></i><b>4.5.1</b> Convolutional Neural Networks</a></li>
<li class="chapter" data-level="4.5.2" data-path="computer-vision-and-archaeology.html"><a href="computer-vision-and-archaeology.html#applications"><i class="fa fa-check"></i><b>4.5.2</b> Applications</a></li>
<li class="chapter" data-level="4.5.3" data-path="computer-vision-and-archaeology.html"><a href="computer-vision-and-archaeology.html#exercises-21"><i class="fa fa-check"></i><b>4.5.3</b> Exercises</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="5" data-path="digital-archaeologys-place-in-the-world.html"><a href="digital-archaeologys-place-in-the-world.html"><i class="fa fa-check"></i><b>5</b> Digital Archaeology’s Place in the World</a><ul>
<li class="chapter" data-level="5.1" data-path="marketing-digital-archaeology.html"><a href="marketing-digital-archaeology.html"><i class="fa fa-check"></i><b>5.1</b> Marketing Digital Archaeology</a></li>
<li class="chapter" data-level="5.2" data-path="sustainability-power-in-digital-archaeology.html"><a href="sustainability-power-in-digital-archaeology.html"><i class="fa fa-check"></i><b>5.2</b> Sustainability & Power in Digital Archaeology</a><ul>
<li class="chapter" data-level="5.2.1" data-path="sustainability-power-in-digital-archaeology.html"><a href="sustainability-power-in-digital-archaeology.html#exercises-22"><i class="fa fa-check"></i><b>5.2.1</b> exercises</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="6" data-path="on-the-horizons-where-digital-archaeology-might-go-next.html"><a href="on-the-horizons-where-digital-archaeology-might-go-next.html"><i class="fa fa-check"></i><b>6</b> On the Horizons: Where Digital Archaeology Might Go Next</a></li>
<li class="chapter" data-level="" data-path="references.html"><a href="references.html"><i class="fa fa-check"></i>References</a></li>
<li class="divider"></li>
<li><a href="https://creativecommons.org/licenses/by/4.0/" target="blank">CC-BY 4.0</a></li>
<li><a href="https://github.com/rstudio/bookdown" target="blank">Made with bookdown</a></li>
<li><a href="https://www.ecampusontario.ca/" target="blank">Funded by EcampusOntario</a></li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i><a href="./">The Open Digital Archaeology Textbook</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<section class="normal" id="section-">
<div id="data-driven-documents" class="section level2">
<h2><span class="header-section-number">3.3</span> Data Driven Documents</h2>
<p>Given that a lot of archaeological data is represented in JSON format when we retrieve it from an API or from a database, it is worth your time to consider ways of representing this data natively on the web. By ‘natively’ we mean, as part of the document object model approach that underpins most webdesign. By making the data part of the way the site is generated (and manipulated), we free our data and our visualizations. This opens up the possibility of generating archaeological visualizations (and compelling narratives) on-the-fly as data is updated. It opens up the possibility of remixing the data, or of linking it into other data.</p>
<p>But as Mike Bostock (editor for interactive graphics at the New York Times and creator of <a href="http//:d3js.org">D3</a>) points out, there is a danger of getting lost in the woods of any one particular technology; we always need to keep in mind,</p>
<blockquote>
<p>The purpose of visualization is insight, not pictures.</p>
</blockquote>
<ul>
<li><a href="https://medium.com/@mbostock/a-better-way-to-code-2b1d2876a3a0">Mike Bostock</a></li>
</ul>
<p>In this section, we introduce two approaches to data driven documents: D3.js, and the Processing language.</p>
<div id="d3" class="section level3">
<h3><span class="header-section-number">3.3.1</span> D3</h3>
<p>Let’s make an interactive bar chart of pottery counts using D3.</p>
<div class="figure">
<img src="images/d3barchart.png" alt="A screenshot of the final product" />
<p class="caption">A screenshot of the final product</p>
</div>
<blockquote>
<p>D3.js is a JavaScript library for manipulating documents based on data. D3 helps you bring data to life using HTML, SVG, and CSS. D3’s emphasis on web standards gives you the full capabilities of modern browsers without tying yourself to a proprietary framework, combining powerful visualization components and a data-driven approach to DOM manipulation.</p>
</blockquote>
<p>What this means is that D3 gives us some pre-packaged tools for taking our JSON file and tying elements of that data to different kinds of graphical elements in the html of a webpage, in a way that is relatively straightforward. Take a few moments to explore the <a href="https://github.com/d3/d3/wiki/Gallery">example gallery</a> which demonstrates - with the code - ways of achieving various kinds of visualizations (including dynamic and interactive ones).</p>
<p>To use D3.js, we have to specify three particular parts of the puzzle - the data, the styling, and the html that pulls it altogether. Within the html, we use SVG - ‘scalable vector graphics’ ie mathematical descriptions of the lines, rather than the coloured pixels of raster graphics - to describe how the different elements of the visualization will be built. The <em>size</em> and <em>placement</em> of these elements depends on the aspects of the data.</p>
<p>One way of experimenting with D3 is to use Mike Bostock’s <a href="http://bl.ocks.org">bl.ocks.org</a> service. This site shows off many different kinds of visualizations. To use it for yourself requires us to put our html, css, and json files somewhere where bl.ocks.org can find it - in this case, we will use a Github <a href="http://gist.github.com">gist</a>. A gist is part of the Github website that allows anyone to quickly post a code snippet online, with a url, for sharing. If we are logged in, then the gist ceases to be anonymous - for instance, Shawn’s gists are all at <a href="http://gist.github.com/shawngraham">gist.github.com/shawngraham</a>. To run a gist through bl.ocks.org, we copy the URL path <em>after</em> gist.github.com and paste it <em>after bl.ocks.org</em> - hence Shawn’s gists could be visualized at <code>http://bl.ocks.org/shawngraham/<string-of-random-letters-and-numbers-identifying-the-exact-gist</code>. A gist can have more than one file.</p>
<p>On your own webserver, you would have an <code>index.html</code> file, a <code>style.css</code> file, and a data file, either in csv, tsv, or in json. Let’s build a simple bar chart with an interactive tool tip, that visualizes some pottery counts.</p>
<p>Our pottery counts data is represented by the following .json file:</p>
<div class="sourceCode"><pre class="sourceCode json"><code class="sourceCode json"><span class="ot">[</span>
<span class="fu">{</span><span class="dt">"PotteryType"</span><span class="fu">:</span> <span class="st">"Terra Sig"</span><span class="fu">,</span><span class="dt">"Count"</span><span class="fu">:</span> <span class="dv">58</span><span class="fu">}</span><span class="ot">,</span>
<span class="fu">{</span><span class="dt">"PotteryType"</span><span class="fu">:</span> <span class="st">"African Red Slip"</span><span class="fu">,</span><span class="dt">"Count"</span><span class="fu">:</span> <span class="dv">81</span><span class="fu">}</span><span class="ot">,</span>
<span class="fu">{</span><span class="dt">"PotteryTyp"</span><span class="fu">:</span> <span class="st">"Dressel24"</span><span class="fu">,</span><span class="dt">"Count"</span><span class="fu">:</span> <span class="dv">39</span><span class="fu">}</span><span class="ot">,</span>
<span class="fu">{</span><span class="dt">"PotteryType"</span><span class="fu">:</span> <span class="st">"Vernice Nera"</span><span class="fu">,</span><span class="dt">"Count"</span><span class="fu">:</span> <span class="dv">80</span><span class="fu">}</span><span class="ot">,</span>
<span class="fu">{</span><span class="dt">"PotteryType"</span><span class="fu">:</span> <span class="st">"Bipedalis Fragment"</span><span class="fu">,</span><span class="dt">"Count"</span><span class="fu">:</span> <span class="dv">99</span><span class="fu">}</span>
<span class="ot">]</span></code></pre></div>
<p>The next step is to create the style sheet. The one we’re going to use can be inspected <a href="https://gist.github.com/shawngraham/dc506c6be872625101a1163ad59e4d68#file-barchart-css">here</a>. A stylesheet describes how each element referred to in the html should be rendered. Can you work out which part of the stylesheet is governing the colour for our barchart? Which bit will take care of the axes?</p>
<p>The final step is to create the html that will pull everything together. Because we’re going to use the tools in the D3 package to control how this all works, we have to tell this to the html. The opening of our HTML looks like this - see how we’re telling the brower where our css is, and where to find the D3? The D3 <em>could</em> live in, for instance, a folder on our own server, but here we’re going to use the most up-to-date version available at 3djs.org:</p>
<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"><span class="dt"><!DOCTYPE </span>html<span class="dt">></span>
<span class="kw"><meta</span><span class="ot"> charset=</span><span class="st">"utf-8"</span><span class="kw">></span>
<span class="kw"><head></span>
<span class="kw"><link</span><span class="ot"> rel=</span><span class="st">"stylesheet"</span><span class="ot"> type=</span><span class="st">"text/css"</span><span class="ot"> href=</span><span class="st">"barchart.css"</span><span class="kw">></span>
<span class="kw"></head></span>
<span class="kw"><body></span>
<span class="kw"><script</span><span class="ot"> src=</span><span class="st">"https://d3js.org/d3.v3.min.js"</span><span class="kw">></script></span>
<span class="kw"><script</span><span class="ot"> src=</span><span class="st">"d3.tip.v0.6.3.js"</span><span class="kw">></script></span>
<span class="kw"><script></span></code></pre></div>
<p>Next, we’re going to define a series of variables that will control or describe how we want the data to be displayed, and the kind of <em>interactivity</em> that our chart will have. The second script in the html code above calls a related package, ‘d3.tip’ by Justin Palmer. This is a small bundle that enables mouse-over tool-tips on the elements in our visualization. It’s not loading it from somewhere else on the web, but rather from the same location where the index.html file can be found.</p>
<p>In the definition of the variables below, any that begin with <code>d3</code> are referring to the D3 package which was loaded by the <code><script></code>. For more on the wide variety of things D3 can do, we invite you to check out <a href="https://github.com/d3/d3/wiki/Tutorials">the D3 tutorials</a>.</p>
<div class="sourceCode"><pre class="sourceCode js"><code class="sourceCode javascript"><span class="kw">var</span> margin <span class="op">=</span> <span class="op">{</span><span class="dt">top</span><span class="op">:</span> <span class="dv">40</span><span class="op">,</span> <span class="dt">right</span><span class="op">:</span> <span class="dv">20</span><span class="op">,</span> <span class="dt">bottom</span><span class="op">:</span> <span class="dv">30</span><span class="op">,</span> <span class="dt">left</span><span class="op">:</span> <span class="dv">70</span><span class="op">},</span>
width <span class="op">=</span> <span class="dv">460</span> <span class="op">-</span> <span class="va">margin</span>.<span class="at">left</span> <span class="op">-</span> <span class="va">margin</span>.<span class="at">right</span><span class="op">,</span>
height <span class="op">=</span> <span class="dv">500</span> <span class="op">-</span> <span class="va">margin</span>.<span class="at">top</span> <span class="op">-</span> <span class="va">margin</span>.<span class="at">bottom</span><span class="op">;</span>
<span class="kw">var</span> x <span class="op">=</span> <span class="va">d3</span>.<span class="va">scale</span>.<span class="at">ordinal</span>()
.<span class="at">rangeRoundBands</span>([<span class="dv">0</span><span class="op">,</span> width]<span class="op">,</span> .<span class="dv">1</span>)<span class="op">;</span>
<span class="kw">var</span> y <span class="op">=</span> <span class="va">d3</span>.<span class="va">scale</span>.<span class="at">linear</span>()
.<span class="at">range</span>([height<span class="op">,</span> <span class="dv">0</span>])<span class="op">;</span>
<span class="kw">var</span> xAxis <span class="op">=</span> <span class="va">d3</span>.<span class="va">svg</span>.<span class="at">axis</span>()
.<span class="at">scale</span>(x)
.<span class="at">orient</span>(<span class="st">"bottom"</span>)<span class="op">;</span>
<span class="kw">var</span> yAxis <span class="op">=</span> <span class="va">d3</span>.<span class="va">svg</span>.<span class="at">axis</span>()
.<span class="at">scale</span>(y)
.<span class="at">orient</span>(<span class="st">"left"</span>)
.<span class="at">ticks</span>(<span class="dv">10</span><span class="op">,</span> <span class="st">""</span>)<span class="op">;</span></code></pre></div>
<p>This next variable contains the information telling the browser what to do if the user mouses-over one of the bars in our chart. When that happens, the browser is to turn the bar red and to display the value for that bar (which is held in d.Count - look at the JSON again. Do you see the ‘Count’ data? If you wanted to adapt this chart to show <em>weights</em> of the pottery, what might you have to change?)</p>
<div class="sourceCode"><pre class="sourceCode js"><code class="sourceCode javascript"><span class="kw">var</span> tip <span class="op">=</span> <span class="va">d3</span>.<span class="at">tip</span>()
.<span class="at">attr</span>(<span class="st">'class'</span><span class="op">,</span> <span class="st">'d3-tip'</span>)
.<span class="at">offset</span>([<span class="op">-</span><span class="dv">10</span><span class="op">,</span> <span class="dv">0</span>])
.<span class="at">html</span>(<span class="kw">function</span>(d) <span class="op">{</span>
<span class="cf">return</span> <span class="st">"<strong>Count:</strong> <span style='color:red'>"</span> <span class="op">+</span> <span class="va">d</span>.<span class="at">Count</span> <span class="op">+</span> <span class="st">"</span>"</span><span class="op">;</span>
<span class="op">}</span>)
<span class="kw">var</span> svg <span class="op">=</span> <span class="va">d3</span>.<span class="at">select</span>(<span class="st">"body"</span>).<span class="at">append</span>(<span class="st">"svg"</span>)
.<span class="at">attr</span>(<span class="st">"width"</span><span class="op">,</span> width <span class="op">+</span> <span class="va">margin</span>.<span class="at">left</span> <span class="op">+</span> <span class="va">margin</span>.<span class="at">right</span>)
.<span class="at">attr</span>(<span class="st">"height"</span><span class="op">,</span> height <span class="op">+</span> <span class="va">margin</span>.<span class="at">top</span> <span class="op">+</span> <span class="va">margin</span>.<span class="at">bottom</span>)
.<span class="at">append</span>(<span class="st">"g"</span>)
.<span class="at">attr</span>(<span class="st">"transform"</span><span class="op">,</span> <span class="st">"translate("</span> <span class="op">+</span> <span class="va">margin</span>.<span class="at">left</span> <span class="op">+</span> <span class="st">","</span> <span class="op">+</span> <span class="va">margin</span>.<span class="at">top</span> <span class="op">+</span> <span class="st">")"</span>)<span class="op">;</span>
<span class="va">svg</span>.<span class="at">call</span>(tip)<span class="op">;</span></code></pre></div>
<p>Now we add the actual data:</p>
<div class="sourceCode"><pre class="sourceCode js"><code class="sourceCode javascript"><span class="va">d3</span>.<span class="at">json</span>(<span class="st">"pottery.json"</span><span class="op">,</span> <span class="kw">function</span>(error<span class="op">,</span> data) <span class="op">{</span>
<span class="cf">if</span> (error) <span class="cf">throw</span> error<span class="op">;</span>
<span class="va">x</span>.<span class="at">domain</span>(<span class="va">data</span>.<span class="at">map</span>(<span class="kw">function</span>(d) <span class="op">{</span> <span class="cf">return</span> <span class="va">d</span>.<span class="at">PotteryType</span><span class="op">;</span> <span class="op">}</span>))<span class="op">;</span>
<span class="va">y</span>.<span class="at">domain</span>([<span class="dv">0</span><span class="op">,</span> <span class="va">d3</span>.<span class="at">max</span>(data<span class="op">,</span> <span class="kw">function</span>(d) <span class="op">{</span> <span class="cf">return</span> <span class="va">d</span>.<span class="at">Count</span><span class="op">;</span> <span class="op">}</span>)])<span class="op">;</span></code></pre></div>
<p>We just tell it that the json data is in the <code>pottery.json</code> file. If that json file was on the web somewhere, we could just provide the url (as long as it ends in a json file!). Then we map the data in the json file to our x and y axes - PotteryType and Count. This mapping pushes that data to <code>d.PotteryType</code> and <code>d.Count</code>; anytime we need that data, we can now just refer to those variables.</p>
<p>We finish up by pulling it all together:</p>
<div class="sourceCode"><pre class="sourceCode js"><code class="sourceCode javascript"> <span class="va">svg</span>.<span class="at">append</span>(<span class="st">"g"</span>)
.<span class="at">attr</span>(<span class="st">"class"</span><span class="op">,</span> <span class="st">"x axis"</span>)
.<span class="at">attr</span>(<span class="st">"transform"</span><span class="op">,</span> <span class="st">"translate(0,"</span> <span class="op">+</span> height <span class="op">+</span> <span class="st">")"</span>)
.<span class="at">call</span>(xAxis)<span class="op">;</span>
<span class="va">svg</span>.<span class="at">append</span>(<span class="st">"g"</span>)
.<span class="at">attr</span>(<span class="st">"class"</span><span class="op">,</span> <span class="st">"y axis"</span>)
.<span class="at">call</span>(yAxis)
.<span class="at">append</span>(<span class="st">"text"</span>)
.<span class="at">attr</span>(<span class="st">"transform"</span><span class="op">,</span> <span class="st">"rotate(-90)"</span>)
.<span class="at">attr</span>(<span class="st">"y"</span><span class="op">,</span> <span class="op">-</span><span class="dv">36</span>)
.<span class="at">attr</span>(<span class="st">"dy"</span><span class="op">,</span> <span class="st">".71em"</span>)
.<span class="at">style</span>(<span class="st">"text-anchor"</span><span class="op">,</span> <span class="st">"end"</span>)
.<span class="at">text</span>(<span class="st">"Count"</span>)<span class="op">;</span>
<span class="va">svg</span>.<span class="at">selectAll</span>(<span class="st">".bar"</span>)
.<span class="at">data</span>(data)
.<span class="at">enter</span>().<span class="at">append</span>(<span class="st">"rect"</span>)
.<span class="at">attr</span>(<span class="st">"class"</span><span class="op">,</span> <span class="st">"bar"</span>)
.<span class="at">attr</span>(<span class="st">"x"</span><span class="op">,</span> <span class="kw">function</span>(d) <span class="op">{</span> <span class="cf">return</span> <span class="at">x</span>(<span class="va">d</span>.<span class="at">PotteryType</span>)<span class="op">;</span> <span class="op">}</span>)
.<span class="at">attr</span>(<span class="st">"width"</span><span class="op">,</span> <span class="va">x</span>.<span class="at">rangeBand</span>())
.<span class="at">attr</span>(<span class="st">"y"</span><span class="op">,</span> <span class="kw">function</span>(d) <span class="op">{</span> <span class="cf">return</span> <span class="at">y</span>(<span class="va">d</span>.<span class="at">Count</span>)<span class="op">;</span> <span class="op">}</span>)
.<span class="at">attr</span>(<span class="st">"height"</span><span class="op">,</span> <span class="kw">function</span>(d) <span class="op">{</span> <span class="cf">return</span> height <span class="op">-</span> <span class="at">y</span>(<span class="va">d</span>.<span class="at">Count</span>)<span class="op">;</span> <span class="op">}</span>)
.<span class="at">on</span>(<span class="st">'mouseover'</span><span class="op">,</span> <span class="va">tip</span>.<span class="at">show</span>)
.<span class="at">on</span>(<span class="st">'mouseout'</span><span class="op">,</span> <span class="va">tip</span>.<span class="at">hide</span>)<span class="op">;</span>
})<span class="op">;</span></code></pre></div>
<p>You can see our gist that contains our interactive bar chart at <a href="https://gist.github.com/shawngraham/dc506c6be872625101a1163ad59e4d68" class="uri">https://gist.github.com/shawngraham/dc506c6be872625101a1163ad59e4d68</a> (interestingly, all the files in our gist are listed alphabetically. Scroll down to see all of the files). Let’s make this visualization live - pass the filepath to <a href="https://bl.ocks.org/" class="uri">https://bl.ocks.org/</a> to see the finished result!</p>
<p>(That is, copy the bit <em>after</em> gist.github.com/ and paste it so that it’s now after <a href="https://bl.ocks.org/" class="uri">https://bl.ocks.org/</a> in your browser’s address bar.)</p>
</div>
<div id="discussion-1" class="section level3">
<h3><span class="header-section-number">3.3.2</span> discussion</h3>
<p>What might this particular visualization be telling you about this ‘site’? How might you integrate this visualizations with other kinds of visualizations (check the <a href="https://github.com/d3/d3/wiki/Gallery">example gallery</a> for inspiration) to tell a compelling story?</p>
<p>This walkthrough has only barely skimmed the surface of what D3 can do. But now that you know how the different pieces fit together, you can try fitting your own data into the visualizations that <em>other</em> people have made. This can be frustrating - you really have to know how your data is structured, and you must read closely the index.html files of the visualization you want to repurpose to make sure that the code is calling the data correctly. For instance, in our example above, Graham kept getting an error where the bars themselves would not display. He chased this error down by right-clicking on the barchart and selecting ‘inspect element’. This opens the browser’s inspector tool, and allows us to see what errors are occuring in our html. In Graham’s case, the error message was <code>error invalid value for rect attribute height NaN</code>.</p>
<p>Error messages are often inscrutable. Copying the error into a Google search usually finds <em>other</em> people who have had the same error and who have posted their problem to sites like <a href="http://stackoverflow.com">Stack Overflow</a>, a coding question and answer site. Reading the responses, graham realized that when he repurposed the example from <a href="http://www.knowstack.com/different-ways-of-loading-a-d3js-data/">this walkthrough</a> he made the following mistake. Can you spot it?</p>
<p>Original code:</p>
<div class="sourceCode"><pre class="sourceCode js"><code class="sourceCode javascript"><span class="va">svg</span>.<span class="at">selectAll</span>(<span class="st">".bar"</span>)
.<span class="at">data</span>(data)
.<span class="at">enter</span>().<span class="at">append</span>(<span class="st">"rect"</span>)
.<span class="at">attr</span>(<span class="st">"class"</span><span class="op">,</span> <span class="st">"bar"</span>)
.<span class="at">attr</span>(<span class="st">"x"</span><span class="op">,</span> <span class="kw">function</span>(d) <span class="op">{</span> <span class="cf">return</span> <span class="at">x</span>(<span class="va">d</span>.<span class="at">Employee</span>)<span class="op">;</span> <span class="op">}</span>)
.<span class="at">attr</span>(<span class="st">"width"</span><span class="op">,</span> <span class="va">x</span>.<span class="at">rangeBand</span>())
.<span class="at">attr</span>(<span class="st">"y"</span><span class="op">,</span> <span class="kw">function</span>(d) <span class="op">{</span> <span class="cf">return</span> <span class="at">y</span>(<span class="va">d</span>.<span class="at">Salary</span>)<span class="op">;</span> <span class="op">}</span>)
.<span class="at">attr</span>(<span class="st">"height"</span><span class="op">,</span> <span class="kw">function</span>(d) <span class="op">{</span> <span class="cf">return</span> height <span class="op">-</span> <span class="at">y</span>(<span class="va">d</span>.<span class="at">Salary</span>)<span class="op">;</span> <span class="op">}</span>)
.<span class="at">on</span>(<span class="st">'mouseover'</span><span class="op">,</span> <span class="va">tip</span>.<span class="at">show</span>)
.<span class="at">on</span>(<span class="st">'mouseout'</span><span class="op">,</span> <span class="va">tip</span>.<span class="at">hide</span>)<span class="op">;</span></code></pre></div>
<p>Graham’s mistake:</p>
<div class="sourceCode"><pre class="sourceCode js"><code class="sourceCode javascript"> <span class="va">svg</span>.<span class="at">selectAll</span>(<span class="st">".bar"</span>)
.<span class="at">data</span>(data)
.<span class="at">enter</span>().<span class="at">append</span>(<span class="st">"rect"</span>)
.<span class="at">attr</span>(<span class="st">"class"</span><span class="op">,</span> <span class="st">"bar"</span>)
.<span class="at">attr</span>(<span class="st">"x"</span><span class="op">,</span> <span class="kw">function</span>(d) <span class="op">{</span> <span class="cf">return</span> <span class="at">x</span>(<span class="va">d</span>.<span class="at">PotteryType</span>)<span class="op">;</span> <span class="op">}</span>)
.<span class="at">attr</span>(<span class="st">"width"</span><span class="op">,</span> <span class="va">x</span>.<span class="at">rangeBand</span>())
.<span class="at">attr</span>(<span class="st">"y"</span><span class="op">,</span> <span class="kw">function</span>(d) <span class="op">{</span> <span class="cf">return</span> <span class="at">y</span>(<span class="va">d</span>.<span class="at">PotteryType</span>)<span class="op">;</span> <span class="op">}</span>)
.<span class="at">attr</span>(<span class="st">"height"</span><span class="op">,</span> <span class="kw">function</span>(d) <span class="op">{</span> <span class="cf">return</span> height <span class="op">-</span> <span class="at">y</span>(<span class="va">d</span>.<span class="at">Count</span>)<span class="op">;</span> <span class="op">}</span>)
.<span class="at">on</span>(<span class="st">'mouseover'</span><span class="op">,</span> <span class="va">tip</span>.<span class="at">show</span>)
.<span class="at">on</span>(<span class="st">'mouseout'</span><span class="op">,</span> <span class="va">tip</span>.<span class="at">hide</span>)<span class="op">;</span></code></pre></div>
<p>It was very frustrating! It wasn’t until he took a break and looked at the code again with fresh eyes that he spotted it. Have you?</p>
</div>
<div id="exercises-12" class="section level3">
<h3><span class="header-section-number">3.3.3</span> exercises</h3>
<ol style="list-style-type: decimal">
<li><p>Ben Christensen has a very simple line graph using D3 at <a href="http://bl.ocks.org/2579599" class="uri">http://bl.ocks.org/2579599</a>, and the source code at <a href="https://gist.github.com/2579599" class="uri">https://gist.github.com/2579599</a>. Login to Github, and then take a fork (a copy) of his source code. Study the code and make a list, of <em>every</em> line you would have to modify in order to turn this graph <em>with its current data</em> into an illustration of archaeological data.</p></li>
<li><p>Now try to do it. Click the ‘edit’ button on your gist, and make your changes. To save your changes, you need to hit the green ‘commit’ button at the bottom of the page. Display your changes using bl.ocks.org. <strong>Nb</strong> Your changes can take a few minutes to show up - it takes time for things to propagate across the web. View your bl.ocks.org in <em>incognito mode</em> so that you’re not viewing the cached (old) version of your graph. If your changes show - great! If they don’t - use the inspector. What are your errors telling you?</p></li>
<li><p>Try representing your data in a .json file. Use the examples at the top of this page to guide you. Search for the error messages you will get, and keep track of what you’ve done, and where you’ve sought help. This will be more difficult, and frustrating, but you will discover that you are learning throughout.</p></li>
<li><p>The <a href="https://datavizcatalogue.com/">Data Visualization Catalogue</a> has a wide variety of examples of different kinds of charts along with suggestions for their most appropriate use-cases. Code examples are provided for all of them, and many use D3. Select an example that might be useful for archaeology, and explore its code. Can you make it work? Where do you run into roadblocks: what kinds of questions would you use to remove the roadblock? The point here is to map out <em>what you don’t know</em> so that you can begin to ask the <em>right</em> questions.</p></li>
</ol>
</div>
</div>
</section>
</div>
</div>
</div>
<a href="statistical-computing-with-r-and-python-notebooks-reproducible-code.html" class="navigation navigation-prev " aria-label="Previous page"><i class="fa fa-angle-left"></i></a>
<a href="storytelling-and-the-archaeological-cms-omeka-kora-and-mukurtu.html" class="navigation navigation-next " aria-label="Next page"><i class="fa fa-angle-right"></i></a>
</div>
</div>
<script src="libs/gitbook-2.6.7/js/app.min.js"></script>
<script src="libs/gitbook-2.6.7/js/lunr.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-search.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-sharing.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-fontsettings.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-bookdown.js"></script>
<script src="libs/gitbook-2.6.7/js/jquery.highlight.js"></script>
<script>
gitbook.require(["gitbook"], function(gitbook) {
gitbook.start({
"sharing": {
"github": false,
"facebook": true,
"twitter": true,
"google": false,
"linkedin": false,
"weibo": false,
"instapper": false,
"vk": false,
"all": ["facebook", "google", "twitter", "linkedin", "weibo", "instapaper"]
},
"fontsettings": {
"theme": "white",
"family": "sans",
"size": 2
},
"edit": {
"link": "https://github.com/o-date/draft/edit/gh-pages/03.2-d3-documents.rmd",
"text": "Edit"
},
"download": ["odate.pdf"],
"toc": {
"collapse": "section",
"number_sections": null
}
});
});
</script>
</body>
</html>