1
1
require 'google_visualr'
2
2
require_relative 'googlecharts/iruby_notebook'
3
- require_relative 'googlecharts/display '
3
+ require_relative 'googlecharts/google_visualr '
4
4
require 'daru'
5
5
require 'bigdecimal'
6
6
require 'daru/view/constants'
@@ -58,6 +58,16 @@ module GooglechartsAdapter
58
58
# options = {type: :area}
59
59
# chart = Daru::View::Plot.new(data, options)
60
60
#
61
+ # @example ChartEditor
62
+ # data = [
63
+ # ['Year', 'Sales', 'Expenses'],
64
+ # ['2013', 1000, 400],
65
+ # ['2014', 1170, 460],
66
+ # ['2015', 660, 1120],
67
+ # ['2016', 1030, 540]
68
+ # ]
69
+ # plot = Daru::View::Plot.new(data, {}, chart_class: 'Charteditor')
70
+ #
61
71
# @example Multiple Charts in a row
62
72
# Draw the Daru::View::PlotList object with the data as an array of
63
73
# Daru::View::Plots(s) or Daru::View::Table(s) or both
@@ -115,6 +125,16 @@ def init(data=[], options={}, user_options={})
115
125
# query = 'SELECT A, H, O, Q, R, U LIMIT 5 OFFSET 8'
116
126
# data << query
117
127
# chart = Daru::View::Table.new(data)
128
+ #
129
+ # @example ChartEditor
130
+ # data = [
131
+ # ['Year', 'Sales', 'Expenses'],
132
+ # ['2013', 1000, 400],
133
+ # ['2014', 1170, 460],
134
+ # ['2015', 660, 1120],
135
+ # ['2016', 1030, 540]
136
+ # ]
137
+ # table = Daru::View::Table.new(data, {}, chart_class: 'Charteditor')
118
138
def init_table ( data = [ ] , options = { } , user_options = { } )
119
139
# if `options` is something like this :
120
140
# {
@@ -141,23 +161,6 @@ def init_table(data=[], options={}, user_options={})
141
161
@table
142
162
end
143
163
144
- # @param data [Array, Daru::DataFrame, Daru::Vector, Daru::View::Table]
145
- # The data provided by the user to generate the google datatable.
146
- # Data in String format represents the URL of the google spreadsheet
147
- # from which data has to invoked
148
- # @return [GoogleVisualr::DataTable] the table object will the data
149
- # filled
150
- def get_table ( data )
151
- if data . is_a? ( Daru ::View ::Table ) &&
152
- data . table . is_a? ( GoogleVisualr ::DataTable )
153
- data . table
154
- elsif data . is_a? ( GoogleVisualr ::DataTable )
155
- data
156
- else
157
- add_data_in_table ( data )
158
- end
159
- end
160
-
161
164
# @param data [String] URL of the google spreadsheet from which data
162
165
# has to invoked
163
166
# @return [Boolean, void] returns true for valid URL and raises error
@@ -216,6 +219,23 @@ def add_series(plot, opts={})
216
219
217
220
private
218
221
222
+ # @param data [Array, Daru::DataFrame, Daru::Vector, Daru::View::Table]
223
+ # The data provided by the user to generate the google datatable.
224
+ # Data in String format represents the URL of the google spreadsheet
225
+ # from which data has to invoked
226
+ # @return [GoogleVisualr::DataTable] the table object with the data
227
+ # filled
228
+ def get_table ( data )
229
+ if data . is_a? ( Daru ::View ::Table ) &&
230
+ data . table . is_a? ( GoogleVisualr ::DataTable )
231
+ data . table
232
+ elsif data . is_a? ( GoogleVisualr ::DataTable )
233
+ data
234
+ else
235
+ add_data_in_table ( data )
236
+ end
237
+ end
238
+
219
239
def extract_chart_type ( options )
220
240
# TODO: Imprvoe this method.
221
241
chart_type = options [ :type ] . nil? ? 'Line' : options . delete ( :type )
0 commit comments