Activate your free membership today | Log-in

Monday, October 29th, 2007

GChart: GWT charts without JSNI, plugins, or server round-trips

Category: GWT, Java, JavaScript, Library

John C. Gunther is building a technical computing application that generates all of the data that it charts via client-side computations. He didn't want to create the charts on the server side, and decided to use GWT to do the work for him.

This is how he created GChart.

To see it at work, check out the chart gallery that has examples such as:

JAVASCRIPT:
  1.  
  2. package com.googlecode.gchartdemo.client;
  3. import com.googlecode.gchart.client.GChart;
  4. /**
  5. * Defines a scatter-plot of x*x vs. x.
  6. */
  7. public class GChartExample00 extends GChart {
  8.   GChartExample00() {
  9.      setChartTitle("<b>x<sup>2</sup> vs x</b>");
  10.      setChartSize(150, 150);
  11.      addCurve();
  12.      for (int i = 0; i <10; i++)
  13.        getCurve().addPoint(i,i*i);
  14.      getCurve().setLegendLabel("x<sup>2");
  15.      getXAxis().setAxisLabel("x");
  16.      getYAxis().setAxisLabel("x<sup>2</sup>");
  17.      update();
  18.   }
  19. }
  20.  

Which creates:

For other graphing needs check out Plotkit and Dojo Charting.

Posted by Dion Almaer at 10:51 am

+++--
3.8 rating from 23 votes

2 Comments »

Comments feed TrackBack URI

Hey Dion,

Thanks for the link to dojo.charting. For those who are wondering about Dojo charting on the 0.9+ versions, here’s a peek at the awesome work Eugene Lazutkin has been cooking up for 1.0:

http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/charting/tests/

Regards

Comment by Alex Russell — October 29, 2007

Thanks for the article–GChart got more visits from Ajaxian than from any other site!

As Tahir
Akhtar pointed out
on the GWT forum, GChart’s site
originally lacked a live demo. No longer. Click on the
bar chart image on GChart’s home page
to open it up into a real-live GChart.

Comment by John Gunther — November 3, 2007

Leave a comment

You must be logged in to post a comment.