1 # Provides a tag for embedding sparklines graphs into your Rails app.
3 module SparklinesHelper
5 # Call with an array of data and a hash of params for the Sparklines module.
7 # sparkline_tag [42, 37, 43, 182], :type => 'bar', :line_color => 'black'
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)
15 %(<img src="#{ url_for options }" class="#{options[:class] || 'sparkline'}" alt="Sparkline Graph" />)