]> projects.mako.cc - selectricity-live/blob - vendor/plugins/sparklines/lib/sparklines_helper.rb
turned off memcache as it was causing trouble
[selectricity-live] / vendor / plugins / sparklines / lib / sparklines_helper.rb
1 # Provides a tag for embedding sparklines graphs into your Rails app.
2 #
3 module SparklinesHelper
4
5         # Call with an array of data and a hash of params for the Sparklines module.
6   #
7   #  sparkline_tag [42, 37, 43, 182], :type => 'bar', :line_color => 'black'
8   #
9         # You can also pass :class => 'some_css_class' ('sparkline' by default).
10         def sparkline_tag(results=[], options={})               
11                 url = { :controller => 'sparklines',
12                         :results => results.join(',') }
13                 options = url.merge(options)
14                 
15                 %(<img src="#{ url_for options }" class="#{options[:class] || 'sparkline'}" alt="Sparkline Graph" />)
16         end
17
18 end

Benjamin Mako Hill || Want to submit a patch?