analytica 0.0.18 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/lib/analytica.rb +1 -1
  2. data/lib/visualization.rb +29 -15
  3. metadata +3 -3
data/lib/analytica.rb CHANGED
@@ -4,7 +4,7 @@ require File.join(File.dirname(__FILE__), 'computation')
4
4
  require File.join(File.dirname(__FILE__), 'visualization')
5
5
 
6
6
  module Analytica
7
- VERSION = '0.0.18'
7
+ VERSION = '0.0.19'
8
8
 
9
9
  include Strict
10
10
 
data/lib/visualization.rb CHANGED
@@ -7,7 +7,7 @@ module Analytica
7
7
  module Representation
8
8
  def set_labels(params={})
9
9
  enforce_map_defaults!({
10
- :data => nil,
10
+ :data => [],
11
11
  :type => :x_axis,
12
12
  :prefix => ' ',
13
13
  :postfix => ' ',
@@ -15,7 +15,7 @@ module Analytica
15
15
  :color => '000000',
16
16
  :size => 10}, params)
17
17
 
18
- enforce_weak_primitives!([Array, NilClass], params[:data])
18
+ enforce_primitive!(Array, params[:data])
19
19
 
20
20
  enforce_map!({
21
21
  :type => [:axis, :x_axis, :y_axis, :data],
@@ -83,13 +83,13 @@ module Analytica
83
83
  elsif @labels[:x_axis]
84
84
  x_axis_label = {
85
85
  :axis_with_labels => 'x',
86
- :axis_labels => @labels[:x_axis][:data].nil? ? self.map{|n|"#{n}"} : @labels[:x_axis][:data]
86
+ :axis_labels => @labels[:x_axis][:data].size == 0 ? self.map{|n|"#{n}"} : @labels[:x_axis][:data]
87
87
  }
88
88
  options.merge!(x_axis_label)
89
89
  elsif @labels[:y_axis]
90
90
  y_axis_label = {
91
91
  :axis_with_labels => 'y',
92
- :axis_labels => @labels[:y_axis][:data].nil? ? ["#{0}", "#{(datamax*0.5).to_i}", "#{datamax.to_i}"] : @labels[:y_axis][:data]
92
+ :axis_labels => @labels[:y_axis][:data].size == 0 ? ["#{0}", "#{(datamax*0.5).to_i}", "#{datamax.to_i}"] : @labels[:y_axis][:data]
93
93
  }
94
94
  options.merge!(y_axis_label)
95
95
  end
@@ -121,6 +121,7 @@ module Analytica
121
121
  :background_color => '000000',
122
122
  :width => 600,
123
123
  :height => 280,
124
+ :format => :image_tag,
124
125
  :bar_settings => {}}, params)
125
126
 
126
127
  enforce_map!({
@@ -130,16 +131,18 @@ module Analytica
130
131
  :width => :natural_number,
131
132
  :height => :natural_number,
132
133
  :background_color => :hex_color,
134
+ :format => [:url, :image_tag],
133
135
  :color => :hex_color}, params)
134
136
 
135
137
 
136
138
  options = {}
137
139
 
140
+ options.merge!({:format => 'image_tag'}) if params[:format] == :image_tag
141
+
138
142
  base = {
139
143
  :data => self,
140
144
  :max_value => datamax,
141
- :size => "#{params[:width]}x#{params[:height]}",
142
- :format => 'image_tag'
145
+ :size => "#{params[:width]}x#{params[:height]}"
143
146
  }
144
147
 
145
148
  options.merge!(base)
@@ -166,6 +169,7 @@ module Analytica
166
169
  :background_color => 'ffffff',
167
170
  :width => 600,
168
171
  :height => 180,
172
+ :format => :image_tag,
169
173
  :bar_settings => {}}, params)
170
174
 
171
175
  enforce_map!({
@@ -175,6 +179,7 @@ module Analytica
175
179
  :width => :natural_number,
176
180
  :height => :natural_number,
177
181
  :background_color => :hex_color,
182
+ :format => [:url, :image_tag],
178
183
  :color => :hex_color}, params)
179
184
 
180
185
  params[:title] = '' unless params.has_key? :title
@@ -184,11 +189,12 @@ module Analytica
184
189
 
185
190
  options = {}
186
191
 
