Module: LazyHighCharts::LayoutHelper
- Defined in:
- lib/lazy_high_charts/layout_helper.rb
Instance Method Summary collapse
- #build_html_output(type, placeholder, object, &block) ⇒ Object
- #high_chart(placeholder, object, &block) ⇒ Object
- #high_graph(placeholder, object, &block) ⇒ Object
- #high_graph_stock(placeholder, object, &block) ⇒ Object
- #high_stock(placeholder, object, &block) ⇒ Object
Instance Method Details
#build_html_output(type, placeholder, object, &block) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/lazy_high_charts/layout_helper.rb', line 26 def build_html_output(type, placeholder, object, &block) = [ generate_json_from_hash(OptionsKeyFilter.filter(object.)) ] << %|"series": [#{generate_json_from_array(object.data)}]| core_js =<<-EOJS var options, chart; options = { #{.join(',')} }; #{capture(&block) if block_given?} chart = new Highcharts.#{type}(options); EOJS if defined?(request) && request.respond_to?(:xhr?) && request.xhr? graph =<<-EOJS <script type="text/javascript"> (function() { #{core_js} })() </script> EOJS else graph =<<-EOJS <script type="text/javascript"> (function() { var onload = window.onload; window.onload = function(){ if (typeof onload == "function") onload(); #{core_js} }; })() </script> EOJS end if defined?(raw) return raw(graph) else return graph end end |
#high_chart(placeholder, object, &block) ⇒ Object
6 7 8 9 10 |
# File 'lib/lazy_high_charts/layout_helper.rb', line 6 def high_chart(placeholder, object , &block) object..merge!({:id=>placeholder}) object.[:chart][:renderTo] = placeholder high_graph(placeholder,object , &block).concat(content_tag("div","", object.)) end |
#high_graph(placeholder, object, &block) ⇒ Object
18 19 20 |
# File 'lib/lazy_high_charts/layout_helper.rb', line 18 def high_graph(placeholder, object, &block) build_html_output("Chart", placeholder, object, &block) end |
#high_graph_stock(placeholder, object, &block) ⇒ Object
22 23 24 |
# File 'lib/lazy_high_charts/layout_helper.rb', line 22 def high_graph_stock(placeholder, object, &block) build_html_output("StockChart", placeholder, object, &block) end |
#high_stock(placeholder, object, &block) ⇒ Object
12 13 14 15 16 |
# File 'lib/lazy_high_charts/layout_helper.rb', line 12 def high_stock(placeholder, object , &block) object..merge!({:id=>placeholder}) object.[:chart][:renderTo] = placeholder high_graph_stock(placeholder,object , &block).concat(content_tag("div","", object.)) end |