X-Git-Url: https://projects.mako.cc/source/selectricity/blobdiff_plain/4ab69ea7afaeff96714961139e7c696e7c7141ab..e7bff908a0ea52b62e4fa0dc13be0293a51dcbb1:/app/controllers/sparklines_controller.rb?ds=inline diff --git a/app/controllers/sparklines_controller.rb b/app/controllers/sparklines_controller.rb index eb5e6a6..50a330f 100644 --- a/app/controllers/sparklines_controller.rb +++ b/app/controllers/sparklines_controller.rb @@ -1,43 +1,30 @@ + +# Handles requests for sparkline graphs. +# +# You shouldn't need to edit or extend this, but you can read +# the documentation for SparklinesHelper to see how to call it from +# another view. +# +# AUTHOR +# +# Geoffrey Grosenbach[mailto:boss@topfunky.com] +# +# http://topfunky.com +# class SparklinesController < ApplicationController - # Handles requests for sparkline graphs from views. - # - # Params are generated by the sparkline_tag helper method. - # - def index - # Make array from comma-delimited list of data values - ary = [] - if params.has_key?('results') && !params['results'].nil? - params['results'].split(',').each do |s| - ary << s.to_i - end - end + layout nil + + def index + # Make array from comma-delimited list of data values + ary = [] + params['results'].split(',').each do |s| + ary << s.to_i + end + + send_data( Sparklines.plot( ary, params ), + :disposition => 'inline', + :type => 'image/png', + :filename => "spark_#{params[:type]}.png" ) + end - send_data( Sparklines.plot( ary, params ), - :disposition => 'inline', - :type => 'image/png', - :filename => "spark_#{params[:type]}.png" ) - end - - def spark_pie - send_data(Sparklines.plot( )) - end - # Use this type of method for sparklines that can be cached. (Doesn't work with the helper.) - # - # To make caching easier, add a line like this to config/routes.rb: - # map.sparklines "sparklines/:action/:id/image.png", :controller => "sparklines" - # - # Then reference it with the named route: - # image_tag sparklines_url(:action => 'show', :id => 42) - def show - send_data(Sparklines.plot( - [42, 37, 89, 74, 70, 50, 40, 30, 40, 50], - :type => 'bar', :above_color => 'orange' - ), - :disposition => 'inline', - :type => 'image/png', - :filename => "sparkline.png") - end - - - -end \ No newline at end of file +end