-
Notifications
You must be signed in to change notification settings - Fork 42
/
d3-02.html
596 lines (521 loc) · 25.3 KB
/
d3-02.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
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>d3 Tutorial</title>
<meta name="description" content="A framework for easily creating beautiful presentations using HTML">
<meta name="author" content="Hakim El Hattab">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="reveal.js/css/reveal.css">
<link rel="stylesheet" href="reveal.js/css/theme/black.css" id="theme">
<link rel="stylesheet" href="style.css">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="highlight.js/src/styles/obsidian.css" id="highlight-theme">
<!-- If the query includes 'print-pdf', use the PDF print sheet -->
<script>
document.write('<link rel="stylesheet" href="reveal.js/css/print/' + (window.location.search.match(/print-pdf/gi) ? 'pdf' : 'paper') + '.css" type="text/css" media="print">');
</script>
<script src="js/jquery.js"></script>
<script src="js/d3.js"></script>
<script src="js/chart.js"></script>
<script>
(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-55386037-1', 'auto');
ga('send', 'pageview');
</script>
<!--[if lt IE 9]>
<script src="reveal.js/lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<div class="slides">
<section class="center">
<h1>
<small>D3.js Tutorial</small>
</h1>
<h4>Second Part</h4>
<br/>
<p>
<small>
A tutorial by <a href="http://homes.cs.washington.edu/~domoritz/">Dominik Moritz</a> (<a href="http://twitter.com/domoritz">@domoritz</a>) and <a href="http://kanitw.yellowpigz.com/">Kanit "Ham" Wongsuphasawat</a> (<a href="http://twitter.com/kanitw">@kanitw</a>)
</small>
</p>
<p>
<small>
<a href="http://idl.cs.washington.edu">Interactive Data Lab</a>,
<a href="http://uw.edu">University of Washington</a>
</small>
</p>
<p><small><small>(Based on <a href="http://vadim.ogievetsky.com/IntroD3">Vadim Ogievetsky</a> and <a href="http://alignedleft.com/tutorials/d3/">Scott Murray</a>'s work)</small></small></p>
</section>
<section data-markdown>
## Outline
* Interactions
* Scales & Axes
* Tips e.g. Importing Data
* Path Generators & Line Interpolators
* Layouts & Maps
* Let's Build a Chart & More Examples
</section>
<section>
<section>
<h2>Interactions</h2>
</section>
<section>
<h3>Event Listeners</h3>
<p>
<code>.on('mouseover',...), .on('click',...)</code>
</p>
<div class="left">
<p data-height="500" data-theme-id="0" data-slug-hash="yziKj" data-user="kanitw" data-default-tab="js" class='codepen'>
</p>
</div>
<div class="right">
<p data-height="400" data-theme-id="0" data-slug-hash="yziKj" data-user="kanitw" data-default-tab="result" class='codepen'>
</p>
</div>
<p><small>Note 1: <code>:hover</code> pseudo-selector also works with svg!</small></p>
<p><small>Note 2: To remove a <i>listener</i>, pass null as the <i>listener</i>. To remove all listeners for a particular event type, pass null as the <i>listener</i>, and .type as the type, e.g. <code>selection.on(".foo", null)</code>.</small></p>
</section>
<section>
<h3>SVG Tooltips</h3>
<p><a href="http://localhost:8000/fundamental.html#/5/6">Last week</a>, we did it in svg.</p>
<div class="left">
<p data-height="400" data-theme-id="0" data-slug-hash="Dbuhd" data-user="kanitw" data-default-tab="html" class='codepen'>
</p>
</div>
<div class="right">
<p data-height="400" data-theme-id="0" data-slug-hash="Dbuhd" data-user="kanitw" data-default-tab="result" class='codepen'>
</p>
</div>
</section>
<section>
<h3>SVG Tooltips</h3>
<div class="left">
<p data-height="400" data-theme-id="0" data-slug-hash="mkgqD" data-user="kanitw" data-default-tab="js" class='codepen'>
</p>
</div>
<div class="right">
<p data-height="400" data-theme-id="0" data-slug-hash="mkgqD" data-user="kanitw" data-default-tab="result" class='codepen'>
</p>
</div>
</section>
<section>
<h3>HTML Tooltips</h3>
<iframe src="http://examples.oreilly.com/0636920026938/chapter_10/14_div_tooltip.html" class="white" width="100%" height="400"></iframe>
<p class="see-also">
<small>See "<a href="http://chimera.labs.oreilly.com/books/1230000000345/ch10.html#_html_div_tooltips">Div Tooltip HTML</a>" in Murray</small>
</p>
</section>
<section>
<h3>Brushing - <code>d3.svg.brush()</code></h3>
<iframe src="http://bl.ocks.org/mbostock/raw/4063663/" class="white" frameborder="0" width="100%" height="450"></iframe>
<p><small>From http://bl.ocks.org/mbostock/4063663. See also <a href="http://bl.ocks.org/mbostock/1667367">Focus+Context</a></small></p>
</section>
</section>
<section>
<section class="center">
<h2>Scale</h2>
<h4>Domain ↦ Range</h4>
<br>
<div class="left-align">
<small>So you don't have to write:</small>
<pre><code class="js" data-trim>
function x(d) {
return d * 42 + "px";
}
</code></pre>
</div>
<p class="see-also">
<small><a href="http://www.jeromecukier.net/blog/2011/08/11/d3-scales-and-color/">http://www.jeromecukier.net/blog/2011/08/11/d3-scales-and-color/</a></small>
</p>
</section>
<section class="center">
<h3><code>.linear()</code></h3>
<p>
<img src="img/d3scale1.png" height="200" width="587" alt="">
</p>
<pre><code class="javascript" data-trim>
var x = d3.scale.linear().domain([0, 10]).range([0,100]);
console.log(x(-1),x(0), x(4.4), x(10), x(11)); //-10 0 44 100 110 with some rounding errors
console.log(x.clamp()(-1), x.clamp()(11); // 0 100
</code></pre>
<footer class="source"><small><small>Source: http://www.jeromecukier.net/blog/2011/08/11/d3-scales-and-color/</small></small></footer>
</section>
<section >
<h3>Scale methods</h3>
<ul>
<li><code>.nice()</code> round domain to nicer numbers e.g. from <code>[0.2014, 0.9966]</code> to <code>[0.2, 1]</code>
<pre><code class="javascript" data-trim>
d3.scale.linear().domain([0.2014,0.9966]).nice().domain() // [0.1,1]
</code></pre>
</li>
<li><code>.rangeRound()</code> output range in integers – better for positioning marks on the screen
<pre><code class="javascript" data-trim>
d3.scale.linear().domain([0, 10]).range([0,100])(0.1234)// 1.234
d3.scale.linear().domain([0, 10]).rangeRound([0,100])(0.1234)// 1
</code></pre></li>
<li><code>.invert()</code>
<pre><code class="javascript" data-trim>
d3.scale.linear().domain([0, 10]).range([0,100]).invert(50); //5
</code></pre>
</li>
<li><code>.ticks()</code> return uniformly spaced ticks for your axes. (See <a href="https://github.com/mbostock/d3/wiki/SVG-Axes">Axes</a> for examples)</li>
<li><code>.clamp()</code> limit output to range if an input outside the domain is provided</li>
</ul>
</section>
<section>
<h3>Scales supports various interpolations!</h3>
<p>Color</p>
<pre><code class="javascript" data-trim>
var x = d3.scale.linear()
.domain([12, 24])
.range(["steelblue", "brown"]);
x(16); // #666586
x.interpolate(d3.interpolateHsl)(16); //#3cb05f
</code></pre>
<p>Size</p>
<pre><code class="javascript" data-trim>
var x = d3.scale.linear()
.domain([12, 24])
.range(["0px", "720px"]);
x(16); // 240px
</code></pre>
</section>
<section>
<h3>Other Scales</h3>
<code>d3.scale.log(), d3.scale.pow(), d3.scale.quantile()</code>
</section>
<section>
<h3>Ordinal Scales</h3>
<p><code>d3.scale.ordinal()</code></p>
<p>
<small><code>ordinal.rangePoints(interval[, padding])</code> – e.g. Plots</small>
</p>
<img src="img/range-point.png" height="112" width="476"/>
<p>
<small><code>ordinal.rangeBands(interval[, padding[, outerPadding]])</code> - e.g. Bar Chart</small>
</p>
<img src="img/range-bands.png" height="172" width="540"/>
</section>
<section>
<h3>Categorical Color Scale</h3>
<p>
<code>.category10()</code>
</p>
<p>
<small><font color="#1f77b4">#1f77b4</font>
<font color="#ff7f0e">#ff7f0e</font>
<font color="#2ca02c">#2ca02c</font>
<font color="#d62728">#d62728</font>
<font color="#9467bd">#9467bd</font>
<font color="#8c564b">#8c564b</font>
<font color="#e377c2">#e377c2</font>
<font color="#7f7f7f">#7f7f7f</font>
<font color="#bcbd22">#bcbd22</font>
<font color="#17becf">#17becf</font></small>
</p>
<div class="left">
<p data-height="400" data-theme-id="0" data-slug-hash="zpKuv" data-user="kanitw" data-default-tab="js" class='codepen'>
</p>
</div>
<div class="right">
<p data-height="400" data-theme-id="0" data-slug-hash="zpKuv" data-user="kanitw" data-default-tab="result" class='codepen'>
</p>
</div>
</section>
</section>
<section>
<section>
<h3><a href="https://github.com/mbostock/d3/wiki/SVG-Axes">SVG Axes</a></h3>
<pre><code class="javascript" data-trim>
//Create an axis for a given scale, and configure as desired.
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom"); // returns a function!
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis); //rendering axis with call</code></pre>
<p>Need customization!</p>
<pre><code class="javascript" data-trim>
.axis path, .axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
</code></pre>
<p>See <a href="http://bl.ocks.org/mbostock/3885304">Bar Chart</a> example</p>
</section>
<section data-markdown>
## [More SVG Axes](https://github.com/mbostock/d3/wiki/SVG-Axes)
[![6186172](http://bl.ocks.org/mbostock/raw/6186172/thumbnail.png)](http://bl.ocks.org/mbostock/6186172)
[![5537697](http://bl.ocks.org/mbostock/raw/5537697/thumbnail.png)](http://bl.ocks.org/mbostock/5537697)
[![4573883](http://bl.ocks.org/mbostock/raw/4573883/thumbnail.png)](http://bl.ocks.org/mbostock/4573883)
[![4403522](http://bl.ocks.org/mbostock/raw/4403522/thumbnail.png)](http://bl.ocks.org/mbostock/4403522)
[![4349486](http://bl.ocks.org/mbostock/raw/4349486/thumbnail.png)](http://bl.ocks.org/mbostock/4349486)
[![3892919](http://bl.ocks.org/mbostock/raw/3892919/thumbnail.png)](http://bl.ocks.org/mbostock/3892919)
</section>
<section data-markdown>
## [More SVG Axes](https://github.com/mbostock/d3/wiki/SVG-Axes)
[![3371592](http://bl.ocks.org/mbostock/raw/3371592/thumbnail.png)](http://bl.ocks.org/mbostock/3371592)
[![3259783](http://bl.ocks.org/mbostock/raw/3259783/thumbnail.png)](http://bl.ocks.org/mbostock/3259783)
[![3212294](http://bl.ocks.org/mbostock/raw/3212294/thumbnail.png)](http://bl.ocks.org/mbostock/3212294)
[![2983699](http://bl.ocks.org/mbostock/raw/2983699/thumbnail.png)](http://bl.ocks.org/mbostock/2983699)
[![2996766](http://bl.ocks.org/mbostock/raw/2996766/thumbnail.png)](http://bl.ocks.org/mbostock/2996766)
[![2996785](http://bl.ocks.org/mbostock/raw/2996785/thumbnail.png)](http://bl.ocks.org/mbostock/2996785)
[![1849162](http://bl.ocks.org/mbostock/raw/1849162/thumbnail.png)](http://bl.ocks.org/mbostock/1849162)
[![4323929](http://bl.ocks.org/mbostock/raw/4323929/thumbnail.png)](http://bl.ocks.org/mbostock/4323929)
</section>
</section>
<section>
<section>
<h2>Path Generators & Line Interpolators</h2>
Charts from <a href="http://bost.ocks.org/mike/d3/workshop/#124">http://bost.ocks.org/mike/d3/workshop/#124</a>
</section>
<section>
<h3><code>d3.svg.line(), d3.svg.area()</code></h3>
<p>D3 provides <a href="https://github.com/mbostock/d3/wiki/SVG-Shapes">helpers to generate SVG lines and areas</a>.</p>
<div class="leftright">
<div class="left">
<p data-height="500" data-theme-id="0" data-slug-hash="qdWKyx" data-user="domoritz" data-default-tab="js" class='codepen'>
</p>
</div>
<div class="right">
<p data-height="400" data-theme-id="0" data-slug-hash="qdWKyx" data-user="domoritz" data-default-tab="result" class='codepen'>
</p>
</div>
</div>
</section>
<section id="interpolate-linear-chart">
<h3>Linear Interpolation</h3>
<script>d3.select("#interpolate-linear-chart").call(interpolateChart())</script>
</section>
<section id="interpolate-step-chart">
<h3>Step Interpolation</h3>
<small>Step-before and step-after interpolation are handy for bar charts, and for visualizing step functions (values that change instantaneously rather than gradually).</small>
<script>d3.select("#interpolate-step-chart").call(interpolateChart().interpolate("step-after"))</script>
<aside></aside>
</section>
<section id="interpolate-basis-chart">
<h3>Basis Interpolation</h3>
<small>Note that with basis interpolation, the line doesn’t always go through the control point. D3 also provides cardinal and cubic monotone interpolation; the latter is generally preferred to avoid misleading.</small>
<script>d3.select("#interpolate-basis-chart").call(interpolateChart().interpolate("basis"))</script>
</section>
</section>
<section>
<section>
<h2>Layouts & Maps</h2>
</section>
<section>
<h3>Pie</h3>
<p><small>Many layouts are just data generators/modifier.</small></p>
<div class="left">
<p data-height="500" data-theme-id="0" data-slug-hash="xGKzbg" data-user="domoritz" data-default-tab="js" class='codepen'>
</p>
</div>
<div class="right">
<p data-height="400" data-theme-id="0" data-slug-hash="xGKzbg" data-user="domoritz" data-default-tab="result" class='codepen'>
</p>
</div>
<p><small>Source: <a href="http://chimera.labs.oreilly.com/books/1230000000345/ch11.html">Chapter 11</a> in Interactive Data Visualization for the Web by Murray</small></p>
</section>
<section>
<h3><a href="http://bl.ocks.org/mbostock/4062045">Force Directed</a></h3>
<iframe class="white" src="http://bl.ocks.org/kanitw/8593822" frameborder="0" width="100%" height="500"></iframe>
</section>
<section>
<h3><a href="http://mbostock.github.io/d3/talk/20111018/pack.html">Pack</a></h3>
<img src="img/pack.png" height="480" width="588" alt="">
</section>
<section>
<h3><a href="http://mbostock.github.io/d3/talk/20111018/tree.html">Tree</a></h3>
<img src="img/tree.png" height="480" width="492" alt="">
</section>
<section>
<h3><a href="http://mbostock.github.io/d3/talk/20111018/treemap.html">Treemap</a></h3>
<img src="img/treemap.png" height="480" width="510" alt="">
</section>
<section>
<h3><a href="http://mbostock.github.io/d3/talk/20111018/partition.html">Partition</a></h3>
<img src="img/partition.png" height="343" width="640" alt="">
</section>
<section>
<h3><a href="http://mbostock.github.io/d3/talk/20111116/bundle.html">Bundle</a></h3>
<img src="img/bundle.png" height="480" width="628" alt="">
</section>
<section>
<h3><a href="http://mbostock.github.io/d3/talk/20111116/airports.html">Voronoi</a></h3>
<img src="img/voronoi.png" height="384" width="640" alt="">
</section>
<!-- <section>
<h3>More Layouts</h3>
<ul>
<li>
<a class="internal present" href="/mbostock/d3/wiki/Bundle-Layout">Bundle</a> - apply Holten's <em>hierarchical bundling algorithm</em> to edges.</li>
<li>
<a class="internal present" href="/mbostock/d3/wiki/Chord-Layout">Chord</a> - produce a chord diagram from a matrix of relationships.</li>
<li>
<a class="internal present" href="/mbostock/d3/wiki/Cluster-Layout">Cluster</a> - cluster entities into a dendrogram.</li>
<li>
<a class="internal present" href="/mbostock/d3/wiki/Force-Layout">Force</a> - position linked nodes using physical simulation.</li>
<li>
<a class="internal present" href="/mbostock/d3/wiki/Hierarchy-Layout">Hierarchy</a> - derive a custom hierarchical layout implementation.</li>
<li>
<a class="internal present" href="/mbostock/d3/wiki/Histogram-Layout">Histogram</a> - compute the distribution of data using quantized bins.</li>
<li>
<a class="internal present" href="/mbostock/d3/wiki/Pack-Layout">Pack</a> - produce a hierarchical layout using recursive circle-packing.</li>
<li>
<a class="internal present" href="/mbostock/d3/wiki/Partition-Layout">Partition</a> - recursively partition a node tree into a sunburst or icicle.</li>
<li>
<a class="internal present" href="/mbostock/d3/wiki/Pie-Layout">Pie</a> - compute the start and end angles for arcs in a pie or donut chart.</li>
<li>
<a class="internal present" href="/mbostock/d3/wiki/Stack-Layout">Stack</a> - compute the baseline for each series in a stacked bar or area chart.</li>
<li>
<a class="internal present" href="/mbostock/d3/wiki/Tree-Layout">Tree</a> - position a tree of nodes tidily.</li>
<li>
<a class="internal present" href="/mbostock/d3/wiki/Treemap-Layout">Treemap</a> - use recursive spatial subdivision to display a tree of nodes.</li>
</ul>
</section> -->
<section>
<h2>Maps</h2>
<a href="http://bost.ocks.org/mike/map/">http://bost.ocks.org/mike/map/</a>
</section>
</section>
<section>
<h3>Load data: <code>d3.csv(), d3.tsv(), d3.json()</code></h3>
<p>Implemented Using <a href="http://www.w3.org/TR/XMLHttpRequest/">XMLHttpRequest</a></p>
<pre><code data-trim>
var format = d3.time.format("%b %Y");
d3.csv("stocks.csv", function(d) {
return {
price: +d.price, // convert price to number
date : format.parse(d.date)
};
}, function(error, rows) {
console.log(rows);
});
</code></pre>
<p><small>Note: A web server is required when loading external data. For example with <code>python -m SimpleHTTPServer</code></small></p>
<footer class="source"><small><small>Source: http://bost.ocks.org/mike/d3/workshop/#61</small></small></footer>
</section>
<section>
<section>
<h2>Useful Tips</h2>
</section>
<section data-markdown>
### Useful Helpers
* `max()`, `min()`, `range()`, `extent()`, `mean()`, `median()`
* `keys()`, `values()`
* [Arrays](https://github.com/mbostock/d3/wiki/Arrays) – Learn to use Javascript built-in + D3's [Arrays Helpers](https://github.com/mbostock/d3/wiki/Arrays)!
* [SVG Helpers](https://github.com/mbostock/d3/wiki/SVG) e.g. `d3.svg.area()`
* Use `window.onresize` event to resize your chart when the window is resized
</section>
<section>
<h3>Reusable d3.</h3>
<p>Repeatable, Modifiable, Configurable, Extensible</p>
<ul>
<li>
Mike Bostock's <a href="http://bost.ocks.org/mike/chart/">Towards Reusable Charts</a>
</li>
<li>
Mike Pennisi <a href="http://weblog.bocoup.com/reusability-with-d3/">Exploring Reusability with D3.js
</a>
</li>
</ul>
</section>
<section>
<section>
<h3>Need in memory database?</h3>
<a href="https://github.com/StanfordHCI/datavore">Datavore</a>
<a href="http://square.github.io/crossfilter/">Crossfilter</a>
</section>
</section>
</section>
<section>
<section>
<h2>Let's Build a Chart!</h2>
</section>
<section>
<h2>Use transforms to define a new origin.</h2>
<p>It's always a good idea to sketch the transforms before you start.</p>
<svg width="1200" height="500" style="zoom: 0.7"><g transform="translate(80,80); scale(0.1)"><defs><marker id="triangle-start" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="-8" markerHeight="8" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="fill: rgb(255, 255, 255);"></path></marker><marker id="triangle-end" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="8" markerHeight="8" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="fill: rgb(255, 255, 255);"></path></marker></defs><rect width="1120" height="480" style="fill: none; stroke: rgb(255, 255, 255); stroke-width: 2px;"></rect><g transform="translate(80,80)"><rect width="960" height="320" style="stroke-dasharray: 8px, 12px; fill: none; stroke: rgb(255, 255, 255); stroke-width: 2px;"></rect><text y="-12" style="fill: rgb(255, 255, 255);">translate(left,top)</text></g><line x2="80" y2="80" marker-end="url(#triangle-end)" style="fill: none; stroke: rgb(255, 255, 255); stroke-width: 2px;"></line><line x1="560" x2="560" y2="80" marker-end="url(#triangle-end)" style="fill: none; stroke: rgb(255, 255, 255); stroke-width: 2px;"></line><line x1="560" x2="560" y1="400" y2="480" marker-start="url(#triangle-start)" style="fill: none; stroke: rgb(255, 255, 255); stroke-width: 2px;"></line><line x1="0" x2="80" y1="280" y2="280" marker-end="url(#triangle-end)" style="fill: none; stroke: rgb(255, 255, 255); stroke-width: 2px;"></line><line x1="1120" x2="1040" y1="280" y2="280" marker-end="url(#triangle-end)" style="fill: none; stroke: rgb(255, 255, 255); stroke-width: 2px;"></line><text y="-12" style="fill: rgb(255, 255, 255);">origin</text><circle r="6" style="fill: rgb(255, 255, 255);"></circle></g></svg>
<small class="">From <a href="http://bost.ocks.org/mike/d3/workshop/#107">http://bost.ocks.org/mike/d3/workshop/#107</a></small>
</section>
<section>
<a href="build_a_chart">Go to the example</a>
</section>
<section data-markdown>
### More Examples
* https://github.com/mbostock/d3/wiki/Gallery
* http://mbostock.github.io/d3/talk/20111018/
* http://bost.ocks.org/mike/map/
* http://christopheviau.com/d3list/gallery.html
</section>
</section>
</div>
</div>
<script src="reveal.js/lib/js/head.min.js"></script>
<script src="reveal.js/js/reveal.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
slideNumber: true,
transitionSpeed: 'fast',
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'slide', // default/cube/page/concave/zoom/linear/fade/none
// Parallax scrolling
// parallaxBackgroundImage: 'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg',
// parallaxBackgroundSize: '2100px 900px',
// Optional libraries used to extend on reveal.js
dependencies: [{
src: 'reveal.js/lib/js/classList.js',
condition: function() {
return !document.body.classList;
}
}, {
src: 'reveal.js/plugin/markdown/marked.js',
condition: function() {
return !!document.querySelector('[data-markdown]');
}
}, {
src: 'reveal.js/plugin/markdown/markdown.js',
condition: function() {
return !!document.querySelector('[data-markdown]');
}
}, {
src: 'reveal.js/plugin/highlight/highlight.js',
async: true,
callback: function() {
hljs.initHighlightingOnLoad();
}
}, {
src: 'reveal.js/plugin/zoom-js/zoom.js',
async: true,
condition: function() {
return !!document.body.classList;
}
}, {
src: 'reveal.js/plugin/notes/notes.js',
async: true,
condition: function() {
return !!document.body.classList;
}
}]
});
</script>
<script async src="//codepen.io/assets/embed/ei.js"></script>
<!-- <script src="http://static.jsbin.com/js/embed.js"></script> -->
</body>
</html>