SlideShare a Scribd company logo
1 of 26
Introduction to the Google Visualization API Jason Young, NC State University June 8, 2009
What's all this about? Visualization, API, Google, Introduction
Visualization For now, let's just say that's a Fancy word for "graph"
Our Example Visualization Ooooooh, a Live Demo!
Application  Programming  Interface i.e. Why use excel when you can spend 100s of hours coding the very same thing?
<?php      $title = &quot;Time Jason Spent Preparing For This Presentation&quot;;      $width = 800;      $height = 600;      $diameter = 400;      $center_xpos = 300;      $center_ypos = 300;      $width_label = 10;           $data_values = array(80,10,10);      $data_labels = array(&quot;Joking about it on twitter&quot;,&quot;Writing code&quot;,&quot;Presenting to my dogs&quot;);           $mygraph = ImageCreate( $width, $height );           $color[] = ImageColorAllocate( $mygraph, 255, 102, 102 ); //red      $color[] = ImageColorAllocate( $mygraph, 102, 255, 102 ); //green      $color[] = ImageColorAllocate( $mygraph, 102, 102, 255 ); //blue      $white = ImageColorAllocate( $mygraph, 255, 255, 255 );      $black = ImageColorAllocate( $mygraph, 0, 0, 0 );      ImageFill( $mygraph, 0, 0, $white );           $slice_current = 0;      for( $i = 0; $i < count( $data_values ); $i++ ) {          $slice_start = round( $slice_current );          $slice_current += ( $data_values[ $i ] / 100 ) * 360;          $slice_end = round( $slice_current );                   $slice_color = $color[$i];                   ImageArc( $mygraph, $center_xpos, $center_ypos, $diameter, $diameter, $slice_start, $slice_current, $slice_color );                   # start          $arc_xpos = cos(deg2rad($slice_start)) * ($diameter / 2);          $arc_ypos = sin(deg2rad($slice_start)) * ($diameter / 2);          ImageLine( $mygraph, $center_xpos, $center_ypos, floor( $center_xpos + $arc_xpos ), floor( $center_ypos + $arc_ypos ), $slice_color );                   # end          $arc_xpos = cos(deg2rad($slice_end)) * ($diameter / 2);          $arc_ypos = sin(deg2rad($slice_end)) * ($diameter / 2);          ImageLine( $mygraph, $center_xpos, $center_ypos, ceil( $center_xpos + $arc_xpos ), ceil( $center_ypos + $arc_ypos ), $slice_color );                   # fill          $slice_mid = round( ( ( $slice_end - $slice_start ) / 2 ) + $slice_start );          $arc_xpos = cos(deg2rad($slice_mid)) * ($diameter / 3);          $arc_ypos = sin(deg2rad($slice_mid)) * ($diameter / 3);          ImageFillToBorder( $mygraph, floor( $center_xpos + $arc_xpos ), floor( $center_ypos + $arc_ypos ), $slice_color, $slice_color );      }           $label_xpos = $center_xpos + $diameter / 2 + 10;      $label_ypos = $center_ypos - $diameter / 4;      $title_xpos = $center_xpos - $diameter / 4;      $title_ypos = 0; #$center_ypos - $diameter / 2;      ImageString( $mygraph, 15, $title_xpos, $title_ypos, $title, $black );           for( $i = 0; $i < count( $data_labels ); $i++ ) {          $label_color = $color[$i];          ImageFilledRectangle( $mygraph, $label_xpos + 1, $label_ypos + 1, $label_xpos + $width_label, $label_ypos + $width_label, $label_color );          ImageString( $mygraph, 10, $label_xpos + $width_label + 5, $label_ypos, $data_labels[ $i ], $black );          ImageString( $mygraph, 10, $label_xpos + $width_label + 250, $label_ypos, $data_values[ $i ], $black );          $label_ypos += $width_label + 2;      }           ImageString( $mygraph, 11, $label_xpos, $label_ypos, &quot;Total:&quot;, $black );      ImageString( $mygraph, 11, $label_xpos + $width_label + 250, $label_ypos, 100, $black );      Header( &quot;Content-type: image/PNG&quot; );      ImagePNG( $mygraph );      ImageDestroy( $mygraph );      ?>
$title  = &quot;Time Jason Spent Preparing For This Presentation&quot;; $data_values  =  array (80,10,10); $data_labels  =  array (&quot;Joking about it on twitter&quot;, &quot;Writing code&quot;,&quot;Presenting to my dogs&quot;); $mygraph  =  ImageCreate (  $width ,  $height  ); $color[]  =  ImageColorAllocate (  $mygraph , 255, 102, 102 ); [...]  ImageArc (  $mygraph ,  $center_xpos ,  $center_ypos ,  $diameter ,  $diameter ,  $slice_start ,  $slice_current ,  $slice_color  ); [...] ImageLine (  $mygraph ,  $center_xpos ,  $center_ypos ,  floor (  $center_xpos  +  $arc_xpos  ),  floor (  $center_ypos  +  $arc_ypos  ),  $slice_color  ); [...] Header ( &quot;Content-type: image/PNG&quot; ); ImagePNG (  $mygraph  );
 
Story Time
Google http://code.google.com/apis/visualization/
OMG!  It's Javascript?!?
Introduction finally!
<html>   <head>     <!--Load the AJAX API-->     <script type=&quot;text/javascript&quot; src=&quot;http://www.google.com/jsapi&quot;></script>     <script type=&quot;text/javascript&quot;>            // Load the Visualization API and the piechart package.       google.load('visualization', '1', {'packages':['piechart']});              // Set a callback to run when the API is loaded.       google.setOnLoadCallback(drawChart);              // Callback that creates and populates a data table, instantiates the pie chart, passes in the data and draws it.       function drawChart() {         var data = new google.visualization.DataTable();         data.addColumn('string', 'Activity');         data.addColumn('number', 'Percentage of Time Spent');         data.addRows(3);         data.setValue(0, 0, 'Joking about it on twitter');         data.setValue(0, 1, 80);         data.setValue(1, 0, 'Writing code');         data.setValue(1, 1, 10);         data.setValue(2, 0, 'Presenting to my dogs');         data.setValue(2, 1, 10);         var chart = new google.visualization.PieChart(document.getElementById('chart_div'));         chart.draw(data, {width: 800, height: 600, is3D: true, title: 'Time Jason Spent Preparing For This Presentation'});       }     </script>   </head>   <body>     <!--Div that will hold the pie chart-->     <div id=&quot;chart_div&quot;></div>   </body> </html>
Codexploration ,[object Object],[object Object],[object Object],[object Object],[object Object]
Codexploration ,[object Object],[object Object]
Codexploration ,[object Object],[object Object],[object Object]
Codexploration ,[object Object]
JavaScript Object Notation (JSON) ,[object Object],[object Object]
A Live example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
<html> <head>     <meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;/>     <title>Hourly Activity - eXtension People</title>     <script type=&quot;text/javascript&quot; src=&quot;http://www.google.com/jsapi&quot;></script>     <script type=&quot;text/javascript&quot;>       google.load(&quot;visualization&quot;, &quot;1&quot;, {packages:[&quot;columnchart&quot;]});              google.setOnLoadCallback(queryData);          function queryData() {       var query = new google.visualization.Query('https://people.extension.org/data/activitytable?activity=aaeresolve&tz=US%2FEastern');       query.send(handleQueryResponse);     }    function handleQueryResponse(response) {       if (response.isError()) {         alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());         return;       }       var data = response.getDataTable();     var chart = new google.visualization.ColumnChart(document.getElementById('visualization_chart'));     chart.draw(data, {width: 800, height: 480, legend: 'bottom', title: ''});   } </script> </head>      <body>             <h1>Hourly Activity</h1> <div id=&quot;visualization_chart&quot;></div> </body> </html>
Codexploration ,[object Object]
Codexploration ,[object Object],[object Object],[object Object]
 
iGoogle  
More... putting the visualization back into &quot;graph&quot;
Questions? finally. No, really.

More Related Content

What's hot

Why Hacking WordPress Search Isn't Some Big Scary Thing
Why Hacking WordPress Search Isn't Some Big Scary ThingWhy Hacking WordPress Search Isn't Some Big Scary Thing
Why Hacking WordPress Search Isn't Some Big Scary ThingChris Reynolds
 
Fields in Core: How to create a custom field
Fields in Core: How to create a custom fieldFields in Core: How to create a custom field
Fields in Core: How to create a custom fieldIvan Zugec
 
Wynn Netherland: Accelerating Titanium Development with CoffeeScript, Compass...
Wynn Netherland: Accelerating Titanium Development with CoffeeScript, Compass...Wynn Netherland: Accelerating Titanium Development with CoffeeScript, Compass...
Wynn Netherland: Accelerating Titanium Development with CoffeeScript, Compass...Axway Appcelerator
 
The Art of Transduction
The Art of TransductionThe Art of Transduction
The Art of TransductionDavid Stockton
 
Comparing 30 MongoDB operations with Oracle SQL statements
Comparing 30 MongoDB operations with Oracle SQL statementsComparing 30 MongoDB operations with Oracle SQL statements
Comparing 30 MongoDB operations with Oracle SQL statementsLucas Jellema
 
Gareth hayes. non alphanumeric javascript-php and shared fuzzing
Gareth hayes. non alphanumeric javascript-php and shared fuzzingGareth hayes. non alphanumeric javascript-php and shared fuzzing
Gareth hayes. non alphanumeric javascript-php and shared fuzzingYury Chemerkin
 
Everything you always wanted to know about forms* *but were afraid to ask
Everything you always wanted to know about forms* *but were afraid to askEverything you always wanted to know about forms* *but were afraid to ask
Everything you always wanted to know about forms* *but were afraid to askAndrea Giuliano
 
Coding Horrors
Coding HorrorsCoding Horrors
Coding HorrorsMark Baker
 
Using a mobile phone as a therapist - Superweek 2018
Using a mobile phone as a therapist - Superweek 2018Using a mobile phone as a therapist - Superweek 2018
Using a mobile phone as a therapist - Superweek 2018Peter Meyer
 
Javascript & jQuery: A pragmatic introduction
Javascript & jQuery: A pragmatic introductionJavascript & jQuery: A pragmatic introduction
Javascript & jQuery: A pragmatic introductionIban Martinez
 
Extending Moose
Extending MooseExtending Moose
Extending Moosesartak
 
PHP webboard
PHP webboardPHP webboard
PHP webboardtumetr1
 
Code moi une RH! (PHP tour 2017)
Code moi une RH! (PHP tour 2017)Code moi une RH! (PHP tour 2017)
Code moi une RH! (PHP tour 2017)Arnaud Langlade
 
Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Kris Wallsmith
 
PHP cart
PHP cartPHP cart
PHP carttumetr1
 
WordPress 3.1 at DC PHP
WordPress 3.1 at DC PHPWordPress 3.1 at DC PHP
WordPress 3.1 at DC PHPandrewnacin
 
HTML5 and CSS3 Refresher
HTML5 and CSS3 RefresherHTML5 and CSS3 Refresher
HTML5 and CSS3 RefresherIvano Malavolta
 

What's hot (20)

Why Hacking WordPress Search Isn't Some Big Scary Thing
Why Hacking WordPress Search Isn't Some Big Scary ThingWhy Hacking WordPress Search Isn't Some Big Scary Thing
Why Hacking WordPress Search Isn't Some Big Scary Thing
 
Fields in Core: How to create a custom field
Fields in Core: How to create a custom fieldFields in Core: How to create a custom field
Fields in Core: How to create a custom field
 
Wynn Netherland: Accelerating Titanium Development with CoffeeScript, Compass...
Wynn Netherland: Accelerating Titanium Development with CoffeeScript, Compass...Wynn Netherland: Accelerating Titanium Development with CoffeeScript, Compass...
Wynn Netherland: Accelerating Titanium Development with CoffeeScript, Compass...
 
The Art of Transduction
The Art of TransductionThe Art of Transduction
The Art of Transduction
 
Comparing 30 MongoDB operations with Oracle SQL statements
Comparing 30 MongoDB operations with Oracle SQL statementsComparing 30 MongoDB operations with Oracle SQL statements
Comparing 30 MongoDB operations with Oracle SQL statements
 
Gareth hayes. non alphanumeric javascript-php and shared fuzzing
Gareth hayes. non alphanumeric javascript-php and shared fuzzingGareth hayes. non alphanumeric javascript-php and shared fuzzing
Gareth hayes. non alphanumeric javascript-php and shared fuzzing
 
