analytica 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/analytica.rb +4 -2
- data/lib/visualization.rb +56 -13
- metadata +4 -4
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.
|
7
|
+
VERSION = '0.0.16'
|
8
8
|
|
9
9
|
include Strict
|
10
10
|
|
@@ -26,11 +26,13 @@ module Analytica
|
|
26
26
|
include Analytica::Computation
|
27
27
|
include Analytica::Visualization::Common
|
28
28
|
include Analytica::Visualization::DataSet
|
29
|
+
|
30
|
+
attr_accessor :labels
|
29
31
|
|
30
32
|
def initialize(datapoints=[])
|
31
33
|
enforce!(:numeric_array, datapoints)
|
32
34
|
|
33
|
-
@labels =
|
35
|
+
@labels = {}
|
34
36
|
@labels_set = false
|
35
37
|
|
36
38
|
super datapoints
|
data/lib/visualization.rb
CHANGED
@@ -20,7 +20,7 @@ module Analytica
|
|
20
20
|
if @labels_set
|
21
21
|
label = {
|
22
22
|
:axis_with_labels => ['x', 'y'],
|
23
|
-
:axis_labels => [@labels, ["#{0}", "#{(datamax*0.
|
23
|
+
:axis_labels => [@labels[:axis][:data], ["#{0}", "#{(datamax*0.5).to_i}", "#{datamax.to_i}"]]
|
24
24
|
}
|
25
25
|
|
26
26
|
options.merge!(label)
|
@@ -37,11 +37,33 @@ module Analytica
|
|
37
37
|
module DataSet
|
38
38
|
include Strict
|
39
39
|
|
40
|
-
def set_labels(
|
41
|
-
|
40
|
+
def set_labels(data, params={})
|
41
|
+
enforce_map_defaults!({
|
42
|
+
:type => :axis,
|
43
|
+
:prefix => ' ',
|
44
|
+
:postfix => ' ',
|
45
|
+
:decimal => 0,
|
46
|
+
:color => '000000',
|
47
|
+
:size => 10}, params)
|
48
|
+
|
49
|
+
enforce_map!({
|
50
|
+
:type => [:axis, :data],
|
51
|
+
:prefix => :string,
|
52
|
+
:decimal => :integer,
|
53
|
+
:color => :hex_color,
|
54
|
+
:size => :natural_number}, params)
|
42
55
|
|
43
|
-
@labels = labels
|
44
56
|
@labels_set = true
|
57
|
+
|
58
|
+
@labels = {} if @labels.nil?
|
59
|
+
@labels[params[:type]] = {}
|
60
|
+
|
61
|
+
@labels[params[:type]][:prefix] = params[:prefix] == ' ' ? '' : params[:prefix]
|
62
|
+
@labels[params[:type]][:postfix] = params[:postfix] == ' ' ? '' : params[:postfix]
|
63
|
+
@labels[params[:type]][:decimal] = params[:decimal]
|
64
|
+
@labels[params[:type]][:color] = params[:color]
|
65
|
+
@labels[params[:type]][:size] = params[:size]
|
66
|
+
@labels[params[:type]][:data] = data
|
45
67
|
end
|
46
68
|
|
47
69
|
def bar_settings(bar_settings)
|
@@ -157,8 +179,8 @@ module Analytica
|
|
157
179
|
:title_size => 12,
|
158
180
|
:title_color => '000000',
|
159
181
|
:orientation => :vertical,
|
160
|
-
:color => '
|
161
|
-
:background_color => '
|
182
|
+
:color => '00bb00',
|
183
|
+
:background_color => 'ffffff',
|
162
184
|
:stacked => false,
|
163
185
|
:width => 600,
|
164
186
|
:height => 280,
|
@@ -197,9 +219,33 @@ module Analytica
|
|
197
219
|
}
|
198
220
|
|
199
221
|
options.merge!(color)
|
200
|
-
|
201
|
-
options.merge!(common_options)
|
202
222
|
|
223
|
+
if @labels_set
|
224
|
+
|
225
|
+
if @labels[:data]
|
226
|
+
data_string = ""
|
227
|
+
@labels[:data][:data].each {|element| data_string += ",#{element.to_f}"}
|
228
|
+
data_string = data_string[1..data_string.size]
|
229
|
+
data_labels = {
|
230
|
+
:custom => "chm=N#{@labels[:data][:prefix]}*f#{@labels[:data][:decimal]}*#{@labels[:data][:postfix]},#{@labels[:data][:color]},0,-1,#{@labels[:data][:size]}&chds=0,#{datamax}"
|
231
|
+
}
|
232
|
+
options.merge!(data_labels)
|
233
|
+
end
|
234
|
+
|
235
|
+
if @labels[:axis]
|
236
|
+
puts "doing the axis labels thing #{@labels[:axis][:data]}"
|
237
|
+
axis_labels = {
|
238
|
+
:axis_with_labels => ['x', 'y'],
|
239
|
+
:axis_labels => [@labels[:axis][:data], ["#{0}", "#{(datamax*0.5).to_i}", "#{datamax.to_i}"]]
|
240
|
+
}
|
241
|
+
|
242
|
+
options.merge!(axis_labels)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
if @title_set
|
247
|
+
options.merge!(@title)
|
248
|
+
end
|
203
249
|
return Gchart.bar(options)
|
204
250
|
end
|
205
251
|
end
|
@@ -214,11 +260,8 @@ module Analytica
|
|
214
260
|
bar_settings
|
215
261
|
end
|
216
262
|
|
217
|
-
def set_labels(
|
218
|
-
|
219
|
-
|
220
|
-
@labels = labels
|
221
|
-
@labels_set = true
|
263
|
+
def set_labels(data, params={})
|
264
|
+
# TODO implement
|
222
265
|
end
|
223
266
|
|
224
267
|
def datamax
|
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:
|
4
|
+
hash: 63
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 16
|
10
|
+
version: 0.0.16
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Raeez Lorgat
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-21 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|