# File lib/sparklines_helper.rb, line 11 def sparkline_tag(results=[], options={}) url = { :controller => 'sparklines' } url[:results] = results.join(',') unless results.nil? options = url.merge(options) attributes = %(class="#{options[:class] || 'sparkline'}" alt="Sparkline Graph" ) attributes << %(title="#{options[:title]}" ) if options[:title] # prefer to use a "data" URL scheme as described in {RFC 2397}[http://www.ietf.org/rfc/rfc2397.txt] # data_url = "data:image/png;base64,#{Base64.encode64(Sparklines.plot(results,options))}" # tag = %(<img src="#{data_url}" #{attributes}/>) # # respect some limits noted in RFC 2397 since the data: url is supposed to be 'short' # data_url.length <= 1024 && tag.length <= 2100 ? tag : %(<img src="#{ url_for options }" #{attributes}/>) end