winston/google_visualr — pull request #65 by ghiculescu (2013-11-14 01:40:17+00:00)
Title: Add interactive Timeline chart

Add support for Google's Timeline chart: https://developers.google.com/chart/interactive/docs/gallery/timeline

Note that the first two commits, [1](https://github.com/ghiculescu/google_visualr/commit/510312f69837e775ef8700b1b9596c5c4d032f63) [2](https://github.com/ghiculescu/google_visualr/commit/eca255e1a45d9369cee1fab115124c56f7209729), are fixes for https://github.com/winston/google_visualr/pull/64 - I merged them in here so I could work off my branch before this is merged into the gem. The interesting stuff is in [this commit](https://github.com/ghiculescu/google_visualr/commit/793ceee373ae1ae5e2f0d1fec16faadb1c132ff9).

The Timeline chart is able to plot stuff across date ranges, *or* across times within a date. It does this by expecting a `new Date(0, 0, 0,...)` if you are only interested in the times ([example](https://developers.google.com/chart/interactive/docs/gallery/timeline#ControllingColors)). To allow the gem to handle this, I've added a new column type - `timewithoutdate`. It expects a Ruby `Time` or `DateTime` for validation purposes, then coerces it into the form required for the chart, outputting it as if it's a `datetime`.

If you want to make a dated timeline ([example](https://developers.google.com/chart/interactive/docs/gallery/timeline#LabelingBars)) you should just set your column type as `date` rather than `timewithoutdate`. Happy to help with documentation on the examples site.

If you had other ideas about how to manage this sort of "weird" handling of dates I'm certainly happy to hear it - this seemed like the simplest solution to me, and so far I haven't come across any leaks in the abstraction.