InfoQ

News

Google Releases Chart API

Posted by Mark Little on Dec 07, 2007 09:46 AM

Community
SOA
Topics
Announcements
Tags
Google
The Google team announced the release of the Chart API for dynamically generating charts for embedding in Web pages. According to Steve Crossan:
We actually built this originally to use internally - we use it on Google Video and Google Finance for example. It seemed like it would be a good thing to open up to other users too.
Plus, this is an example of the output from the "20% time" Google offer to their developers!

The API is relatively straightforward to use. For example , this http://chart.apis.google.com/chart?cht=p3&chd=s:hW&chs=250x100&chl=InfoQ|Rocks creates a two segment, 3D pie-chart in png format. Trivial to then embed in an img tag. More complex pie charts are logical extensions of this approach. The current release supports quite a nice range of different chart types, including line charts, bar charts, Venn diagrams, scatter plots; plus other effects are supported. Not bad for an initial release that was done on the teams "off" time!

As the documentation illustrates, it is very simple to embed images within html as well as JavaScript:
var simpleEncoding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

function simpleEncode(values,maxValue) {

var chartData = ['s:'];
for (var i = 0; i < values.length; i++) {
var currentValue = values[i];
if (!isNaN(currentValue) && currentValue >= 0) {
chartData.push(simpleEncoding.charAt(Math.round((simpleEncoding.length-1) * currentValue / maxValue)));
}
else {
chartData.push('_');
}
}
return chartData.join('');
}
It's a nice, simple and yet powerful API that opens up some interesting possibilities. Being dynamic also means that there's potential for (relatively) real-time updates of information.

No comments

Watch Thread Reply

Educational Content

Bindings, Platforms, and Innovation

This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.

Orchestrating Long Running Activities with JBoss / JBPM

This article explores the use of JBoss and jBPM to implement design solutions that effectively address the issue of orchestrating long running activities.

Neo4j - The Benefits of Graph Databases

This presentation covers the use of graph databases as an optimal solution for data that is difficult to fit in static tables, rapidly evolving data or data that has a lot of optional attributes.

Realistic about Risk: Software development with Real Options

This session introduces Real Options and shows how it can help in running your project. Real Options is a decision-making process that can be used to manage risk.

Communication Flexibility Using Bindings

This article discusses the use of bindings on services and references (including the instance of non-configured bindings) as the means to implement SCA communications in a Web and SOA environment.

Writing DSLs in Groovy

After a short introduction to DSLs, Scott Davis plays with the keyboard showing how to approach the creation of a DSL by typing working snippets of Groovy code that get executed.

Scaling Agile with C/ALM (Collaborative Application Lifecycle Management)

IBM Rational and InfoQ present, Scaling Agile with C/ALM, an eBook showing organizations how to become “finely tuned software delivery machines” by enabling team integration and scaling.

Concurrent Programming with Microsoft F#

Amanda Laucher presents a real life enterprise application written in F#. She shows actual code snippets, explaining design decisions and suggesting how to use some of the F# constructs.