Module: HighchartsHelper
- Defined in:
- app/helpers/highcharts_helper.rb
Instance Method Summary collapse
-
#high_chart(placeholder, object, &block) ⇒ Object
(also: #highchart)
ActiveSupport::JSON.unquote_hash_key_identifiers = false.
- #high_graph(placeholder, object, &block) ⇒ Object
Instance Method Details
#high_chart(placeholder, object, &block) ⇒ Object Also known as: highchart
ActiveSupport::JSON.unquote_hash_key_identifiers = false
4 5 6 7 8 9 |
# File 'app/helpers/highcharts_helper.rb', line 4 def high_chart(placeholder, object , &block) object..merge!({:id=>placeholder}) object.[:chart][:renderTo] = placeholder output = high_graph(placeholder, object, &block) output << content_tag(:div, "", object.) end |
#high_graph(placeholder, object, &block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/helpers/highcharts_helper.rb', line 13 def high_graph(placeholder, object, &block) graph = javascript_tag <<-EOJS jQuery(function() { // 1. Define JSON options var options = { chart: #{object.[:chart].to_json}, title: #{object.[:title].to_json}, legend: #{object.[:legend].to_json}, xAxis: #{object.[:x_axis].to_json}, yAxis: #{object.[:y_axis].to_json}, tooltip: #{object.[:tooltip].to_json}, credits: #{object.[:credits].to_json}, plotOptions: #{object.[:].to_json}, series: #{object.data.to_json}, subtitle: #{object.[:subtitle].to_json} }; // 2. Add callbacks (non-JSON compliant) #{capture(&block) if block_given?} // 3. Build the chart var chart = new Highcharts.Chart(options); }); EOJS end |