forked from hakimel/reveal.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
564 lines (492 loc) · 16.6 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
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
<html lang="en">
<head>
<meta charset="utf-8">
<title>Highcharts How-To - ONA14</title>
<meta name="description" content="">
<meta name="author" content="Adam Nekola">
<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="css/reveal.min.css">
<link rel="stylesheet" href="css/theme/default.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
<style>
iframe.zoom {
-ms-zoom: 0.75;
-moz-transform: scale(0.75);
-moz-transform-origin: 0 0;
-o-transform: scale(0.75);
-o-transform-origin: 0 0;
-webkit-transform: scale(0.75);
-webkit-transform-origin: 0 0;
}
</style>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section class="charts">
<iframe src="dashboard.php" height="770" width="100%" scrolling="no" frameborder="0" style="background:white; padding:0 15px; border-radius:5px;"></iframe>
<p>Take the poll: <a href="http://bit.ly/1oPB884">http://bit.ly/1oPB884</a></p>
</section>
<section>
<h1>Highcharts How-To</h1>
<h3>Visualizing data with interactivity</h3>
<p>
<small>Presented by Adam Nekola • <a href="http://twitter.com/nekolaweb">@nekolaweb</a></small>
</p>
<p>
<small>Developer • Pew Research Center • <a href="http://ona14.journalists.org/speaker/adam-nekola/">Bio</a></small>
</p>
</section>
<section>
<h2>What is Highcharts?</h2>
<ul>
<li>Noun: A Javascript library for data visualization</li>
<li>Takes arguments for customization to draw an SVG element</li>
<li>Anyone can use it once they understand how to change settings</li>
</ul>
</section>
<section>
<h2>Why Highcharts?</h2>
<ul>
<li>More customizable than Google Charts</li>
<li>Less complicated than D3.js or Raphael</li>
<li>More reliable than other plug and play tools
<ul>
<li>You can download the Javascript file and never worry about the service turning off.</li>
</ul>
</li>
<li>Heavily tested and IE6+ compatible</li>
<li>Don't take my word for it:
<ul>
<li>Fast Company: <a href="http://www.fastcolabs.com/3030447/how-highcharts-won-the-enterprise-data-viz-market">How Highcharts Won the Enterprise Data Viz Market</a></li>
</ul>
</li>
</ul>
</section>
<section>
<h2>Disclaimer</h2>
<p>Highcharts is free for non-commercial use,</p>
<p>but <a href="http://shop.highsoft.com/highcharts.html">requires a licence otherwise</a>.</p>
<p>Cost is $90 per website</p>
<br/>
<p><i>* I have no vested interest in Highcharts; I just think it's easier to learn and implement than D3</i></p>
</section>
<section class="charts">
<iframe src="dashboard.php" height="770" width="100%" scrolling="no" frameborder="0" style="background:white; padding:0 15px; border-radius:5px;"></iframe>
</section>
<section>
<h2>Example:</h2>
<p>Toggle buttons, multiple series types</p>
<iframe src="http://www.pewhispanic.org/2013/09/23/unauthorized-trends/iframe/" height="892" width="100%" scrolling="no" frameborder="0" style="background:white; padding:15px; border-radius:5px;"></iframe>
</section>
<section>
<h2>Example:</h2>
<p>Toggle buttons, multiple series types</p>
<iframe src="http://www.pewglobal.org/2014/02/13/developing-technology-use//iframe/" height="690" width="100%" scrolling="no" frameborder="0" style="background:white; padding:15px; border-radius:5px;"></iframe>
</section>
<section>
<h2>Example: Animations</h2>
<iframe src="http://www.people-press.org/2014/06/12/section-1-growing-ideological-consistency/iframe/" height="810" width="600" scrolling="no" frameborder="0" style="background:white; padding:15px; border-radius:5px;"></iframe>
<aside class="notes">
Oh hey, these are some notes. They'll be hidden in your presentation, but you can see them if you open the speaker notes window (hit 's' on your keyboard).
</aside>
</section>
<section>
<h2>How an API works</h2>
<p>API: Application programming interface</p>
<div class="fragment">
<p>Array of values passed to a function</p>
<pre><code data-trim >
var args = {
'key': 'value',
'name': 'Adam'
};
doSomething(args);
</code></pre>
</div>
<div class="fragment">
<p>The function knows what to do</p>
<pre><code data-trim >
function doSomething( args ) {
var defaults = {
'key': 'default',
'name': false,
'age': false
};
$.extend( true, defaults, args );
if ( defaults['name'] ) print defaults['name'];
if ( defaults['age'] ) print defaults['age'];
}
</code></pre>
</div>
</section>
<section>
<h2>Highcharts API</h2>
<p>Set up a target element</p>
<pre><code data-trim >
<div id="container"></div>
</code></pre>
<div class="fragment">
<p>Uses jQuery to call function</p>
<pre><code data-trim >
var args = {
title: {
text: 'This is my chart'
}
};
$('#container').highcharts(args);
</code></pre>
</div>
</section>
<section>
<section>
<h2>Highcharts Resources</h2>
<ul>
<li><a target="_blank" href="http://www.highcharts.com/demo">Demos / Examples</a></li>
<li><a target="_blank" href="http://www.highcharts.com/docs">Documentation / How-to</a></li>
<li><a target="_blank" href="http://api.highcharts.com/highcharts">API Reference</a></li>
<li><a target="_blank" href="http://jsfiddle.net/">jsfiddle.net</a></li>
<li><a target="_blank" href="http://stackoverflow.com/questions/tagged/highcharts">Stack Overflow: Highcharts</a></li>
</ul>
</section>
<section>
<iframe class="zoom" src="http://www.highcharts.com/demo" height="1010" width="130%" frameborder="0" style="background:white; padding:15px; border-radius:5px; max-width: 130%; max-height: 120%;"></iframe>
</section>
<section>
<iframe class="zoom" src="http://www.highcharts.com/docs" height="1010" width="130%" frameborder="0" style="background:white; padding:15px; border-radius:5px; max-width: 130%; max-height: 120%;"></iframe>
</section>
<section>
<iframe class="zoom" src="http://api.highcharts.com/highcharts" height="1010" width="130%" frameborder="0" style="background:white; padding:15px; border-radius:5px; max-width: 130%; max-height: 120%;"></iframe>
</section>
<section>
<img width="289" height="451" src="img/api.png" alt="API">
</section>
</section>
<section>
<h2>Customizing</h2>
<p>Maybe disable a few things</p>
<pre><code data-trim>
title: {
text: ''
},
subtitle: {
enabled: false
},
legend: {
enabled: false
},
exporting: {
enabled: false
},
credits: {
enabled: false
}
</code></pre>
</section>
<section>
<h2>Customizing</h2>
<p>Change default colors</p>
<pre><code data-trim>
colors: ['#E7A337', '#BC7E35', '#815729', '#716A60'],
</code></pre>
<div class="fragment">
<p>Change text styles</p>
<pre><code data-trim>
title: {
align: 'left',
style: {
color: '#ccc',
fontFamily: '"abril-text", Georgia, serif',
fontSize: '2em',
fontStyle: 'italic'
}
},
</code></pre>
</div>
<div class="fragment">
<p>Myriad more things in the <a href="http://api.highcharts.com/highcharts">API reference</a>.</p>
</div>
</section>
<section>
<h2>Hands-on Time</h2>
<p>Link: <a href="http://bit.ly/1rf6rxD">http://bit.ly/1rf6rxD</a></p>
</section>
<section>
<h2>Data: Series</h2>
<p>Each group of data points is a series ...</p>
<pre><code data-trim>
chart: {
type: 'column'
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0]
}, {
data: [135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}],
</code></pre>
<div class="fragment">
<p>corresponding to a <i>category</i> assigned to the X-axis:</p>
<pre><code data-trim>
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
}
</code></pre>
</div>
<div class="fragment">
<img width="493" height="294" src="img/series.png" alt="Nulls">
</div>
</section>
<section>
<h2>Data: Series</h2>
<p>Skip a point using <code>null</code> and leave empty spot:</p>
<pre><code data-trim>
series: [{
type: 'line',
data: [29.9, 71.5, 106.4, null, 144.0, 176.0]
}],
</code></pre>
<div class="fragment">
<p>Connect a line through the <code>null</code>:</p>
<pre><code data-trim>
plotOptions: {
line: {
connectNulls: true
}
},
</code></pre>
</div>
<div class="fragment">
<img width="900" height="246" src="img/nulls.png" alt="Nulls">
</div>
</section>
<section>
<h2>Data: Series</h2>
<p>Alternatively, we can provide both X and Y coordinates for points:</p>
<pre><code data-trim>
series: [{
type: 'scatter',
data: [
[0, 29.9],
[1, 71.5],
[3, 106.4]
]
}]
</code></pre>
<div class="fragment">
<img width="491" height="259" src="img/scatter.png" alt="Nulls">
</div>
</section>
<section>
<h2>Common issue: Dates</h2>
<p>Dates can be considered "categories" or can use datetime</p>
<pre><code data-trim>
// Categories
xAxis: {
categories: ['Jan', 'Feb', 'Mar']
},
series: [{
data: [129.9, 71.5, 106.4]
}],
// datetime
xAxis: {
type: 'datetime'
},
series: [{
data: [
[Date.UTC(2010, 0, 1), 29.9],
[Date.UTC(2010, 2, 14), 71.5],
[Date.UTC(2010, 3, 9), 106.4]
}]
</code></pre>
</section>
<section>
<h2>Common issue: Dates</h2>
<p>Notes regarding datetime:</p>
<ul>
<li>Use if unevenly dispersed data points</li>
<li>Months start at 0
<ul>
<li>0 - January</li>
<li>7 - August</li>
</ul>
</li>
<li>MUST be in chronological order</li>
</ul>
</section>
<section>
<h2>Hands-on Time</h2>
<p>Link: <a href="http://bit.ly/1mx2Ueq">http://bit.ly/1mx2Ueq</a></p>
</section>
<section>
<h2>Taking this home</h2>
<p>You'll need the ability to put code on your site.</p>
<p>Also, you'll need to include script files.</p>
<pre><code data-trim>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
</code></pre>
<p><i>* Your site may already use jQuery</i></p>
<p>jQuery is best included in the <code><head></code> of your page</p>
<p>Highcharts is best included just before the closing <code></body></code> tag</p>
</section>
<section>
<h2>Taking this home: WordPress</h2>
<p>Some tips for using Highcharts in WordPress</p>
<ul>
<li>Post editor will strip out <code><script></code> <a href="http://codex.wordpress.org/Roles_and_Capabilities#unfiltered_html">for non-admin</a></li>
<li>Always enqueue scripts
<ul>
<li>Maybe tie it to a post category:</li>
</ul>
</li>
</ul>
<pre><code data-trim>
if ( in_category('highcharts') ){
wp_enqueue_script('highcharts', 'http://code...', array('jQuery') );
}
</code></pre>
</section>
<section>
<h2>Advanced: Methods</h2>
<p>Interacting with charts after they are drawn</p>
</section>
<section>
<section>
<h2>Advanced: Toggling data (Step 1)</h2>
<ul>
<li>Create some HTML buttons</li>
<li>Style the buttons with your own CSS</li>
</ul>
<div class="fragment">
<pre><code data-trim>
<div class="button active">Option 1</div>
<div class="button">Option 2</div>
<div class="button">Option 3</div>
</code></pre>
</div>
</section>
<section>
<h2>Advanced: Toggling data (Step 2)</h2>
<ul>
<li>Create an array with all your series data</li>
<li>Add jQuery to fire when buttons are clicked</li>
</ul>
<div class="fragment">
<pre><code data-trim>
var dataArray = {
[5,4,3,2,1],
[8,2,3,8,2],
[0,0,6,8,9]
};
var my_chart = $('#chart').highcharts();
$('.button').on('click', function(){
var index = $(this).index('.button');
var newdata = dataArray[index];
$(this).addClass('active').siblings().removeClass('active');
$.each(my_chart.series[0].data, function(dataIndex, dataValue){
my_chart.series[0].data[dataIndex].update(newdata[dataIndex], false);
});
my_chart.redraw();
});
</code></pre>
<p>See Highcharts API <a href="http://api.highcharts.com/highcharts#Point.update">Point.update</a></p>
</div>
</section>
</section>
<section>
<h2>Advanced: Other data changes</h2>
<p>Combine Point.update with javascript <code>setInterval()</code> to:</p>
<ul>
<li>Animate data (Polarization example)</li>
<li>Update chart with AJAX (Poll dashboard)</li>
</ul>
</section>
<section>
<section>
<h2>Advanced: Combining Javascript tools</h2>
<p>Using <a href="http://imakewebthings.com/jquery-waypoints/">Waypoints</a> to draw a chart when a user scrolls to it</p>
<a href="http://www.pewresearch.org/next-america/"><img src="img/next-am.gif" width="500"/></a>
</section>
<section>
<pre><code data-trim>
var args = {
...
series: [
data: [null, null, null, null, null]
]
};
var actualSeries = [{
name: 'Actual Series',
data: [5, 40, 32, 74, 99]
}];
</code></pre>
<pre><code data-trim>
$('#chart').highcharts(args);
var chart = $('#chart').highcharts();
$("#chart").waypoint( function(direction) {
chart.series[0].remove();
chart.addSeries(actualSeries, false);
chart.redraw();
});
</code></pre>
</section>
</section>
<section>
<h2>Also: <a href="http://www.highcharts.com/products/highmaps">Highmaps</a></h2>
<iframe class="zoom" src="http://www.highcharts.com/maps/demo/color-axis" height="1010" width="130%" frameborder="0" style="background:white; padding:15px; border-radius:5px; max-width: 130%; max-height: 120%;"></iframe>
</section>
<section>
<h1>THE END</h1>
<p>Adam Nekola • <a href="http://www.twitter.com/nekolaweb/">@nekolaweb</a></p>
<p>Find this presentation at: </p>
<p><a href="http://www.adamnekola.com/slides/highcharts/">http://www.adamnekola.com/slides/highcharts/</a></p>
</section>
</div>
</div>
<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/highcharts.js"></script>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.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,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'default', // 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: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>