Prev | Current Page 211 | Next

David Berube

"Practical Reporting with Ruby and Rails"

to_s do
' '
end
span "Weekend - $#{'%0.2f' % week[:weekend_amount]}"
end
end
. . ..
end
puts mab
This code loops through all of the weeks. For each week, you create a label, showing
the week number and year. You also create a row for the weekend spending and a row for
the weekday spending, each with a label and a colored bar. Each bar is sized proportionally
to the others, so that the biggest spending weekend or weekday gets a bar that is
200 pixels wide. The other bars are a percentage of that size, such as 50% (the minimum
size is 1%).
After you have finished building the HTML page, the code will be stored in the
Markaby::Builder object, and then you print it using the puts method.
Summary
PayPal lets you easily download financial information in CSV format, and you can quickly
and efficiently use FasterCSV and Markaby to process that information. In this chapter??™s
example, you used both of these tools to dynamically create a database structure, load
data into it, use Active Record and MySQL to pull data from it, and then quickly create a
custom, attractive CSS graph.


Pages:
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
Chuck Mangione Lutricia McNeal Men At Work Mandaryna Timo Maas