SVGo workshop
SVGo workshopSVGo workshop
SVGo workshop
 
Everything you always wanted to know about forms* *but were afraid to ask
Everything you always wanted to know about forms* *but were afraid to askEverything you always wanted to know about forms* *but were afraid to ask
Everything you always wanted to know about forms* *but were afraid to ask
 
Coding Horrors
Coding HorrorsCoding Horrors
Coding Horrors
 
Using a mobile phone as a therapist - Superweek 2018
Using a mobile phone as a therapist - Superweek 2018Using a mobile phone as a therapist - Superweek 2018
Using a mobile phone as a therapist - Superweek 2018
 
Javascript & jQuery: A pragmatic introduction
Javascript & jQuery: A pragmatic introductionJavascript & jQuery: A pragmatic introduction
Javascript & jQuery: A pragmatic introduction
 
Extending Moose
Extending MooseExtending Moose
Extending Moose
 
Emmet cheat-sheet
Emmet cheat-sheetEmmet cheat-sheet
Emmet cheat-sheet
 
PHP webboard
PHP webboardPHP webboard
PHP webboard
 
Code moi une RH! (PHP tour 2017)
Code moi une RH! (PHP tour 2017)Code moi une RH! (PHP tour 2017)
Code moi une RH! (PHP tour 2017)
 
Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)
 
PHP cart
PHP cartPHP cart
PHP cart
 
WordPress 3.1 at DC PHP
WordPress 3.1 at DC PHPWordPress 3.1 at DC PHP
WordPress 3.1 at DC PHP
 
HTML5 and CSS3 Refresher
HTML5 and CSS3 RefresherHTML5 and CSS3 Refresher
HTML5 and CSS3 Refresher
 
#ThisIsHappening
#ThisIsHappening#ThisIsHappening
#ThisIsHappening
 

Similar to Google Visualization API

Drupal Lightning FAPI Jumpstart
Drupal Lightning FAPI JumpstartDrupal Lightning FAPI Jumpstart
Drupal Lightning FAPI Jumpstartguestfd47e4c7
 
Drupal Development (Part 2)
Drupal Development (Part 2)Drupal Development (Part 2)
Drupal Development (Part 2)Jeff Eaton
 
Perl使いの国のRubyist
Perl使いの国のRubyistPerl使いの国のRubyist
Perl使いの国のRubyistTakafumi ONAKA
 
Oh, you’re the NY times guy
Oh, you’re the NY times guyOh, you’re the NY times guy
Oh, you’re the NY times guyDavid Hayes
 
Exploiting Php With Php
Exploiting Php With PhpExploiting Php With Php
Exploiting Php With PhpJeremy Coates
 
Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB jhchabran
 
Graph Databases
Graph DatabasesGraph Databases
Graph DatabasesJosh Adell
 
Scripting GeoServer with GeoScript
Scripting GeoServer with GeoScriptScripting GeoServer with GeoScript
Scripting GeoServer with GeoScriptJustin Deoliveira
 
London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)Dennis Knochenwefel
 
php global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdf
php global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdfphp global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdf
php global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdfanjalitimecenter11
 
jQuery - Doing it right
jQuery - Doing it rightjQuery - Doing it right
jQuery - Doing it rightgirish82
 

Similar to Google Visualization API (20)

Drupal Lightning FAPI Jumpstart
Drupal Lightning FAPI JumpstartDrupal Lightning FAPI Jumpstart
Drupal Lightning FAPI Jumpstart
 
JQuery Basics
JQuery BasicsJQuery Basics
JQuery Basics
 
Jquery
JqueryJquery
Jquery
 
Drupal Development (Part 2)
Drupal Development (Part 2)Drupal Development (Part 2)
Drupal Development (Part 2)
 
Perl使いの国のRubyist
Perl使いの国のRubyistPerl使いの国のRubyist
Perl使いの国のRubyist
 
Oh, you’re the NY times guy
Oh, you’re the NY times guyOh, you’re the NY times guy
Oh, you’re the NY times guy
 
Views notwithstanding
Views notwithstandingViews notwithstanding
Views notwithstanding
 
Exploiting Php With Php
Exploiting Php With PhpExploiting Php With Php
Exploiting Php With Php
 
Faking Data
Faking DataFaking Data
Faking Data
 
Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB
 
Convidar para page !!
Convidar para page !!Convidar para page !!
Convidar para page !!
 
Graph Databases
Graph DatabasesGraph Databases
Graph Databases
 
Theme verdadeiro
Theme verdadeiroTheme verdadeiro
Theme verdadeiro
 
Database api
Database apiDatabase api
Database api
 
Wp meetup custom post types
Wp meetup custom post typesWp meetup custom post types
Wp meetup custom post types
 
Scripting GeoServer with GeoScript
Scripting GeoServer with GeoScriptScripting GeoServer with GeoScript
Scripting GeoServer with GeoScript
 
Php
PhpPhp
Php
 
London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)
 
php global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdf
php global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdfphp global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdf
php global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdf
 
jQuery - Doing it right
jQuery - Doing it rightjQuery - Doing it right
jQuery - Doing it right
 

Recently uploaded

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 

Recently uploaded (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 

Google Visualization API

  • 1. Introduction to the Google Visualization API Jason Young, NC State University June 8, 2009
  • 2. What's all this about? Visualization, API, Google, Introduction
  • 3. Visualization For now, let's just say that's a Fancy word for &quot;graph&quot;
  • 4. Our Example Visualization Ooooooh, a Live Demo!
  • 5. Application Programming  Interface i.e. Why use excel when you can spend 100s of hours coding the very same thing?
  • 6. <?php      $title = &quot;Time Jason Spent Preparing For This Presentation&quot;;      $width = 800;      $height = 600;      $diameter = 400;      $center_xpos = 300;      $center_ypos = 300;      $width_label = 10;           $data_values = array(80,10,10);      $data_labels = array(&quot;Joking about it on twitter&quot;,&quot;Writing code&quot;,&quot;Presenting to my dogs&quot;);           $mygraph = ImageCreate( $width, $height );           $color[] = ImageColorAllocate( $mygraph, 255, 102, 102 ); //red      $color[] = ImageColorAllocate( $mygraph, 102, 255, 102 ); //green      $color[] = ImageColorAllocate( $mygraph, 102, 102, 255 ); //blue      $white = ImageColorAllocate( $mygraph, 255, 255, 255 );      $black = ImageColorAllocate( $mygraph, 0, 0, 0 );      ImageFill( $mygraph, 0, 0, $white );           $slice_current = 0;      for( $i = 0; $i < count( $data_values ); $i++ ) {          $slice_start = round( $slice_current );          $slice_current += ( $data_values[ $i ] / 100 ) * 360;          $slice_end = round( $slice_current );                   $slice_color = $color[$i];                   ImageArc( $mygraph, $center_xpos, $center_ypos, $diameter, $diameter, $slice_start, $slice_current, $slice_color );                   # start          $arc_xpos = cos(deg2rad($slice_start)) * ($diameter / 2);          $arc_ypos = sin(deg2rad($slice_start)) * ($diameter / 2);          ImageLine( $mygraph, $center_xpos, $center_ypos, floor( $center_xpos + $arc_xpos ), floor( $center_ypos + $arc_ypos ), $slice_color );                   # end          $arc_xpos = cos(deg2rad($slice_end)) * ($diameter / 2);          $arc_ypos = sin(deg2rad($slice_end)) * ($diameter / 2);          ImageLine( $mygraph, $center_xpos, $center_ypos, ceil( $center_xpos + $arc_xpos ), ceil( $center_ypos + $arc_ypos ), $slice_color );                   # fill          $slice_mid = round( ( ( $slice_end - $slice_start ) / 2 ) + $slice_start );          $arc_xpos = cos(deg2rad($slice_mid)) * ($diameter / 3);          $arc_ypos = sin(deg2rad($slice_mid)) * ($diameter / 3);          ImageFillToBorder( $mygraph, floor( $center_xpos + $arc_xpos ), floor( $center_ypos + $arc_ypos ), $slice_color, $slice_color );      }           $label_xpos = $center_xpos + $diameter / 2 + 10;      $label_ypos = $center_ypos - $diameter / 4;      $title_xpos = $center_xpos - $diameter / 4;      $title_ypos = 0; #$center_ypos - $diameter / 2;      ImageString( $mygraph, 15, $title_xpos, $title_ypos, $title, $black );           for( $i = 0; $i < count( $data_labels ); $i++ ) {          $label_color = $color[$i];          ImageFilledRectangle( $mygraph, $label_xpos + 1, $label_ypos + 1, $label_xpos + $width_label, $label_ypos + $width_label, $label_color );          ImageString( $mygraph, 10, $label_xpos + $width_label + 5, $label_ypos, $data_labels[ $i ], $black );          ImageString( $mygraph, 10, $label_xpos + $width_label + 250, $label_ypos, $data_values[ $i ], $black );          $label_ypos += $width_label + 2;      }           ImageString( $mygraph, 11, $label_xpos, $label_ypos, &quot;Total:&quot;, $black );      ImageString( $mygraph, 11, $label_xpos + $width_label + 250, $label_ypos, 100, $black );      Header( &quot;Content-type: image/PNG&quot; );      ImagePNG( $mygraph );      ImageDestroy( $mygraph );      ?>
  • 7. $title = &quot;Time Jason Spent Preparing For This Presentation&quot;; $data_values = array (80,10,10); $data_labels = array (&quot;Joking about it on twitter&quot;, &quot;Writing code&quot;,&quot;Presenting to my dogs&quot;); $mygraph = ImageCreate ( $width , $height ); $color[] = ImageColorAllocate ( $mygraph , 255, 102, 102 ); [...]  ImageArc ( $mygraph , $center_xpos , $center_ypos , $diameter , $diameter , $slice_start , $slice_current ,  $slice_color ); [...] ImageLine ( $mygraph , $center_xpos , $center_ypos ,  floor ( $center_xpos + $arc_xpos ),  floor ( $center_ypos + $arc_ypos ), $slice_color ); [...] Header ( &quot;Content-type: image/PNG&quot; ); ImagePNG ( $mygraph );
  • 8.  
  • 13. <html>   <head>     <!--Load the AJAX API-->     <script type=&quot;text/javascript&quot; src=&quot;http://www.google.com/jsapi&quot;></script>     <script type=&quot;text/javascript&quot;>           // Load the Visualization API and the piechart package.       google.load('visualization', '1', {'packages':['piechart']});             // Set a callback to run when the API is loaded.       google.setOnLoadCallback(drawChart);             // Callback that creates and populates a data table, instantiates the pie chart, passes in the data and draws it.       function drawChart() {         var data = new google.visualization.DataTable();         data.addColumn('string', 'Activity');         data.addColumn('number', 'Percentage of Time Spent');         data.addRows(3);         data.setValue(0, 0, 'Joking about it on twitter');         data.setValue(0, 1, 80);         data.setValue(1, 0, 'Writing code');         data.setValue(1, 1, 10);         data.setValue(2, 0, 'Presenting to my dogs');         data.setValue(2, 1, 10);         var chart = new google.visualization.PieChart(document.getElementById('chart_div'));         chart.draw(data, {width: 800, height: 600, is3D: true, title: 'Time Jason Spent Preparing For This Presentation'});       }     </script>   </head>   <body>     <!--Div that will hold the pie chart-->     <div id=&quot;chart_div&quot;></div>   </body> </html>
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20. <html> <head>     <meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;/>     <title>Hourly Activity - eXtension People</title>     <script type=&quot;text/javascript&quot; src=&quot;http://www.google.com/jsapi&quot;></script>     <script type=&quot;text/javascript&quot;>       google.load(&quot;visualization&quot;, &quot;1&quot;, {packages:[&quot;columnchart&quot;]});             google.setOnLoadCallback(queryData);         function queryData() {       var query = new google.visualization.Query('https://people.extension.org/data/activitytable?activity=aaeresolve&tz=US%2FEastern');       query.send(handleQueryResponse);     }   function handleQueryResponse(response) {       if (response.isError()) {         alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());         return;       }       var data = response.getDataTable();     var chart = new google.visualization.ColumnChart(document.getElementById('visualization_chart'));     chart.draw(data, {width: 800, height: 480, legend: 'bottom', title: ''});   } </script> </head>     <body>            <h1>Hourly Activity</h1> <div id=&quot;visualization_chart&quot;></div> </body> </html>
  • 21.
  • 22.
  • 23.  
  • 25. More... putting the visualization back into &quot;graph&quot;