Pages

Friday, August 6, 2010

Googe Chart API

Recently I wanted to develop a tool that would show graphs on a web page. As I searched more and more, I began to understand that it was not easy as I though it would be.

I tried to display a bar chart using javascripts (cnxLABS). It worked fine, but then it was quite clumsy.
I stumbled upon JPGraph. These guys support so many different types of charts. Quite handy and easy to include it in your code. Rendering doesn't look sharp though.

PChart just looked cool on the site, but i was not able to include it in my project and run it. I just got too many errors. If any one out there was able to use it successfully in your project, please let me know :)



Finally, I decided to use Google Chart API. Simply awesome. Easy to include in your project and the rendering is just smooth and pleasing. The disadvantage, though, is you need to be connected to the internet to display charts in your web page. This will not be acceptable in certain cases. The Google Code Playground makes your easier in building charts. Most of the charts are interactive, which makes the experience better.




Sample code to display a pie chart

function drawVisualization() 
{
// Create and populate the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Task');
data.addColumn('number', 'Hours per Day');
data.addRows(5);
data.setValue(0, 0, 'Work');
data.setValue(0, 1, 11);
data.setValue(1, 0, 'Eat');
data.setValue(1, 1, 2);
data.setValue(2, 0, 'Commute');
data.setValue(2, 1, 2);
data.setValue(3, 0, 'Watch TV');
data.setValue(3, 1, 2);
data.setValue(4, 0, 'Sleep');
data.setValue(4, 1, 7);

// Create and draw the visualization.
new google.visualization.PieChart(document.getElementById('visualization')).
draw(data, {title:"So, how was your day?"});
}

Happy Charting :)

4 comments:

ninest123 said...

moncler, moncler, pandora jewelry, pandora jewelry, marc jacobs, ugg,ugg australia,ugg italia, sac louis vuitton pas cher, canada goose, moncler outlet, pandora charms, canada goose outlet, bottes ugg, moncler, canada goose uk, replica watches, hollister, louis vuitton, louis vuitton, swarovski, moncler, swarovski crystal, links of london, ugg boots uk, moncler, louis vuitton, doudoune canada goose, ugg pas cher, coach outlet, louis vuitton, moncler, canada goose, canada goose outlet, canada goose, thomas sabo, canada goose, pandora charms, ugg,uggs,uggs canada, wedding dresses, moncler

ninest123 said...

timberland boots, soccer shoes, nike roshe, asics running shoes, oakley, juicy couture outlet, beats by dre, new balance, jimmy choo shoes, vans, north face outlet, instyler, mcm handbags, abercrombie and fitch, baseball bats, hollister, karen millen, gucci, lancel, bottega veneta, valentino shoes, louboutin, reebok shoes, north face outlet, converse outlet, hollister, herve leger, juicy couture outlet, ralph lauren, ferragamo shoes, insanity workout, ghd, nike air max, mont blanc, chi flat iron, nfl jerseys, toms shoes, supra shoes, mac cosmetics, converse, babyliss, wedding dresses, celine handbags, ray ban, vans shoes, nike air max, montre pas cher, soccer jerseys, p90x workout, birkin bag

ninest123 said...

vans pas cher, michael kors outlet, mulberry, michael kors, sac guess, new balance pas cher, ugg boots, nike air max, true religion outlet, hogan, true religion jeans, burberry, hollister, hollister, oakley pas cher, true religion jeans, coach purses, michael kors outlet, timberland, ray ban uk, converse pas cher, north face, burberry outlet online, longchamp, michael kors, nike huarache, michael kors outlet, tn pas cher, ray ban pas cher, michael kors outlet, michael kors outlet, hermes, air force, lululemon, nike blazer, lacoste pas cher, michael kors, nike trainers, ralph lauren uk, nike air max, nike roshe, nike air max, michael kors, north face, vanessa bruno, ugg boots, true religion jeans, hollister pas cher, nike free run uk, abercrombie and fitch

ninest123 said...

louboutin pas cher, nike air max, ray ban sunglasses, prada handbags, michael kors, coach outlet, coach outlet, nike free, replica watches, kate spade outlet, uggs on sale, louboutin shoes, longchamp outlet, longchamp, burberry, polo ralph lauren outlet, tory burch outlet, nike air max, louboutin, ralph lauren pas cher, louis vuitton, christian louboutin outlet, chanel handbags, prada outlet, tiffany jewelry, ray ban sunglasses, kate spade handbags, sac longchamp, nike outlet, air max, gucci outlet, air jordan pas cher, louboutin outlet, nike roshe run, replica watches, nike free, longchamp pas cher, jordan shoes, polo ralph lauren outlet, tiffany and co, cheap oakley sunglasses, ray ban sunglasses, oakley sunglasses, ugg boots, replica handbags, longchamp outlet, ugg boots