Module: Rorschart::Helper
Instance Method Summary
collapse
-
#area_chart(data_source, options = {}) ⇒ Object
-
#bar_chart(data_source, options = {}) ⇒ Object
-
#bubble_chart(data_source, options = {}) ⇒ Object
-
#column_chart(data_source, options = {}) ⇒ Object
-
#combo_chart(data_source, options = {}) ⇒ Object
-
#geo_chart(data_source, options = {}) ⇒ Object
-
#line_chart(data_source, options = {}) ⇒ Object
-
#pie_chart(data_source, options = {}) ⇒ Object
-
#rorschart_chart(klass_name, dataSource, options = {}) ⇒ Object
-
#table_chart(data_source, options = {}) ⇒ Object
-
#to_chart(data_source) ⇒ Object
#chart_options, #default_options
#add_rows, #chart_class_from_string, #format_if_needed, #is_already_converted?, #to_datatable_format
Instance Method Details
#area_chart(data_source, options = {}) ⇒ Object
26
27
28
|
# 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 = {}) ⇒ Object
22
23
24
|
# 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 = {}) ⇒ Object
38
39
40
|
# 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 = {}) ⇒ Object
18
19
20
|
# 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 = {}) ⇒ Object
42
43
44
|
# 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 = {}) ⇒ Object
34
35
36
|
# 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 = {}) ⇒ Object
10
11
12
|
# 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 = {}) ⇒ Object
14
15
16
|
# 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 = {}) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# 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 = {}) ⇒ Object
30
31
32
|
# File 'lib/rorschart/helper.rb', line 30
def table_chart(data_source, options = {})
rorschart_chart "Table", data_source, options
end
|
#to_chart(data_source) ⇒ Object
46
47
48
|
# File 'lib/rorschart/helper.rb', line 46
def to_chart(data_source)
to_datatable_format(data_source).to_json
end
|