Skip to content

Commit ee534f2

Browse files
committed
Added documentation of methods
1 parent 6ba1ea9 commit ee534f2

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

lib/daru/view/adapters/googlecharts/base_chart.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,22 @@ def query_response_function_name(element_id)
1818
"handleQueryResponse_#{element_id.tr('-', '_')}"
1919
end
2020

21+
# @param data [Array, Daru::DataFrame, Daru::Vector, Daru::View::Table, String]
22+
# Data of GoogleVisualr DataTable
23+
# @return [String] Data option (dataSourceUrl or dataTable) required to
24+
# draw the Chartwrapper based upon the data provided.
2125
def append_data(data)
2226
return "\n dataSourceUrl: '#{data}'," if data.is_a? String
2327
"\n dataTable: data_table,"
2428
end
2529

30+
# @see #GooleVisualr::DataTable.extract_option_view
2631
def extract_option_view
2732
return js_parameters(@options.delete('view')) unless @options['view'].nil?
2833
'\'\''
2934
end
3035

31-
# So that it can be used in ChartEditor also
36+
# @see #GooleVisualr::DataTable.draw_wrapper
3237
def draw_wrapper
3338
return "\n wrapper.draw();" if class_chart == 'Chartwrapper'
3439
''
@@ -71,6 +76,7 @@ def to_js_chart_wrapper(data, element_id=SecureRandom.uuid)
7176
js
7277
end
7378

79+
# @see #GooleVisualr::DataTable.load_js_chart_wrapper
7480
def load_js_chart_wrapper(element_id)
7581
js = ''
7682
js << "\n google.load('visualization', '#{version}', "
@@ -79,6 +85,10 @@ def load_js_chart_wrapper(element_id)
7985
js
8086
end
8187

88+
# Generates JavaScript function for rendering the chartwrapper
89+
#
90+
# @param (see #to_js_chart_wrapper)
91+
# @return [String] JS function to render the chartwrapper
8292
def draw_js_chart_wrapper(data, element_id)
8393
js = ''
8494
js << "\n function #{chart_function_name(element_id)}() {"

lib/daru/view/adapters/googlecharts/data_table_iruby.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ def to_js_full_script(element_id=SecureRandom.uuid)
5353
js
5454
end
5555

56+
# Generates JavaScript and renders the Google Chartwrapper in the
57+
# final HTML output.
58+
#
59+
# @param data [Array, Daru::DataFrame, Daru::Vector, Daru::View::Table, String]
60+
# Data of GoogleVisualr Chart
61+
# @param element_id [String] The ID of the DIV element that the Google
62+
# Chartwrapper should be rendered in
63+
# @return [String] Javascript code to render the Google Chartwrapper
5664
def to_js_full_script_chart_wrapper(data, element_id=SecureRandom.uuid)
5765
js = ''
5866
js << "\n<script type='text/javascript'>"
@@ -74,17 +82,25 @@ def package_name
7482
'table'
7583
end
7684

85+
# @param data [Array, Daru::DataFrame, Daru::Vector, String] Data
86+
# of GoogleVisualr DataTable
87+
# @return [String] Data option (dataSourceUrl or dataTable) required to
88+
# draw the Chartwrapper based upon the data provided.
7789
def append_data(data)
7890
return "\n dataSourceUrl: '#{data}'," if data.is_a? String
7991
"\n dataTable: data_table,"
8092
end
8193

94+
# @return [String] Returns value of the view option provided by the user
95+
# and '' otherwise
8296
def extract_option_view
8397
return js_parameters(@options.delete(:view)) unless @options[:view].nil?
8498
'\'\''
8599
end
86100

87101
# So that it can be used in ChartEditor also
102+
#
103+
# @return [String] Returns string to draw the Chartwrapper and '' otherwise
88104
def draw_wrapper
89105
return "\n wrapper.draw();" if class_chart == 'Chartwrapper'
90106
''
@@ -102,6 +118,12 @@ def load_js(element_id)
102118
js
103119
end
104120

121+
# Generates JavaScript of callback to render chart. Packages are not
122+
# required to load explicitly in Chartwrapper
123+
#
124+
# @param element_id [String] The ID of the DIV element that the Google
125+
# Chart should be rendered in
126+
# @return [String] JS of callback to render chart.
105127
def load_js_chart_wrapper(element_id)
106128
js = ''
107129
js << "\n google.load('visualization', #{google_table_version}, "
@@ -125,6 +147,10 @@ def draw_js(element_id)
125147
js
126148
end
127149

150+
# Generates JavaScript function for rendering the chartwrapper
151+
#
152+
# @param (see #to_js_chart_wrapper)
153+
# @return [String] JS function to render the chartwrapper
128154
def draw_js_chart_wrapper(data, element_id)
129155
js = ''
130156
js << "\n function #{chart_function_name(element_id)}() {"

0 commit comments

Comments
 (0)