Ruby-on-Rails

Tracking the News with Google News

In this article, you'll create a graphical report from Google News RSS data, using a handy utility called FeedTools and a plug-in called CSS Graphs Helper. This article is excerpted from chapter 11 of the book Practical Reporting with Ruby and Rails, written by David Berube (Apress; ISBN: 1590599330).

Next, let's take a look at creating a Rails application that shows the report. As noted at the beginning of the chapter, you'll use the CSS Graphs Helper plug-in to create the graphs. This provides a simple way to graph data, by creating HTML graphs using CSS. In Chapter 7, you generated custom HTML and CSS graphs using Markaby, which is the most flexible approach, but CSS Graphs Helper does this automatically.

In this example, you'll use the CSS Graphs Helper's complex_bar_graph method to create a thermometer-like chart. Also available are a bar_graph method, which creates vertical charts, and ahorizontal_bar_chart method, which creates horizontal bar charts . You can get more information about CSS Graphs Helper and its various charts at http://nubyonrails.com/pages/css_graphs.

Note Unfortunately, CSS Graphs Helper currently supports only one chart per page. And, while it's extremely easy to use, it has a limited range of chart types. If you're looking for more complicated charts or for many charts per page, consider using the Gruff graphing library (which was created by the same person who created CSS Graphs Helper). You can find examples of Gruff in Chapters 3, 4, and 10, and at the Gruff home page: http://nubyonrails.com/pages/gruff.

Before we start, if you haven't already installed the Rails gem, do so now: