Producing Charts in Open Wonderland

November 1, 2011

One of the challenges of the +Spaces project is to provide our users with charts of the results from their participation in polls, debates and so on. In Wonderland, one way of doing this would be to create from scratch a new 2D Swing Cell that employs an existing open source Java library such as JFreeChart. This library seems to provide all the charts we need, including pie charts and bar charts.

However, instead of starting from scratch it’s always easier to steal someone else’s ideas “stand on the shoulders of giants.” The “giants” in this case are Google, and their Chart API. The API returns a chart image in response to a URL GET or POST request, where the URL contains all the information about the chart you want, including its data, size and colours. By using such a URL in the HTML of a Poster cell, we can now easily create charts in Wonderland.

For example, here is a very brief video of creating a poster to display the example chart that Google provides.

The advantage of this approach over the Swing approach is flexibility: using a Poster means that we can embed a Chart in other text, and update the Poster programmatically or from the web.

(The modules employed in the video were the new Poster and the Web-based Poster Manager.)


%d bloggers like this: