Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
js_charts
Search
Gordon Diggs
June 14, 2013
110
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
js_charts
Gordon Diggs
June 14, 2013
More Decks by Gordon Diggs
See All by Gordon Diggs
John Coltrane: Lessons in Leadership
gordondiggs
2
310
The Customer Gap
gordondiggs
1
120
Picking Records with JavaScript and a Button
gordondiggs
0
88
Kafka Partitioning Algorithm
gordondiggs
0
150
Supbutton
gordondiggs
0
88
Rayons
gordondiggs
0
94
Sous Vide
gordondiggs
0
110
Dev Events & Internal Tools at Paperless Post
gordondiggs
0
130
The Joys and Pains of Working With an Old Codebase
gordondiggs
0
150
Featured
See All Featured
A Soul's Torment
seathinner
6
2.9k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
[SF Ruby Conf 2025] Rails X
palkan
2
1.1k
The Curious Case for Waylosing
cassininazir
1
380
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
140
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
300
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
210
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.2k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
Transcript
Javascript Chart Libraries Gordon Diggs PP Dev Lightning Talks 130614
Friday, June 14, 13
A little history Friday, June 14, 13
My considerations • Lots of data • Need labels to
be relevant/understandable • Raw numbers more significant than comparisons Friday, June 14, 13
d3.js / rickshaw probably amazing. Friday, June 14, 13
A chronological look at the ones I’ve used Friday, June
14, 13
Google Charts API • Not actually javascript • Static images
• Pass all the data in the URL • Will do automatic gradient • Deprecated Friday, June 14, 13
Google Charts API • http://chart.apis.google.com/chart? cht=p&chd=s:world5&chs=200x125&chl=A |B|C|D|E|Fe Friday, June 14,
13
Google Charts API Friday, June 14, 13
Google Charts API (js) • Great interactivity, can bind events
• Auto-coloring • Pain to set up • Data format kind of weird • Not really open source Friday, June 14, 13
var drawChart = function(elem) {
var options = { backgroundColor: { fill: '#2F2F2F', stroke: '#2F2F2F' }, pieSliceBorderColor: '#2F2F2F', pieSliceText: 'label', pieSliceTextStyle: { color: 'black', fontSize: '12' }, legend: {position: 'none'}, chartArea: {width: '800', height: '500'} }; $.getJSON('/occurrences', { field: $(elem).attr('data-‐field') }, function(response) { console.log("response for field:", $(elem).attr('data-‐field'), response); var data = google.visualization.arrayToDataTable(response.occurrence); var chart = new google.visualization.PieChart(elem) chart.draw(data, options); // add select listener to jump to search results from pie charts google.visualization.events.addListener(chart, 'select', function() { var selected = chart.getSelection()//, label = data.getFormattedValue(selected[0].row, 0); if(confirm("Go to results for '" + label + "'?")) { window.location.href = '/?search=' + encodeURIComponent(label); } }); }); }; $('.chart').each(function(i) { drawChart(this); }); Friday, June 14, 13
Google Charts API (js) Friday, June 14, 13
Google Charts API (js) • https://developers.google.com/chart/ Friday, June 14, 13
Chart.js • Canvas • Good initialization • Nice animation •
Limited Interactivity • No labels Friday, June 14, 13
$('.chart').each(function(i) {
var $elem = $(this), ctx = $elem.find('canvas')[0].getContext("2d"); $.getJSON('/stats', { field: $elem.attr('data-‐field') }, function(response) { var data = [], colors = colorGradient('224466', '6699bb', response.length); $.each(response, function(i, datum) { datum.color = colors[i % colors.length]; data[i] = datum; }); new Chart(ctx).Pie(data, { segmentStrokeColor: '#2F2F2F', segmentStrokeWidth: 1, animation: false }); }); }); Friday, June 14, 13
Chart.js Friday, June 14, 13
Chart.js • http://www.chartjs.org Friday, June 14, 13
Chartkick • One line of ruby • Takes ruby data
structures • Interactivity and labels Friday, June 14, 13
= pie_chart Item.group("artist").count Friday, June 14, 13
Chartkick Friday, June 14, 13
Chartkick • http://ankane.github.io/chartkick/ Friday, June 14, 13
BONUS: jqcloud • Easy way to make word clouds with
jQuery Friday, June 14, 13
$.each($('.frequency'), function(i, freq) { $.getJSON('/items/words_for_field?field='+$(freq).data('field'), function(response)
{ $(freq).jQCloud(response); }); }); Friday, June 14, 13
jqcloud Friday, June 14, 13
jqcloud • https://github.com/lucaong/jQCloud Friday, June 14, 13
Thanks! Friday, June 14, 13