module Rorschart::Helper
Public Instance Methods
area_chart(data_source, options = {})
click to toggle source
# File lib/rorschart/helper.rb, line 26 def area_chart(data_source, options = {}) rorschart_chart "AreaChart", data_source, options end
bar_chart(data_source, options = {})
click to toggle source
# File lib/rorschart/helper.rb, line 22 def bar_chart(data_source, options = {}) rorschart_chart "BarChart", data_source, options end
bubble_chart(data_source, options = {})
click to toggle source
# File lib/rorschart/helper.rb, line 38 def bubble_chart(data_source, options = {}) rorschart_chart "BubbleChart", data_source, options end
column_chart(data_source, options = {})
click to toggle source
# File lib/rorschart/helper.rb, line 18 def column_chart(data_source, options = {}) rorschart_chart "ColumnChart", data_source, options end
combo_chart(data_source, options = {})
click to toggle source
# File lib/rorschart/helper.rb, line 42 def combo_chart(data_source, options = {}) rorschart_chart "ComboChart", data_source, options end
geo_chart(data_source, options = {})
click to toggle source
# File lib/rorschart/helper.rb, line 34 def geo_chart(data_source, options = {}) rorschart_chart "GeoChart", data_source, options end
line_chart(data_source, options = {})
click to toggle source
# File lib/rorschart/helper.rb, line 10 def line_chart(data_source, options = {}) rorschart_chart "LineChart", data_source, options end
pie_chart(data_source, options = {})
click to toggle source
# File lib/rorschart/helper.rb, line 14 def pie_chart(data_source, options = {}) rorschart_chart "PieChart", data_source, options end
rorschart_chart(klass_name, dataSource, options = {})
click to toggle source
# File lib/rorschart/helper.rb, line 50 def rorschart_chart(klass_name, dataSource, options = {}) dataSource = format_if_needed(dataSource) element_id = options.delete(:id) || generateChartId options = default_options.merge(chart_options(klass_name)).deep_merge(options); height = options.delete(:height) || "300px" html = <<HTML <div id="#{ERB::Util.html_escape(element_id)}" style="height: #{ERB::Util.html_escape(height)}; width:100%;"> Rorchart is not initialized. </div> HTML js = <<JS <script type="text/javascript"> new Rorschart.GoogleChart(google.visualization.#{klass_name}, #{element_id.to_json}, #{dataSource.to_json}, #{options.to_json}); </script> JS (html + js).html_safe end
table_chart(data_source, options = {})
click to toggle source
# File lib/rorschart/helper.rb, line 30 def table_chart(data_source, options = {}) rorschart_chart "Table", data_source, options end
to_chart(data_source)
click to toggle source
# File lib/rorschart/helper.rb, line 46 def to_chart(data_source) to_datatable_format(data_source).to_json end
Private Instance Methods
generateChartId()
click to toggle source
# File lib/rorschart/helper.rb, line 77 def generateChartId @current_chart_id ||= 0 "chart#{@current_chart_id += 1}" end