Google Charts API rails plugin
I bundled the code from the previous post into a plugin, called Chartr. This makes it easy to create graphs within rails.
Here's how to use it.
First, install the plugin. (It's probably a good idea to install it with '-x' since it's likely to be updated. Also, I should mention that this is my first plugin.)
ruby script/plugin install -x svn://syvera.com/plugins/chartr
Right, so now we need to graph something. You can put a graph into any page, but let's create a page that definitely deserves a graph:
ruby script/generate controller graphs index
This gives you an index.html.erb page where you can put your graph. In that page, we're going to use Chartr to give us a random graph. This is the code:
<%= Chartr.make_simple_line_chart Array.new(5) {|i| rand(10)},
['one', 'two', 'three', 'four', 'five'],
'stuff to graph' %>
So that's going to give you a graph like this:
Sure, that's cool. But what the heck were those arguments?
The first one is for your values:
Array.new(5) {|i| rand(10)} # returns an array of 5 random values between 0 and 9
The second, also an array, is for the legend. No explanation needed for that. The last is for the html 'alt' tag.
You could provide a fourth one for the size of the graph. If not, the default is 200x100.
Cape Town Events: zalist
A friend wanted to set up a site for gigs going on in Cape Town. A site where regular folk could consult to figure out who was playing where on a given night, and where musicians or bars could list gigs and events.
I wrote zalist.co.za up to show him how it could be done in rails.
Ingredients: postgres, rails.
Cotswold Guesthouse
That site's at cotswold.co.za.
We wanted to create a guest house site with the text in various languages.
Since the people who were going to translate the site from english into [French|Italian|German] were going to be 'geographically distributed', and not likely available at the same time, I thought it would be too complex to coordinate all those translations and the updating of the site. Creating the site in rails as a CMS was the easiest way to deal with it. When someone is ready to add or translate text, they can login and do so.
Basic Ingredients: Rails and postgres, along with the globalize, file_column and exception_notification plugin.
