Google Charts API Ashwin Neurgaonkar 10/13/2008. What are APIs ? API stands for ‘Application...

9
Google Charts API Ashwin Neurgaonkar 10/13/2008

Transcript of Google Charts API Ashwin Neurgaonkar 10/13/2008. What are APIs ? API stands for ‘Application...

Page 1: Google Charts API Ashwin Neurgaonkar 10/13/2008. What are APIs ? API stands for ‘Application Programmable Interface’. As it’s name implies, it is an interface.

Google Charts API

Ashwin Neurgaonkar

10/13/2008

Page 2: Google Charts API Ashwin Neurgaonkar 10/13/2008. What are APIs ? API stands for ‘Application Programmable Interface’. As it’s name implies, it is an interface.

What are APIs ?• API stands for ‘Application Programmable

Interface’.

As it’s name implies, it is an interface that queries the Google database to help programmers in the development of their applications.

• Why use them ? Easy access to google`s services

Reduced overhead for developers

• Objective: To understand the basics of Google Charts API.

Page 3: Google Charts API Ashwin Neurgaonkar 10/13/2008. What are APIs ? API stands for ‘Application Programmable Interface’. As it’s name implies, it is an interface.

Basics: Google Chart API

• The URL

http://chart.apis.google.com/chart?<parameter 1>&<parameter 2>&<parameter n>

Refer http://code.google.com/apis/chart/#maps

• http://chart.apis.google.com/chart?chs=250x100 // chart size

&chd=t:60,40 // chart data

&cht=p3 // chart type

&chl=Hello|World // labels

http://chart.apis.google.com/chart?chs=300x150&chd=t:60,40&cht=p3&chl=Hello|World&chtt=This+is+so+cool!

Page 4: Google Charts API Ashwin Neurgaonkar 10/13/2008. What are APIs ? API stands for ‘Application Programmable Interface’. As it’s name implies, it is an interface.

Features

• Several types of charts. (pie/bar/sparklelines/Radar/Venn diagrams etc)

• Options like Range markers/solid fill/linear gradient/linear stripes/labels and legends make the charts look complete and definitive.

• Multiple types of Text encoding.

• Availability! google never fails …

Page 5: Google Charts API Ashwin Neurgaonkar 10/13/2008. What are APIs ? API stands for ‘Application Programmable Interface’. As it’s name implies, it is an interface.

Using API with PHP

• Open source libraries with ready classes available.

• Some useful links:

http://luddep.se/notebook/2008/04/13/charts-php-and-google-charts-api/

http://code.google.com/p/gchartphp/

Page 6: Google Charts API Ashwin Neurgaonkar 10/13/2008. What are APIs ? API stands for ‘Application Programmable Interface’. As it’s name implies, it is an interface.

sample

• <?php

$chart = new googChart();

$chart->setChartAttrs( array(

'type' => 'pie',

'data' => $data,

'size' => array( 300, 200 ) ));

echo $chart;

• <?php

$data = array(

'IE7' => 22,

'IE6' => 30.7,

'IE5' => 1.7,

'Firefox' => 36.5,

'Mozilla' => 1.1,

'Safari' => 2,

'Opera' => 1.4, );

Page 7: Google Charts API Ashwin Neurgaonkar 10/13/2008. What are APIs ? API stands for ‘Application Programmable Interface’. As it’s name implies, it is an interface.

Issues to consider

• Most readily available classes only implement a small subset of available google charts functions.

• Licensing may be a problem.

• Fixing bugs may consume too much time.

• Max size available is 300,000 pixels. i.e maximum sizes are 1000x300, 300x1000,

600x500, 500x600, 800x375, and 375x800.

Page 8: Google Charts API Ashwin Neurgaonkar 10/13/2008. What are APIs ? API stands for ‘Application Programmable Interface’. As it’s name implies, it is an interface.

Licensing

• Google APIs are NOT open source, but free to be used by developers. No licensing issues!

• Third party Implementations/libraries/classes for Google API maybe open source hence, licensing issues must be considered.

Page 9: Google Charts API Ashwin Neurgaonkar 10/13/2008. What are APIs ? API stands for ‘Application Programmable Interface’. As it’s name implies, it is an interface.

Some interesting uage

• Thematic mapping using google API http://themechanism.com/blog/2008/03/30/thematic-

mapping-with-the-google-charts-api-a-brief-tutorial/

• Generating charts from tables http://icant.co.uk/sandbox/datatable-to-chart/

• Using the Google Chart API with Microsoft Excel

http://www.tushar-mehta.com/publish_train/xl_vba_cases/excel_google_chart_api/index.htm