SlideShare une entreprise Scribd logo
1  sur  21
Télécharger pour lire hors ligne
Visualize Your Dynamic Data with
Chartkick
Nikki Murry @nikkilizmurray Maggie Epps
@mepptimist
Social Driver
The Problem: A mess of JavaScript
var graticule = d3.geo.graticule();
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
var defs = svg.append("defs");
defs.append("path")
.datum({type: "Sphere"})
.attr("id", "sphere")
.attr("d", path);
defs.append("clipPath")
.attr("id", "clip")
.append("use")
.attr("xlink:href", "#sphere");
We Discovered Chartkick!
When would you need Chartkick?
● Your Rails application needs
visualization
● Your priorities are speed,
maintainability, and extensibility
● You want graphs pretty enough
to be user facing, but also
functional enough for admin
reports (Disclosure: Not generated by
Chartkick)
About Chartkick
● Andrew Kane (many other cool gems): https:
//rubygems.org/profiles/ankane
● GroupDate (not compatible with SQLite)
● Gem code:
https://github.com/ankane/chartkick
● Documentation:
http://ankane.github.io/chartkick/
Libraries That Chartkick Uses:
Highcharts
Very configurable
Has a license fee
Google Charts
Limited library
Free
Installation
Add the gem to your Gemfile:
gem ‘chartkick’
Add the script tags to app/views/layouts/application.html.erb
For Google Charts, use:
<%= javascript_include_tag "//www.google.com/jsapi", "chartkick" %>
If you prefer Highcharts, use:
<%= javascript_include_tag "path/to/highcharts.js", "chartkick" %>
But I have a project that’s not in Ruby!!!!!
Not a problem!
Chartkick also has a JavaScript library:
https://github.com/ankane/chartkick.js
And a Python library:
https://github.com/mher/chartkick.py
What’s so special about Chartkick?
Create a graph with one line of Ruby!
Getting the data you want
● Important to know which
data specifically you
want to display
● ActiveRecord or other ORM Queries
● Figuring out the best
chart to display that data
Example #1:
<div class="panel-body">
<%= bar_chart @incoming.joins(:shoutout_values => :value).
group(:name).count %>
</div>
Example #2:
<div class="panel-body">
<%= pie_chart ShoutoutValue.joins(:value).group(:name).count %>
</div>
Customizing Graphs:Standard Options
Inline:
Custom HTML
<%= line_chart data, id: "users-chart", height: "500px" %>
Axis endpoints
<%= line_chart data, min: 1000, max: 5000 %>
Chart colors
<%= line_chart data, colors: ["pink", "#999"] %>
Or in config/initializers/chartkick.rb:
Chartkick.options = { colors: ["#D21724", "gray", "black", "#B27070", "#550000"]}
Customizing Graphs: Using Library
Highcharts: http://www.highcharts.
com/docs
<%= line_chart data, library: {lang: { noData: "There
are no cats here" }, noData: { style: { fontWeight:
'bold', fontSize: '15px', color: '#303030' } } } %>
Google Charts:
https://developers.google.com/chart/
<%= column_chart data, library: {title: “Cat Chart”
backgroundColor: { stroke: "blue", strokeWidth: 4 } } %
>
Options in documentation:
backgroundColor.stroke
backgroundColor.strokeWidth
I want my data even MORE dynamic!
You can use JSON!
In a controller:
class ChartsController < ApplicationController
def completed_tasks
render json: Task.group_by_day(:completed_at).count
end
end
In the view:
<%= line_chart completed_tasks_charts_path %>
Pretty graphs!
Examples….
Multi-series line charts
Timeline
Geocharts
Area Chart
Questions?
Visualize Your Dynamic Data with
Chartkick
Nikki Murry @nikkilizmurray
Maggie Epps @mepptimist
Social Driver

Contenu connexe

Similaire à Dynamic Data Visualization With Chartkick

Computer graphics
Computer graphicsComputer graphics
Computer graphics
amitsarda3
 

Similaire à Dynamic Data Visualization With Chartkick (20)

Google Chart Tools Kanika Garg (10BM60035) Lavanya R. (10BM60042)
Google Chart Tools Kanika Garg (10BM60035) Lavanya R. (10BM60042)Google Chart Tools Kanika Garg (10BM60035) Lavanya R. (10BM60042)
Google Chart Tools Kanika Garg (10BM60035) Lavanya R. (10BM60042)
 
Google Chart Tools
Google Chart Tools Google Chart Tools
Google Chart Tools
 
Svcc 2013-d3
Svcc 2013-d3Svcc 2013-d3
Svcc 2013-d3
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)
 
GraphQL Summit 2019 - Configuration Driven Data as a Service Gateway with Gra...
GraphQL Summit 2019 - Configuration Driven Data as a Service Gateway with Gra...GraphQL Summit 2019 - Configuration Driven Data as a Service Gateway with Gra...
GraphQL Summit 2019 - Configuration Driven Data as a Service Gateway with Gra...
 
D3.js 30-minute intro
D3.js   30-minute introD3.js   30-minute intro
D3.js 30-minute intro
 
Graphs made easy with SAS ODS Graphics Designer (PAPER)
Graphs made easy with SAS ODS Graphics Designer (PAPER)Graphs made easy with SAS ODS Graphics Designer (PAPER)
Graphs made easy with SAS ODS Graphics Designer (PAPER)
 
D3.js - A picture is worth a thousand words
D3.js - A picture is worth a thousand wordsD3.js - A picture is worth a thousand words
D3.js - A picture is worth a thousand words
 
Dublin Ireland Spark Meetup October 15, 2015
Dublin Ireland Spark Meetup October 15, 2015Dublin Ireland Spark Meetup October 15, 2015
Dublin Ireland Spark Meetup October 15, 2015
 
Visual Exploration of Large Data sets with D3, crossfilter and dc.js
Visual Exploration of Large Data sets with D3, crossfilter and dc.jsVisual Exploration of Large Data sets with D3, crossfilter and dc.js
Visual Exploration of Large Data sets with D3, crossfilter and dc.js
 
Having fun with graphs, a short introduction to D3.js
Having fun with graphs, a short introduction to D3.jsHaving fun with graphs, a short introduction to D3.js
Having fun with graphs, a short introduction to D3.js
 
JQuery Flot
JQuery FlotJQuery Flot
JQuery Flot
 
Building Custom Controls to Visualize Data (UI5Con 2016 Frankfurt)
Building Custom Controls to Visualize Data (UI5Con 2016 Frankfurt)Building Custom Controls to Visualize Data (UI5Con 2016 Frankfurt)
Building Custom Controls to Visualize Data (UI5Con 2016 Frankfurt)
 
ESRI Dev Meetup: Building Distributed JavaScript Map Widgets
ESRI Dev Meetup: Building Distributed JavaScript Map WidgetsESRI Dev Meetup: Building Distributed JavaScript Map Widgets
ESRI Dev Meetup: Building Distributed JavaScript Map Widgets
 
SVGD3Angular2React
SVGD3Angular2ReactSVGD3Angular2React
SVGD3Angular2React
 
ELK Stack - Turn boring logfiles into sexy dashboard
ELK Stack - Turn boring logfiles into sexy dashboardELK Stack - Turn boring logfiles into sexy dashboard
ELK Stack - Turn boring logfiles into sexy dashboard
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Move your data (Hans Rosling style) with googleVis + 1 line of R code
Move your data (Hans Rosling style) with googleVis + 1 line of R codeMove your data (Hans Rosling style) with googleVis + 1 line of R code
Move your data (Hans Rosling style) with googleVis + 1 line of R code
 
Introduction to data visualisation with D3
Introduction to data visualisation with D3Introduction to data visualisation with D3
Introduction to data visualisation with D3
 
Google charts
Google chartsGoogle charts
Google charts
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Dernier (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

Dynamic Data Visualization With Chartkick

  • 1. Visualize Your Dynamic Data with Chartkick Nikki Murry @nikkilizmurray Maggie Epps @mepptimist Social Driver
  • 2. The Problem: A mess of JavaScript var graticule = d3.geo.graticule(); var svg = d3.select("body").append("svg") .attr("width", width) .attr("height", height); var defs = svg.append("defs"); defs.append("path") .datum({type: "Sphere"}) .attr("id", "sphere") .attr("d", path); defs.append("clipPath") .attr("id", "clip") .append("use") .attr("xlink:href", "#sphere");
  • 3. We Discovered Chartkick! When would you need Chartkick? ● Your Rails application needs visualization ● Your priorities are speed, maintainability, and extensibility ● You want graphs pretty enough to be user facing, but also functional enough for admin reports (Disclosure: Not generated by Chartkick)
  • 4. About Chartkick ● Andrew Kane (many other cool gems): https: //rubygems.org/profiles/ankane ● GroupDate (not compatible with SQLite) ● Gem code: https://github.com/ankane/chartkick ● Documentation: http://ankane.github.io/chartkick/
  • 5. Libraries That Chartkick Uses: Highcharts Very configurable Has a license fee Google Charts Limited library Free
  • 6. Installation Add the gem to your Gemfile: gem ‘chartkick’ Add the script tags to app/views/layouts/application.html.erb For Google Charts, use: <%= javascript_include_tag "//www.google.com/jsapi", "chartkick" %> If you prefer Highcharts, use: <%= javascript_include_tag "path/to/highcharts.js", "chartkick" %>
  • 7. But I have a project that’s not in Ruby!!!!! Not a problem! Chartkick also has a JavaScript library: https://github.com/ankane/chartkick.js And a Python library: https://github.com/mher/chartkick.py
  • 8. What’s so special about Chartkick? Create a graph with one line of Ruby!
  • 9. Getting the data you want ● Important to know which data specifically you want to display ● ActiveRecord or other ORM Queries ● Figuring out the best chart to display that data
  • 10. Example #1: <div class="panel-body"> <%= bar_chart @incoming.joins(:shoutout_values => :value). group(:name).count %> </div>
  • 11. Example #2: <div class="panel-body"> <%= pie_chart ShoutoutValue.joins(:value).group(:name).count %> </div>
  • 12. Customizing Graphs:Standard Options Inline: Custom HTML <%= line_chart data, id: "users-chart", height: "500px" %> Axis endpoints <%= line_chart data, min: 1000, max: 5000 %> Chart colors <%= line_chart data, colors: ["pink", "#999"] %> Or in config/initializers/chartkick.rb: Chartkick.options = { colors: ["#D21724", "gray", "black", "#B27070", "#550000"]}
  • 13. Customizing Graphs: Using Library Highcharts: http://www.highcharts. com/docs <%= line_chart data, library: {lang: { noData: "There are no cats here" }, noData: { style: { fontWeight: 'bold', fontSize: '15px', color: '#303030' } } } %> Google Charts: https://developers.google.com/chart/ <%= column_chart data, library: {title: “Cat Chart” backgroundColor: { stroke: "blue", strokeWidth: 4 } } % > Options in documentation: backgroundColor.stroke backgroundColor.strokeWidth
  • 14. I want my data even MORE dynamic! You can use JSON! In a controller: class ChartsController < ApplicationController def completed_tasks render json: Task.group_by_day(:completed_at).count end end In the view: <%= line_chart completed_tasks_charts_path %>
  • 21. Visualize Your Dynamic Data with Chartkick Nikki Murry @nikkilizmurray Maggie Epps @mepptimist Social Driver