]> projects.mako.cc - selectricity/blob - app/helpers/sparklines_helper.rb
updated top the the new version of attachment_fu plugin to work out some
[selectricity] / app / helpers / sparklines_helper.rb
1
2 # Provides a tag for embedding sparklines graphs into your Rails app.
3 #
4 # To use, load it in your controller with
5 #
6 #   helper :sparklines
7 #
8 # AUTHOR
9 #
10 # Geoffrey Grosenbach[mailto:boss@topfunky.com]
11 #
12 # http://topfunky.com
13
14 # License
15 #
16 # This code is licensed under the MIT license.
17 #
18 module SparklinesHelper
19
20         # Call with an array of data and a hash of params for the Sparklines module.
21         # You can also pass :class => 'some_css_class' ('sparkline' by default).
22         def sparkline_tag(results=[], options={})               
23                 url = { :controller => 'sparklines',
24                         :results => results.join(',') }
25                 options = url.merge(options)
26                 
27                 "<img src=\"#{ url_for options }\" class=\"#{options[:class] || 'sparkline'}\" alt=\"Sparkline Graph\" />"
28         end
29
30 end

Benjamin Mako Hill || Want to submit a patch?