Module: FlotViewHelpers
- Defined in:
- lib/flot/rails/plus/flot_view_helpers.rb
Instance Method Summary collapse
- #build_gon(chart_sets, options = {}) ⇒ Object
- #build_json(chart_sets, options) ⇒ Object
-
#setup_flot_view(chart_sets, options = {}) ⇒ Object
called by application to setup the view for display or the json for callback data for html leave options blank, for json pass the json object from the view builder as :json => json to enable that also pass :url as the full url to use for json callback in the initial call from the view, in which case samples may be nil as they will be picked up via json call after initial view has been rendered.
Instance Method Details
#build_gon(chart_sets, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/flot/rails/plus/flot_view_helpers.rb', line 16 def build_gon( chart_sets, = {} ) gon.url = [:url] gon.refresh = [:refresh] gon.chart_sets = chart_sets.map { |c| c.as_hash } # generate gon data that will appear in the view include_gon end |
#build_json(chart_sets, options) ⇒ Object
25 26 27 28 |
# File 'lib/flot/rails/plus/flot_view_helpers.rb', line 25 def build_json( chart_sets, ) json = [:json] json.chart_sets chart_sets.map{ |c| c.as_hash(:with_charts => false) } end |
#setup_flot_view(chart_sets, options = {}) ⇒ Object
called by application to setup the view for display or the json for callback data for html leave options blank, for json pass the json object from the view builder as :json => json to enable that also pass :url as the full url to use for json callback in the initial call from the view, in which case samples may be nil as they will be picked up via json call after initial view has been rendered.
8 9 10 11 12 13 14 |
# File 'lib/flot/rails/plus/flot_view_helpers.rb', line 8 def setup_flot_view( chart_sets, = {} ) if [:json] build_json chart_sets, else build_gon chart_sets, end end |