@@ -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