Last week, the news hit the blogosphere that Google had released a beta API for generating graphs using a reasonably easy and transparent GET parametrisation.
Inspired by this, and inspired by my early playing around with Ruby on Rails, I decided to whack together a Rails plugin that takes care of building the Google Charts IMG tag using what I hope is reasonably easy to use syntax.
I have a test-site using random data up for playing around with it.
The test-site as such runs on Ruby on Rails. The controller does some parsing and setting up of relevant arrays, and primarily generates random data for plotting.
The view has the following source code:
<p><% form_tag "" do %>
<%= select_tag "options[type]", options_for_select(@typeopts,@options["type"])
<%= text_field_tag "options[title]", @options["title"] %>
<%= select_tag "options[encoding]", options_for_select(@encopts,@options["encoding"]) %>
<%= hidden_field_tag "datalength", 3 %>
<%= hidden_field_tag "dslengthmin", 5 %>
<%= hidden_field_tag "dslengthmax", 50 %>
<%= hidden_field_tag "dsmin", 0 %>
<%= hidden_field_tag "dsmax", 10000 %>
<%= submit_tag %>
<% end %>
@options array is populated with the options tag from the input pretty straight off.
The whole plugin resides at a project of its own at rubyforge. So far, I have not yet implemented color handling, grid lines or marker setting. I’m happy to share code responsibility or getting suggestions for how to handle the outstanding issues or improve on the code. Just get in touch with me if you feel like contributing.