Major update of Selectricity to work with Rails 2.2.2 from 1.2!
[selectricity] / app / controllers / sparklines_controller.rb
1
2 # Handles requests for sparkline graphs.
3 #
4 # You shouldn't need to edit or extend this, but you can read
5 # the documentation for SparklinesHelper to see how to call it from
6 # another view.
7 #
8 # AUTHOR
9
10 # Geoffrey Grosenbach[mailto:boss@topfunky.com]
11 #
12 # http://topfunky.com
13 #
14 class SparklinesController < ApplicationController
15         layout nil
16
17         def index
18                 # Make array from comma-delimited list of data values
19                 ary = []
20                 params['results'].split(',').each do |s|
21                         ary << s.to_i
22                 end
23                 
24                 send_data( Sparklines.plot( ary, params ), 
25                                         :disposition => 'inline',
26                                         :type => 'image/png',
27                                         :filename => "spark_#{params[:type]}.png" )
28         end
29
30 end

Benjamin Mako Hill || Want to submit a patch?