SlideShare una empresa de Scribd logo
1 de 60
Quick & Easy Data Visualization
with Google Visualization API
+ Google Chart Libraries
Bohyun Kim ( Twitter: @bohyunkim)
Associate Director for Library Applications & Knowledge Systems
University of Maryland, Baltimore
Health Sciences & Human Services Library
CODE4LIB Conference, Raleigh, NC. Mar. 25, 2014.
0. Spreadsheets Ain’t Databases.
CIRC
Newspaper
holdings
Textbook
lists
ACQ
Newspaper
holdings
Textbook
lists
REF
Newspaper
holdings
Textbook
lists
WEB
Newspaper
holdings
Textbook
lists
Creating a web application with a database is not always a
solution available, convenient, or efficient.
Image from Flickr CreativeCommons http://www.flickr.com/photos/88575173@N00/2445955296/
1. But What If They Were … Almost?
• Data Source
<-- Google Spreadsheet
• Query data
<-- Google Visualization API Query Language
• Display on the web
<-- Google Chart Libraries
2. Google Visualization API
Query Language
• Allows you to perform various data manipulations with the
query to the data source, such as Google spreadsheet, fusion
table, or your own database.
• Enables you to query the data source and visualize data with
Google Chart Libraries
• Similar to SQL
https://developers.google.com/chart/interactive/docs/query
language
• Google Visualization API Reference:
https://developers.google.com/chart/interactive/docs/refere
nce
Google Spreadsheet – widely used
URLs for a G Spreadsheet
• In Google Spreadsheet – Sheet3
https://docs.google.com/spreadsheet/ccc?key=0AqAPbBT_k2VUdDc3aC1xS2o
0c2ZmaVpOQWkyY0l1eVE&usp=drive_web#gid=2
• HTML Table
https://spreadsheets.google.com/tq?tqx=out:html&tq=&key=0AqAPbBT_k2VUd
Dc3aC1xS2o0c2ZmaVpOQWkyY0l1eVE&gid=2
• Raw Data Response
: includes a DataTable that you can retrieve by calling getDataTable()
https://spreadsheets.google.com/tq?&tq=&key=0AqAPbBT_k2VUdDc3aC1xS2o0
c2ZmaVpOQWkyY0l1eVE&gid=2
• google.visualization.DataTable
Classhttps://developers.google.com/chart/interactive/docs/reference#DataTabl
e
• Query Language Reference (Version
0.7)https://developers.google.com/chart/interactive/docs/querylanguage#Setti
ng_the_Query_in_the_Data_Source_URL
Raw Data response from G spreadsheet
https://spreadsheets.google.com/tq?&tq=&key=0AqAPbBT_k2VUdDc3aC1xS2o0c2ZmaVpOQWkyY0l1eVE&gid=2
Datatable from G spreadsheet
3-1. Query the Spreadsheet
& Display the Result as a Web page
• Step 1. Form a query
: Show column B, C, D, F where C contains ‘Florida’
• Step 2. Output the query result
As a stand-alone web page with a table
(Needed: URL)
OR
Into your web page as a table / chart
(Needed: JavaScript, G Chart Libraries)
Example G Spreadsheet
https://docs.google.com/spreadsheet/ccc?key=0AqAPbBT_k2VUdDFYamtHdkFqVHZ4VXZ
XSVVraGxacEE&usp=drive_web#gid=0
What Goes into the URL
https://spreadsheets.google.com/
tq?
tqx=out:html
&tq=select B,C,D,F where (C contains 'Florida’)
&key=0AqAPbBT_k2VUdEtXYXdLdjM0TXY1YUV
hMk9jeUQ0NkE
&gid=0 (optional for Sheet1)
https://spreadsheets.google.com/tq?tqx=out:html&tq=select+B,C,D,F+where+%28C+co
ntains+%27Florida%27%29&key=0AqAPbBT_k2VUdEtXYXdLdjM0TXY1YUVhMk9jeUQ0N
kE
Result of the query: SELECT B, C, D, F
WHERE C CONTAINS ‘Florida’
N.B. Google Spreadsheet Size Limit: 400k cells, 256 columns, 20 MB
https://support.google.com/drive/answer/2505921?hl=en
https://spreadsheets.google.com/tq?tqx=out:html&tq=select+B,C,D,F+wher
e+%28B+contains+%27Agoulnik%27%29&key=0AqAPbBT_k2VUdEtXYXdLdj
M0TXY1YUVhMk9jeUQ0NkE
SELECT D,F COUNT(C) WHERE
(B CONTAINS ‘Agoulnik’) GROUP BY D, F
https://spreadsheets.google.com/tq?tqx=out:html&tq=select+D,F,count(C)+where+%28B+
contains+%27Agoulnik%27%29+group+by+D,F&key=0AqAPbBT_k2VUdEtXYXdLdjM0TXY1Y
UVhMk9jeUQ0NkE
Query Options
• Order by, Limit, Offset, Group By (), Pivot
• Label, Format
• avg(), max(), min()
• count(), sum()
• year(), month(), date(), hour()
• minute(), second(), millisecond()
• quarter(), dayOfWeek(), now(), dateDiff()
• toDate(), upper(), lower()
• https://developers.google.com/chart/interactive/
docs/querylanguage#Options
PIVOT
select sum(B) pivot C
https://spreadsheets.google.com/tq?tqx=out:html&tq=select%20sum%28B%29%20pivo
t%28C%29&key=0AqAPbBT_k2VUdHg4X08zMXFMeXRmdURJNUx5blpYUmc
select c, sum(B) group by (C)
https://spreadsheets.google.com/tq?tqx=out:html&tq=select%20C,sum%28B%29%20gr
oup%20by%28C%29&key=0AqAPbBT_k2VUdHg4X08zMXFMeXRmdURJNUx5blpYUmc&g
id=0
select A, sum(B) group by A pivot C
https://spreadsheets.google.com/tq?tqx=out:html&tq=select%20A,%20sum%28B%29%2
0group%20by%20A%20pivot%20C&key=0AqAPbBT_k2VUdHg4X08zMXFMeXRmdURJNUx
5blpYUmc&gid=0
select C, sum(B) group by C pivot A
https://spreadsheets.google.com/tq?tqx=out:html&tq=select%20C,%20sum%28B%29%
20group%20by%20C%20pivot%20A&key=0AqAPbBT_k2VUdHg4X08zMXFMeXRmdURJN
Ux5blpYUmc&gid=0
3-2. Use JS instead of a URL
• More flexible and you can add control options
for users.
• To set the query string from within JavaScript
code, call the setQuery method of the
google.visualization.Query class.
Drop It into Your Own Web Page
Query: SELECT B, C, D, F WHERE C contains ‘Florida’
Parameters
• headers=N - Specifies how many rows are header rows, where N is
an integer zero or greater. These will be excluded from the data and
assigned as column labels in the data table. If not specified, the
spreadsheet will guess how many rows are header rows.
• Range=NN:NN
Example: range=A1:C6
• gid=N - Specifies which sheet in a multi-sheet document to link to, if
you are not linking to the first sheet. N is the sheet's ID number.
Example: gid=0 (for Sheet1)
• sheet=sheet_name - Specifies which sheet in a multi-sheet
document you are linking to, if you are not linking to the first sheet.
sheet_name is the display name of the sheet. You can use the gid
parameter instead of this parameter.
Example: sheet=Sheet5
4. Visualize Your G Spreadsheet Data
Using Google Chart Libraries
The most common way to use Google Charts is with
simple JavaScript that you embed in your web page.
1. You load some Google Chart libraries.
2. List the data to be charted.
3. Select options to customize your chart.
4. Create a chart object with an id that you choose.
5. Then, later in the web page, you create a <div> with
that id to display the Google Chart.
https://developers.google.com/chart/interactive/docs/
Visualize as a table or a chart
• To set the query string from within JavaScript code, call the
setQuery method of the google.visualization.Query class.
• 3 chart drawing techniques:
• chart.draw()
• ChartWrapper
• DrawChart()
• See also:
https://developers.google.com/chart/interactive/docs/dra
wing_charts
(a) chart.draw()
Process
• Load the JSAPI, Google Visualization, and chart libraries.
• Prepare your data.
• Prepare any chart options.
• Instantiate the chart class, passing in a handle to the page container
element.
• Optionally register to receive any chart events. If you intend to call methods
on the chart, you should listen for the "ready" event.
• Call chart.draw(), passing in the data and options.
Advantages
• You have complete control over every step of the process.
• You can register to listen for all events thrown by the chart.
Disadvantages
• Verbose
• You must explicitly load all required chart libraries
• If you send queries, you must manually implement for the callback, check
for success, extract the returned DataTable, and pass it to the chart.
example1._florida.html
Separate the Query from URL
Multiple charts
example2_chartdraw.html
Adapted from: Traci L. Ruthkoski,
Google Visualization API Essentials,
Packt, 2013.
(b) chartwrapper
ChartWrapper is a convenience class that handles loading all the appropriate
chart libraries for you and also simplifies sending queries to Chart Tools
Datasources.
Advantages:
• Much less code
• Loads all the required chart libraries for you
• Makes querying data sources much easier by creating the Query object and
handling the callback for you
• Pass in the container element ID, and it will call getElementByID for you.
• Data can be submitted in a variety of formats: as an array of values, as a
JSON literal string, or as a DataTable handle
Disadvantages:
• ChartWrapper currently propagates only the select, ready, and error events.
To get other events, you must get a handle to the wrapped chart and
subscribe to events there. See the ChartWrapper documentation for
examples.
https://developers.google.com/chart/interactive/docs/drawing_charts#chartwrapper
Line chart - query: 'SELECT A,D
WHERE D > 100 ORDER BY D',
https://developers.google.com/chart/interactive/docs/drawing_charts#chart
wrapper
(c) Drawchart()
DrawChart() is a global static method that wraps a
ChartWrapper.
Advantages:
• Same as ChartWrapper, but slightly shorter to
use.
Disadvantages:
• Does not return a handle to the wrapper, so you
cannot handle any events.
example3_piechart.html
5. Use Data from Your Own Database
with Google Chart Libraries
Simple G DataTable
https://developers.google.com/chart/interactive/docs/reference#DataTable
G Spreadsheet
Datatable response
https://spreadsheets.goog
le.com/tq?&tq=&key=0Aq
APbBT_k2VUdFgwUm5oe
HNEajlhODJoR2pVVWlTeF
E&gid=0
JSON Feed from G Spreadsheet
https://spreadsheets.google.com/feeds/list/0AqAPbBT_k2VUdFgwUm5oeHNEajlhODJ
oR2pVVWlTeFE/1/public/values?alt=json-in-script&callback=cb
An Example MySQL db table
Source for the PHP script on the next slide:
http://stackoverflow.com/questions/12994282/php-mysql-google-chart-json-
complete-example
Construct G DataTable from MySQL db
{
"cols":[{"label":"Weekly
Task","type":"string"},{"label":"Percentage","type":"
number"}],
"rows":[{"c":[{"v":"Sleep"},{"v":30}]},{"c":[{"v":"Watc
hing
Movie"},{"v":10}]},{"c":[{"v":"Job"},{"v":40}]},{"c":[{"
v":"Exercise"},{"v":20}]}]
}
http://stackoverflow.com/questions/12994282/php-mysql-google-chart-json-
complete-example
6. Controls and Dashboards
https://developers.google.com/chart/interactive/docs/gallery/controls
Draw a Dashboard
1. Create An HTML Skeleton For Your Dashboard
2. Load Your Libraries
3. Prepare Your Data
4. Create a Dashboard Instance
5. Create Control and Chart Instances
6. Establish Dependencies (=bind)
7. Draw Your Dashboard
8. Programmatic Changes after Draw
google.load('visualization', '1.0',{'packages':['controls']});
….
dashboard.bind(donutRangeSlider, pieChart);
dashboard.draw(data);
https://developers.google.com/chart/interactive/docs/gallery/controls
example4_controls.html
Dashboard with multiple controls
and a remote data source
new google.visualization.Dashboard(document.getElementById('dashboard'))
.bind([slider, categoryPicker], [pie, table]).draw(data);
example5_dashboard.html
Google Code playground
http://code.google.com/apis/ajax/playground/
Google Public Data Explorer
http://www.google.com/publicdata/directory
Questions?
• Slides: http://slideshare.net/bohyunkim
• Code: https://github.com/bohyunkim/examples
• Twitter: @bohyunkim
• Web: http://bohyunkim.net/blog
Image credit for the title slide:
https://www.flickr.com/photos/44718928@N00/7219422352/
by the Flickr user @justgrimes

Más contenido relacionado

Similar a Quick & Easy Data Visualization with Google Visualization API + Google Chart Libraries

Automating some google things
Automating some google thingsAutomating some google things
Automating some google thingsScott Sunderland
 
Google cloud Professional Data Engineer practice exam test 2020
Google cloud Professional Data Engineer practice exam test 2020Google cloud Professional Data Engineer practice exam test 2020
Google cloud Professional Data Engineer practice exam test 2020SkillCertProExams
 
Yale Library - Google Analytics & Tableau (5/14/2015)
Yale Library - Google Analytics & Tableau (5/14/2015)Yale Library - Google Analytics & Tableau (5/14/2015)
Yale Library - Google Analytics & Tableau (5/14/2015)Sarah Tudesco
 
[Webinar] Interacting with BigQuery and Working with Advanced Queries
[Webinar] Interacting with BigQuery and Working with Advanced Queries[Webinar] Interacting with BigQuery and Working with Advanced Queries
[Webinar] Interacting with BigQuery and Working with Advanced QueriesTatvic Analytics
 
Google Data Studio for business
Google Data Studio for businessGoogle Data Studio for business
Google Data Studio for businessOWOX BI
 
Supercharge your data analytics with BigQuery
Supercharge your data analytics with BigQuerySupercharge your data analytics with BigQuery
Supercharge your data analytics with BigQueryMárton Kodok
 
Google professional data engineer exam dumps
Google professional data engineer exam dumpsGoogle professional data engineer exam dumps
Google professional data engineer exam dumpsTestPrep Training
 
Key projects Data Science and Engineering
Key projects Data Science and EngineeringKey projects Data Science and Engineering
Key projects Data Science and EngineeringVijayananda Mohire
 
Key projects Data Science and Engineering
Key projects Data Science and EngineeringKey projects Data Science and Engineering
Key projects Data Science and EngineeringVijayananda Mohire
 
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)Kanika Garg
 
Feed your inner data scientist. JS Visualization Tools
Feed your inner data scientist.  JS Visualization ToolsFeed your inner data scientist.  JS Visualization Tools
Feed your inner data scientist. JS Visualization ToolsDoug Mair
 
Big query the first step - (MOSG)
Big query the first step - (MOSG)Big query the first step - (MOSG)
Big query the first step - (MOSG)Soshi Nemoto
 
The current status of html5 technology and standard
The current status of html5 technology and standardThe current status of html5 technology and standard
The current status of html5 technology and standardWonsuk Lee
 
Data Visualization on the Web - Intro to D3
Data Visualization on the Web - Intro to D3Data Visualization on the Web - Intro to D3
Data Visualization on the Web - Intro to D3Angela Zoss
 
Google Enterprise Cloud Platform - Resources & $2000 credit!
Google Enterprise Cloud Platform - Resources & $2000 credit!Google Enterprise Cloud Platform - Resources & $2000 credit!
Google Enterprise Cloud Platform - Resources & $2000 credit!BigDataCloud
 
Leveraging Geographic Data in SugarCRM
Leveraging Geographic Data in SugarCRMLeveraging Geographic Data in SugarCRM
Leveraging Geographic Data in SugarCRMAsa Kusuma
 
Google Devfest 2009 Argentina - Google and the Social Web
Google Devfest 2009 Argentina - Google and the Social WebGoogle Devfest 2009 Argentina - Google and the Social Web
Google Devfest 2009 Argentina - Google and the Social WebPatrick Chanezon
 
Google.Test4prep.Professional-Data-Engineer.v2038q.pdf
Google.Test4prep.Professional-Data-Engineer.v2038q.pdfGoogle.Test4prep.Professional-Data-Engineer.v2038q.pdf
Google.Test4prep.Professional-Data-Engineer.v2038q.pdfssuser22b701
 
Introduction to web scraping
Introduction to web scrapingIntroduction to web scraping
Introduction to web scrapingDario Cottafava
 

Similar a Quick & Easy Data Visualization with Google Visualization API + Google Chart Libraries (20)

Automating some google things
Automating some google thingsAutomating some google things
Automating some google things
 
Big query
Big queryBig query
Big query
 
Google cloud Professional Data Engineer practice exam test 2020
Google cloud Professional Data Engineer practice exam test 2020Google cloud Professional Data Engineer practice exam test 2020
Google cloud Professional Data Engineer practice exam test 2020
 
Yale Library - Google Analytics & Tableau (5/14/2015)
Yale Library - Google Analytics & Tableau (5/14/2015)Yale Library - Google Analytics & Tableau (5/14/2015)
Yale Library - Google Analytics & Tableau (5/14/2015)
 
[Webinar] Interacting with BigQuery and Working with Advanced Queries
[Webinar] Interacting with BigQuery and Working with Advanced Queries[Webinar] Interacting with BigQuery and Working with Advanced Queries
[Webinar] Interacting with BigQuery and Working with Advanced Queries
 
Google Data Studio for business
Google Data Studio for businessGoogle Data Studio for business
Google Data Studio for business
 
Supercharge your data analytics with BigQuery
Supercharge your data analytics with BigQuerySupercharge your data analytics with BigQuery
Supercharge your data analytics with BigQuery
 
Google professional data engineer exam dumps
Google professional data engineer exam dumpsGoogle professional data engineer exam dumps
Google professional data engineer exam dumps
 
Key projects Data Science and Engineering
Key projects Data Science and EngineeringKey projects Data Science and Engineering
Key projects Data Science and Engineering
 
Key projects Data Science and Engineering
Key projects Data Science and EngineeringKey projects Data Science and Engineering
Key projects Data Science and Engineering
 
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)
 
Feed your inner data scientist. JS Visualization Tools
Feed your inner data scientist.  JS Visualization ToolsFeed your inner data scientist.  JS Visualization Tools
Feed your inner data scientist. JS Visualization Tools
 
Big query the first step - (MOSG)
Big query the first step - (MOSG)Big query the first step - (MOSG)
Big query the first step - (MOSG)
 
The current status of html5 technology and standard
The current status of html5 technology and standardThe current status of html5 technology and standard
The current status of html5 technology and standard
 
Data Visualization on the Web - Intro to D3
Data Visualization on the Web - Intro to D3Data Visualization on the Web - Intro to D3
Data Visualization on the Web - Intro to D3
 
Google Enterprise Cloud Platform - Resources & $2000 credit!
Google Enterprise Cloud Platform - Resources & $2000 credit!Google Enterprise Cloud Platform - Resources & $2000 credit!
Google Enterprise Cloud Platform - Resources & $2000 credit!
 
Leveraging Geographic Data in SugarCRM
Leveraging Geographic Data in SugarCRMLeveraging Geographic Data in SugarCRM
Leveraging Geographic Data in SugarCRM
 
Google Devfest 2009 Argentina - Google and the Social Web
Google Devfest 2009 Argentina - Google and the Social WebGoogle Devfest 2009 Argentina - Google and the Social Web
Google Devfest 2009 Argentina - Google and the Social Web
 
Google.Test4prep.Professional-Data-Engineer.v2038q.pdf
Google.Test4prep.Professional-Data-Engineer.v2038q.pdfGoogle.Test4prep.Professional-Data-Engineer.v2038q.pdf
Google.Test4prep.Professional-Data-Engineer.v2038q.pdf
 
Introduction to web scraping
Introduction to web scrapingIntroduction to web scraping
Introduction to web scraping
 

Más de Bohyun Kim

Exploring Machine Learning for Libraries and Archives: Present and Future
Exploring Machine Learning for Libraries and Archives: Present and FutureExploring Machine Learning for Libraries and Archives: Present and Future
Exploring Machine Learning for Libraries and Archives: Present and FutureBohyun Kim
 
New Technologies of the Fourth Industrial Revolution: AI, IoT, Robotics, and ...
New Technologies of the Fourth Industrial Revolution: AI, IoT, Robotics, and ...New Technologies of the Fourth Industrial Revolution: AI, IoT, Robotics, and ...
New Technologies of the Fourth Industrial Revolution: AI, IoT, Robotics, and ...Bohyun Kim
 
Practical Considerations for Open Infrastructure
Practical Considerations for Open InfrastructurePractical Considerations for Open Infrastructure
Practical Considerations for Open InfrastructureBohyun Kim
 
AI for Libraries
AI for LibrariesAI for Libraries
AI for LibrariesBohyun Kim
 
The Potential and Challenges of Today's AI
The Potential and Challenges of Today's AIThe Potential and Challenges of Today's AI
The Potential and Challenges of Today's AIBohyun Kim
 
Robots: What Could Go Wrong? What Could Go Right?
Robots: What Could Go Wrong? What Could Go Right? Robots: What Could Go Wrong? What Could Go Right?
Robots: What Could Go Wrong? What Could Go Right? Bohyun Kim
 
AI & Us: Are We Intelligent Machines?
AI & Us: Are We Intelligent Machines?AI & Us: Are We Intelligent Machines?
AI & Us: Are We Intelligent Machines?Bohyun Kim
 
Blockchain: The New Technology and Its Applications for Libraries
Blockchain: The New Technology and Its Applications for LibrariesBlockchain: The New Technology and Its Applications for Libraries
Blockchain: The New Technology and Its Applications for LibrariesBohyun Kim
 
Machine Intelligence and Moral Decision-Making
Machine Intelligence and Moral Decision-MakingMachine Intelligence and Moral Decision-Making
Machine Intelligence and Moral Decision-MakingBohyun Kim
 
Impact of Artificial Intelligence (AI) on Libraries
Impact of Artificial Intelligence (AI) on Libraries Impact of Artificial Intelligence (AI) on Libraries
Impact of Artificial Intelligence (AI) on Libraries Bohyun Kim
 
Taking on a New Leadership Challenge: Student-Focused Learning in Artificial ...
Taking on a New Leadership Challenge: Student-Focused Learning in Artificial ...Taking on a New Leadership Challenge: Student-Focused Learning in Artificial ...
Taking on a New Leadership Challenge: Student-Focused Learning in Artificial ...Bohyun Kim
 
Moving Forward with Digital Disruption: A Right Mindset
Moving Forward with Digital Disruption: A Right MindsetMoving Forward with Digital Disruption: A Right Mindset
Moving Forward with Digital Disruption: A Right MindsetBohyun Kim
 
 Blockchain Overview: Possibilities and Issues
 Blockchain Overview: Possibilities and Issues Blockchain Overview: Possibilities and Issues
 Blockchain Overview: Possibilities and IssuesBohyun Kim
 
AI Lab at a Library? Why Artificial Intelligence Matters & What Libraries Can Do
AI Lab at a Library? Why Artificial Intelligence Matters & What Libraries Can DoAI Lab at a Library? Why Artificial Intelligence Matters & What Libraries Can Do
AI Lab at a Library? Why Artificial Intelligence Matters & What Libraries Can DoBohyun Kim
 
A Pedagogical Approach to Web Scale Discovery User Interface
A Pedagogical Approach to Web Scale Discovery User InterfaceA Pedagogical Approach to Web Scale Discovery User Interface
A Pedagogical Approach to Web Scale Discovery User InterfaceBohyun Kim
 
From Virtual Reality to Blockchain: Current and Emerging Tech Trends
From Virtual Reality to Blockchain: Current and Emerging Tech TrendsFrom Virtual Reality to Blockchain: Current and Emerging Tech Trends
From Virtual Reality to Blockchain: Current and Emerging Tech TrendsBohyun Kim
 
Interdisciplinary Learning through Libraries on Artificial Intelligence
Interdisciplinary Learning through Libraries on Artificial IntelligenceInterdisciplinary Learning through Libraries on Artificial Intelligence
Interdisciplinary Learning through Libraries on Artificial IntelligenceBohyun Kim
 
Facing Change: Tweak or Transform?
Facing Change: Tweak or Transform?Facing Change: Tweak or Transform?
Facing Change: Tweak or Transform?Bohyun Kim
 
Innovating Together: the UX of Discovery
Innovating Together: the UX of DiscoveryInnovating Together: the UX of Discovery
Innovating Together: the UX of DiscoveryBohyun Kim
 
Cleaning Up the Mess: Modernizing Your Dev Team’s Outdated Workflow
Cleaning Up the Mess: Modernizing Your Dev Team’s Outdated WorkflowCleaning Up the Mess: Modernizing Your Dev Team’s Outdated Workflow
Cleaning Up the Mess: Modernizing Your Dev Team’s Outdated WorkflowBohyun Kim
 

Más de Bohyun Kim (20)

Exploring Machine Learning for Libraries and Archives: Present and Future
Exploring Machine Learning for Libraries and Archives: Present and FutureExploring Machine Learning for Libraries and Archives: Present and Future
Exploring Machine Learning for Libraries and Archives: Present and Future
 
New Technologies of the Fourth Industrial Revolution: AI, IoT, Robotics, and ...
New Technologies of the Fourth Industrial Revolution: AI, IoT, Robotics, and ...New Technologies of the Fourth Industrial Revolution: AI, IoT, Robotics, and ...
New Technologies of the Fourth Industrial Revolution: AI, IoT, Robotics, and ...
 
Practical Considerations for Open Infrastructure
Practical Considerations for Open InfrastructurePractical Considerations for Open Infrastructure
Practical Considerations for Open Infrastructure
 
AI for Libraries
AI for LibrariesAI for Libraries
AI for Libraries
 
The Potential and Challenges of Today's AI
The Potential and Challenges of Today's AIThe Potential and Challenges of Today's AI
The Potential and Challenges of Today's AI
 
Robots: What Could Go Wrong? What Could Go Right?
Robots: What Could Go Wrong? What Could Go Right? Robots: What Could Go Wrong? What Could Go Right?
Robots: What Could Go Wrong? What Could Go Right?
 
AI & Us: Are We Intelligent Machines?
AI & Us: Are We Intelligent Machines?AI & Us: Are We Intelligent Machines?
AI & Us: Are We Intelligent Machines?
 
Blockchain: The New Technology and Its Applications for Libraries
Blockchain: The New Technology and Its Applications for LibrariesBlockchain: The New Technology and Its Applications for Libraries
Blockchain: The New Technology and Its Applications for Libraries
 
Machine Intelligence and Moral Decision-Making
Machine Intelligence and Moral Decision-MakingMachine Intelligence and Moral Decision-Making
Machine Intelligence and Moral Decision-Making
 
Impact of Artificial Intelligence (AI) on Libraries
Impact of Artificial Intelligence (AI) on Libraries Impact of Artificial Intelligence (AI) on Libraries
Impact of Artificial Intelligence (AI) on Libraries
 
Taking on a New Leadership Challenge: Student-Focused Learning in Artificial ...
Taking on a New Leadership Challenge: Student-Focused Learning in Artificial ...Taking on a New Leadership Challenge: Student-Focused Learning in Artificial ...
Taking on a New Leadership Challenge: Student-Focused Learning in Artificial ...
 
Moving Forward with Digital Disruption: A Right Mindset
Moving Forward with Digital Disruption: A Right MindsetMoving Forward with Digital Disruption: A Right Mindset
Moving Forward with Digital Disruption: A Right Mindset
 
 Blockchain Overview: Possibilities and Issues
 Blockchain Overview: Possibilities and Issues Blockchain Overview: Possibilities and Issues
 Blockchain Overview: Possibilities and Issues
 
AI Lab at a Library? Why Artificial Intelligence Matters & What Libraries Can Do
AI Lab at a Library? Why Artificial Intelligence Matters & What Libraries Can DoAI Lab at a Library? Why Artificial Intelligence Matters & What Libraries Can Do
AI Lab at a Library? Why Artificial Intelligence Matters & What Libraries Can Do
 
A Pedagogical Approach to Web Scale Discovery User Interface
A Pedagogical Approach to Web Scale Discovery User InterfaceA Pedagogical Approach to Web Scale Discovery User Interface
A Pedagogical Approach to Web Scale Discovery User Interface
 
From Virtual Reality to Blockchain: Current and Emerging Tech Trends
From Virtual Reality to Blockchain: Current and Emerging Tech TrendsFrom Virtual Reality to Blockchain: Current and Emerging Tech Trends
From Virtual Reality to Blockchain: Current and Emerging Tech Trends
 
Interdisciplinary Learning through Libraries on Artificial Intelligence
Interdisciplinary Learning through Libraries on Artificial IntelligenceInterdisciplinary Learning through Libraries on Artificial Intelligence
Interdisciplinary Learning through Libraries on Artificial Intelligence
 
Facing Change: Tweak or Transform?
Facing Change: Tweak or Transform?Facing Change: Tweak or Transform?
Facing Change: Tweak or Transform?
 
Innovating Together: the UX of Discovery
Innovating Together: the UX of DiscoveryInnovating Together: the UX of Discovery
Innovating Together: the UX of Discovery
 
Cleaning Up the Mess: Modernizing Your Dev Team’s Outdated Workflow
Cleaning Up the Mess: Modernizing Your Dev Team’s Outdated WorkflowCleaning Up the Mess: Modernizing Your Dev Team’s Outdated Workflow
Cleaning Up the Mess: Modernizing Your Dev Team’s Outdated Workflow
 

Último

Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 

Último (20)

Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 

Quick & Easy Data Visualization with Google Visualization API + Google Chart Libraries

  • 1. Quick & Easy Data Visualization with Google Visualization API + Google Chart Libraries Bohyun Kim ( Twitter: @bohyunkim) Associate Director for Library Applications & Knowledge Systems University of Maryland, Baltimore Health Sciences & Human Services Library CODE4LIB Conference, Raleigh, NC. Mar. 25, 2014.
  • 2. 0. Spreadsheets Ain’t Databases. CIRC Newspaper holdings Textbook lists ACQ Newspaper holdings Textbook lists REF Newspaper holdings Textbook lists WEB Newspaper holdings Textbook lists
  • 3. Creating a web application with a database is not always a solution available, convenient, or efficient. Image from Flickr CreativeCommons http://www.flickr.com/photos/88575173@N00/2445955296/
  • 4. 1. But What If They Were … Almost? • Data Source <-- Google Spreadsheet • Query data <-- Google Visualization API Query Language • Display on the web <-- Google Chart Libraries
  • 5. 2. Google Visualization API Query Language • Allows you to perform various data manipulations with the query to the data source, such as Google spreadsheet, fusion table, or your own database. • Enables you to query the data source and visualize data with Google Chart Libraries • Similar to SQL https://developers.google.com/chart/interactive/docs/query language • Google Visualization API Reference: https://developers.google.com/chart/interactive/docs/refere nce
  • 7. URLs for a G Spreadsheet • In Google Spreadsheet – Sheet3 https://docs.google.com/spreadsheet/ccc?key=0AqAPbBT_k2VUdDc3aC1xS2o 0c2ZmaVpOQWkyY0l1eVE&usp=drive_web#gid=2 • HTML Table https://spreadsheets.google.com/tq?tqx=out:html&tq=&key=0AqAPbBT_k2VUd Dc3aC1xS2o0c2ZmaVpOQWkyY0l1eVE&gid=2 • Raw Data Response : includes a DataTable that you can retrieve by calling getDataTable() https://spreadsheets.google.com/tq?&tq=&key=0AqAPbBT_k2VUdDc3aC1xS2o0 c2ZmaVpOQWkyY0l1eVE&gid=2 • google.visualization.DataTable Classhttps://developers.google.com/chart/interactive/docs/reference#DataTabl e • Query Language Reference (Version 0.7)https://developers.google.com/chart/interactive/docs/querylanguage#Setti ng_the_Query_in_the_Data_Source_URL
  • 8. Raw Data response from G spreadsheet https://spreadsheets.google.com/tq?&tq=&key=0AqAPbBT_k2VUdDc3aC1xS2o0c2ZmaVpOQWkyY0l1eVE&gid=2
  • 9. Datatable from G spreadsheet
  • 10.
  • 11. 3-1. Query the Spreadsheet & Display the Result as a Web page • Step 1. Form a query : Show column B, C, D, F where C contains ‘Florida’ • Step 2. Output the query result As a stand-alone web page with a table (Needed: URL) OR Into your web page as a table / chart (Needed: JavaScript, G Chart Libraries)
  • 13. What Goes into the URL https://spreadsheets.google.com/ tq? tqx=out:html &tq=select B,C,D,F where (C contains 'Florida’) &key=0AqAPbBT_k2VUdEtXYXdLdjM0TXY1YUV hMk9jeUQ0NkE &gid=0 (optional for Sheet1)
  • 14. https://spreadsheets.google.com/tq?tqx=out:html&tq=select+B,C,D,F+where+%28C+co ntains+%27Florida%27%29&key=0AqAPbBT_k2VUdEtXYXdLdjM0TXY1YUVhMk9jeUQ0N kE Result of the query: SELECT B, C, D, F WHERE C CONTAINS ‘Florida’ N.B. Google Spreadsheet Size Limit: 400k cells, 256 columns, 20 MB https://support.google.com/drive/answer/2505921?hl=en
  • 16. SELECT D,F COUNT(C) WHERE (B CONTAINS ‘Agoulnik’) GROUP BY D, F https://spreadsheets.google.com/tq?tqx=out:html&tq=select+D,F,count(C)+where+%28B+ contains+%27Agoulnik%27%29+group+by+D,F&key=0AqAPbBT_k2VUdEtXYXdLdjM0TXY1Y UVhMk9jeUQ0NkE
  • 17. Query Options • Order by, Limit, Offset, Group By (), Pivot • Label, Format • avg(), max(), min() • count(), sum() • year(), month(), date(), hour() • minute(), second(), millisecond() • quarter(), dayOfWeek(), now(), dateDiff() • toDate(), upper(), lower() • https://developers.google.com/chart/interactive/ docs/querylanguage#Options
  • 18. PIVOT
  • 19. select sum(B) pivot C https://spreadsheets.google.com/tq?tqx=out:html&tq=select%20sum%28B%29%20pivo t%28C%29&key=0AqAPbBT_k2VUdHg4X08zMXFMeXRmdURJNUx5blpYUmc
  • 20. select c, sum(B) group by (C) https://spreadsheets.google.com/tq?tqx=out:html&tq=select%20C,sum%28B%29%20gr oup%20by%28C%29&key=0AqAPbBT_k2VUdHg4X08zMXFMeXRmdURJNUx5blpYUmc&g id=0
  • 21. select A, sum(B) group by A pivot C https://spreadsheets.google.com/tq?tqx=out:html&tq=select%20A,%20sum%28B%29%2 0group%20by%20A%20pivot%20C&key=0AqAPbBT_k2VUdHg4X08zMXFMeXRmdURJNUx 5blpYUmc&gid=0
  • 22. select C, sum(B) group by C pivot A https://spreadsheets.google.com/tq?tqx=out:html&tq=select%20C,%20sum%28B%29% 20group%20by%20C%20pivot%20A&key=0AqAPbBT_k2VUdHg4X08zMXFMeXRmdURJN Ux5blpYUmc&gid=0
  • 23. 3-2. Use JS instead of a URL • More flexible and you can add control options for users. • To set the query string from within JavaScript code, call the setQuery method of the google.visualization.Query class.
  • 24. Drop It into Your Own Web Page Query: SELECT B, C, D, F WHERE C contains ‘Florida’
  • 25. Parameters • headers=N - Specifies how many rows are header rows, where N is an integer zero or greater. These will be excluded from the data and assigned as column labels in the data table. If not specified, the spreadsheet will guess how many rows are header rows. • Range=NN:NN Example: range=A1:C6 • gid=N - Specifies which sheet in a multi-sheet document to link to, if you are not linking to the first sheet. N is the sheet's ID number. Example: gid=0 (for Sheet1) • sheet=sheet_name - Specifies which sheet in a multi-sheet document you are linking to, if you are not linking to the first sheet. sheet_name is the display name of the sheet. You can use the gid parameter instead of this parameter. Example: sheet=Sheet5
  • 26. 4. Visualize Your G Spreadsheet Data Using Google Chart Libraries The most common way to use Google Charts is with simple JavaScript that you embed in your web page. 1. You load some Google Chart libraries. 2. List the data to be charted. 3. Select options to customize your chart. 4. Create a chart object with an id that you choose. 5. Then, later in the web page, you create a <div> with that id to display the Google Chart. https://developers.google.com/chart/interactive/docs/
  • 27. Visualize as a table or a chart • To set the query string from within JavaScript code, call the setQuery method of the google.visualization.Query class. • 3 chart drawing techniques: • chart.draw() • ChartWrapper • DrawChart() • See also: https://developers.google.com/chart/interactive/docs/dra wing_charts
  • 28. (a) chart.draw() Process • Load the JSAPI, Google Visualization, and chart libraries. • Prepare your data. • Prepare any chart options. • Instantiate the chart class, passing in a handle to the page container element. • Optionally register to receive any chart events. If you intend to call methods on the chart, you should listen for the "ready" event. • Call chart.draw(), passing in the data and options. Advantages • You have complete control over every step of the process. • You can register to listen for all events thrown by the chart. Disadvantages • Verbose • You must explicitly load all required chart libraries • If you send queries, you must manually implement for the callback, check for success, extract the returned DataTable, and pass it to the chart.
  • 30.
  • 31. Separate the Query from URL
  • 33. example2_chartdraw.html Adapted from: Traci L. Ruthkoski, Google Visualization API Essentials, Packt, 2013.
  • 34. (b) chartwrapper ChartWrapper is a convenience class that handles loading all the appropriate chart libraries for you and also simplifies sending queries to Chart Tools Datasources. Advantages: • Much less code • Loads all the required chart libraries for you • Makes querying data sources much easier by creating the Query object and handling the callback for you • Pass in the container element ID, and it will call getElementByID for you. • Data can be submitted in a variety of formats: as an array of values, as a JSON literal string, or as a DataTable handle Disadvantages: • ChartWrapper currently propagates only the select, ready, and error events. To get other events, you must get a handle to the wrapped chart and subscribe to events there. See the ChartWrapper documentation for examples.
  • 36. Line chart - query: 'SELECT A,D WHERE D > 100 ORDER BY D', https://developers.google.com/chart/interactive/docs/drawing_charts#chart wrapper
  • 37. (c) Drawchart() DrawChart() is a global static method that wraps a ChartWrapper. Advantages: • Same as ChartWrapper, but slightly shorter to use. Disadvantages: • Does not return a handle to the wrapper, so you cannot handle any events.
  • 39.
  • 40. 5. Use Data from Your Own Database with Google Chart Libraries
  • 44. JSON Feed from G Spreadsheet https://spreadsheets.google.com/feeds/list/0AqAPbBT_k2VUdFgwUm5oeHNEajlhODJ oR2pVVWlTeFE/1/public/values?alt=json-in-script&callback=cb
  • 45. An Example MySQL db table Source for the PHP script on the next slide: http://stackoverflow.com/questions/12994282/php-mysql-google-chart-json- complete-example
  • 46. Construct G DataTable from MySQL db { "cols":[{"label":"Weekly Task","type":"string"},{"label":"Percentage","type":" number"}], "rows":[{"c":[{"v":"Sleep"},{"v":30}]},{"c":[{"v":"Watc hing Movie"},{"v":10}]},{"c":[{"v":"Job"},{"v":40}]},{"c":[{" v":"Exercise"},{"v":20}]}] }
  • 47.
  • 48.
  • 50. 6. Controls and Dashboards https://developers.google.com/chart/interactive/docs/gallery/controls
  • 51. Draw a Dashboard 1. Create An HTML Skeleton For Your Dashboard 2. Load Your Libraries 3. Prepare Your Data 4. Create a Dashboard Instance 5. Create Control and Chart Instances 6. Establish Dependencies (=bind) 7. Draw Your Dashboard 8. Programmatic Changes after Draw google.load('visualization', '1.0',{'packages':['controls']}); …. dashboard.bind(donutRangeSlider, pieChart); dashboard.draw(data); https://developers.google.com/chart/interactive/docs/gallery/controls
  • 53.
  • 54. Dashboard with multiple controls and a remote data source new google.visualization.Dashboard(document.getElementById('dashboard')) .bind([slider, categoryPicker], [pie, table]).draw(data);
  • 56.
  • 57.
  • 59. Google Public Data Explorer http://www.google.com/publicdata/directory
  • 60. Questions? • Slides: http://slideshare.net/bohyunkim • Code: https://github.com/bohyunkim/examples • Twitter: @bohyunkim • Web: http://bohyunkim.net/blog Image credit for the title slide: https://www.flickr.com/photos/44718928@N00/7219422352/ by the Flickr user @justgrimes

Notas del editor

  1. Cannot run a queryCannot display on the Web