192
+ options.merge!({:format => 'image_tag'}) if params[:format] == :image_tag
193
+
187
194
  base = {
188
195
  :data => self,
189
196
  :max_value => datamax,
190
- :size => "#{params[:width]}x#{params[:height]}",
191
- :format => 'image_tag'
197
+ :size => "#{params[:width]}x#{params[:height]}"
192
198
  }
193
199
 
194
200
  options.merge!(base)
@@ -219,6 +225,7 @@ module Analytica
219
225
  :width => 600,
220
226
  :height => 280,
221
227
  :stacked => false,
228
+ :format => :image_tag,
222
229
  :bar_settings => {}}, params)
223
230
 
224
231
  enforce_map!({
@@ -231,18 +238,20 @@ module Analytica
231
238
  :stacked => :boolean,
232
239
  :background_color => :hex_color,
233
240
  :color => :hex_color,
241
+ :format => [:url, :image_tag],
234
242
  :bar_settings => :hash_map}, params)
235
243
 
236
244
  options = {}
237
245
 
246
+ options.merge!({:format => 'image_tag'}) if params[:format] == :image_tag
247
+
238
248
  base = {
239
249
  :data => self,
240
250
  :max_value => datamax,
241
251
  :size => "#{params[:width]}x#{params[:height]}",
242
252
  :orientation => params[:orientation].to_s,
243
253
  :stacked => params[:stacked],
244
- :bar_width_and_spacing => bar_settings(params[:bar_settings]),
245
- :format => 'image_tag'
254
+ :bar_width_and_spacing => bar_settings(params[:bar_settings])
246
255
  }
247
256
 
248
257
  options.merge!(base)
@@ -275,9 +284,9 @@ module Analytica
275
284
  :color => 'ffffff',
276
285
  :width => 600,
277
286
  :height => 280,
287
+ :format => :image_tag,
278
288
  :background_color => '000000'}, params)
279
289
 
280
-
281
290
  enforce_map!({
282
291
  :title => :string,
283
292
  :title_size => :natural_number,
@@ -285,15 +294,17 @@ module Analytica
285
294
  :width => :natural_number,
286
295
  :height => :natural_number,
287
296
  :background_color => :hex_color,
297
+ :format => [:url, :image_tag],
288
298
  :color => :hex_color}, params)
289
299
 
290
300
  options = {}
291
301
 
302
+ options.merge!({:format => 'image_tag'}) if params[:format] == :image_tag
303
+
292
304
  base = {
293
305
  :data => self,
294
306
  :max_value => datamax,
295
- :size => "#{params[:width]}x#{params[:height]}",
296
- :format => 'image_tag'
307
+ :size => "#{params[:width]}x#{params[:height]}"
297
308
  }
298
309
 
299
310
  options.merge!(base)
@@ -322,6 +333,7 @@ module Analytica
322
333
  :width => 600,
323
334
  :height => 280,
324
335
  :stacked => false,
336
+ :format => :image_tag,
325
337
  :bar_settings => {}}, params)
326
338
 
327
339
  enforce_map!({
@@ -334,18 +346,20 @@ module Analytica
334
346
  :stacked => :boolean,
335
347
  :background_color => :hex_color,
336
348
  :colors => :hex_color_array,
349
+ :format => [:url, :image_tag],
337
350
  :bar_settings => :hash_map}, params)
338
351
 
339
352
  options = {}
340
353
 
354
+ options.merge!({:format => 'image_tag'}) if params[:format] == :image_tag
355
+
341
356
  base = {
342
357
  :data => self,
343
358
  :max_value => datamax,
344
359
  :size => "#{params[:width]}x#{params[:height]}",
345
360
  :orientation => params[:orientation].to_s,
346
361
  :stacked => params[:stacked],
347
- :bar_width_and_spacing => bar_settings(params[:bar_settings]),
348
- :format => 'image_tag'
362
+ :bar_width_and_spacing => bar_settings(params[:bar_settings])
349
363
  }
350
364
 
351
365
  options.merge!(base)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: analytica
3
3
  version: !ruby/object:Gem::Version
4
- hash: 59
4
+ hash: 57
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 18
10
- version: 0.0.18
9
+ - 19
10
+ version: 0.0.19
11
11
  platform: ruby
12
12
  authors:
13
13
  - Raeez Lorgat