lib/flotilla.rb
# Insert a flot chart into the page.  <tt>placeholder</tt> should be the 
# name of the div that will hold the chart, <tt>collections</tt> is a hash 
# of legends (as strings) and datasets with options as hashes, <tt>options</tt>
# contains graph-wide options.
# 
# Example usage:
#   
#  chart("graph_div", { 
#   "January" => { :collection => @january, :x => :day, :y => :sales, :options => { :lines => {:show =>true}} }, 
#   "February" => { :collection => @february, :x => :day, :y => :sales, :options => { :points => {:show =>true} } },
#   :grid => { :backgroundColor => "#fffaff" })
# 
# Options:
#   :js_tags - wraps resulting javascript in javascript tags if true.  Defaults to true.
Insert a flot chart into the page. placeholder should be the
name of the div that will hold the chart, collections is a hash
of legends (as strings) and datasets with options as hashes, options
contains graph-wide options.

Example usage.



:js_tags - wraps resulting javascript in javascript tags if true.  Defaults to true.
Insert a flot chart into the page . placeholder should be the name of the div that will hold the chart collections is a hash of legends ( as strings ) and datasets with options as hashes options contains graph - wide options . Example usage . : js_tags - wraps resulting javascript in javascript tags if true . Defaults to true .
def chart(placeholder, series, options = {}, html_options = {})
        html_options.reverse_merge!({ :js_tags => true })
        data, x_is_date, y_is_date = series_to_json(series)
        if x_is_date
          options[:xaxis] ||= {}
          options[:xaxis].merge!({ :mode => 'time' })
        end
        if y_is_date
          options[:yaxis] ||= {}
          options[:yaxis].merge!({ :mode => 'time' })
        end
        jQueryString= Flotilla.jrails_present ? '$' : 'jQuery'
        chart_js = "#{jQueryString}.plot(#{jQueryString}('##{placeholder}'), #{data}, #{options.to_json});"
        html_options[:js_tags] ? javascript_tag(chart_js) : chart_js
      end
def chart ( placeholder , series , options = { } , html_options = { } ) html_options . reverse_merge! ( { :js_tags => true } ) data , x_is_date , y_is_date = series_to_json ( series ) if x_is_date options [ :xaxis ] ||= { } options [ :xaxis ] . merge! ( { :mode => 'time' } ) end if y_is_date options [ :yaxis ] ||= { } options [ :yaxis ] . merge! ( { :mode => 'time' } ) end jQueryString = Flotilla . jrails_present ? '$' : 'jQuery' chart_js = "#{jQueryString}.plot(#{jQueryString}('##{placeholder}'), #{data}, #{options.to_json});" html_options [ :js_tags ] ? javascript_tag ( chart_js ) : chart_js end
Insert a flot chart into the page.
Insert a flot chart into the page .
placeholder
series
options
html_options