Added a new bar graph, that counts how many points the borda system of
[selectricity-live] / vendor / plugins / gruff / generators / gruff / templates / controller.rb
1 class <%= controller_class_name %>Controller < ApplicationController
2
3   # To make caching easier, add a line like this to config/routes.rb:
4   # map.graph "graph/:action/:id/image.png", :controller => "graph"
5   #
6   # Then reference it with the named route:
7   #   image_tag graph_url(:action => 'show', :id => 42)
8
9   def show
10     g = Gruff::Line.new
11     # Uncomment to use your own theme or font
12     # See http://colourlovers.com or http://www.firewheeldesign.com/widgets/ for color ideas
13 #     g.theme = {
14 #       :colors => ['#663366', '#cccc99', '#cc6633', '#cc9966', '#99cc99'],
15 #       :marker_color => 'white',
16 #       :background_colors => ['black', '#333333']
17 #     }
18 #     g.font = File.expand_path('artwork/fonts/VeraBd.ttf', RAILS_ROOT)
19
20     g.title = "Gruff-o-Rama"
21     
22     g.data("Apples", [1, 2, 3, 4, 4, 3])
23     g.data("Oranges", [4, 8, 7, 9, 8, 9])
24     g.data("Watermelon", [2, 3, 1, 5, 6, 8])
25     g.data("Peaches", [9, 9, 10, 8, 7, 9])
26
27     g.labels = {0 => '2004', 2 => '2005', 4 => '2006'}
28
29     send_data(g.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "gruff.png")
30   end
31
32 end

Benjamin Mako Hill || Want to submit a patch?