Prev | Current Page 73 | Next

David Berube

"Practical Reporting with Ruby and Rails"

minimum_value = 0
bar_chart.maximum_value = 110
The minimum_value and maximum_value attributes specify the scale.Without these
attributes, the chart will automatically scale according to the maximum and minimum
values. If you left the default, each chart would have a different scale, and so the charts
would not be directly comparable.
nNote You could loop through all of the charts and find the maximum value and use that here, but then
you would not be able to compare charts from different runs. With fixed values, you can take a chart from,
say, a month ago and compare it with a current chart. Another problem with that approach is that when you
fix the lower end as well, you enlarge the differences between values. The lowest is always scaled to be a
very short line, whereas the largest always occupies the entire chart space. For example, if you had the
values 54, 55, and 56 charted, 56 would appear to be twice as big as 55 and far bigger than 54.
Next, the code pulls out an average time for each event via a custom SQL statement
and the find_by_sql method:
CHAPTER 3 n CREATING GRAPHS WITH RUBY 44
sql = "SELECT event, AVG(time) as average_time
FROM events AS e
INNER JOIN
plays AS p
ON e.


Pages:
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
botox Kraków wyświetlacz xperia Wczasy nad morzem baseny ogrodowe tłumacz niemieckiego