Disaster Relief: how to help.

Terms & Conditions

Google Timeline for Rails

 

Annotated Timeline for Rails

AnnotatedTimeline is a Rails plugin for the Annotated Timeline widget from the Google Visualization API.
Google provides an API to use their Flash-based graphing tool. It lets you plot values as a function of time. This is extremely useful for Mobile Commons, as we often want to display metrics and analytics about a given campaign. For example, we show graphs of opt-ins and opt-outs over time, which is quite useful for watching your list growth.

Source

The code is available, free of charge, at http://github.com/mcommons/annotatedtimeline-for-rails under the MIT license.

Usage

In your controller:



In the view:


This will create a line graph of “foo” and “bar” vs time. It will create a div with ID ‘my_graph’ and render the graph inside that div.

Options

:colors (array of strings)
The colors to use to override the default google color scheme for the chart lines and labels. Each element is a string in a valid HTML color format. For example ‘red’ or ‘#00cc00′.
:displayExactValues (boolean)
If set to false (the default), value displayed on top may be in a shorter approximated form (56.12k instead of 56123.45). If set to true, values will appear unchanged.
:min (number)
Use to explicitly set the minimal value to show in the Y axis.
:scaleType (string)
‘fixed’(default) or ‘maximize’. If ‘maximize’ is used, the range of the values axis will span between the minimal and maximal values of the DataTable. If ‘fixed’ is used, the range of the values axis will span between zero and the maximal values of the DataTable.
:wmode (string)
‘opaque’(default), ‘window’ or ‘transparent’. the Window Mode (wmode) parameter for the Flash chart.
:zoomStartDate (date)
If specified, sets the start date of the selected zoom range.
:zoomEndDate (date)
If specified, sets the end date of the selected zoom range.
:displayAnnotationsFilter (boolean)
If set true, a search box appears at the top of the annotations column that will filter the annotations according to its contents. Defaults to false.
:annotationsWidth (number)
If specified, sets the percentage of the width of the display that the annotations column takes up. Defaults to 25, must be between 5 and 80.