analytica 0.0.17 → 0.0.18
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.
- data/lib/analytica.rb +3 -3
- data/lib/visualization.rb +21 -7
- 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.
|
7
|
+
VERSION = '0.0.18'
|
8
8
|
|
9
9
|
include Strict
|
10
10
|
|
@@ -24,7 +24,7 @@ module Analytica
|
|
24
24
|
|
25
25
|
class DataSet < Array
|
26
26
|
include Analytica::Computation
|
27
|
-
include Analytica::Visualization::
|
27
|
+
include Analytica::Visualization::Representation
|
28
28
|
include Analytica::Visualization::DataSet
|
29
29
|
|
30
30
|
attr_accessor :labels
|
@@ -55,7 +55,7 @@ module Analytica
|
|
55
55
|
end
|
56
56
|
|
57
57
|
class DataSystem < Array
|
58
|
-
include Analytica::Visualization::
|
58
|
+
include Analytica::Visualization::Representation
|
59
59
|
include Analytica::Visualization::DataSystem
|
60
60
|
|
61
61
|
attr_accessor :labels
|
data/lib/visualization.rb
CHANGED
@@ -4,18 +4,21 @@ require 'typestrict'
|
|
4
4
|
module Analytica
|
5
5
|
module Visualization
|
6
6
|
|
7
|
-
module
|
8
|
-
def set_labels(
|
7
|
+
module Representation
|
8
|
+
def set_labels(params={})
|
9
9
|
enforce_map_defaults!({
|
10
|
-
:
|
10
|
+
:data => nil,
|
11
|
+
:type => :x_axis,
|
11
12
|
:prefix => ' ',
|
12
13
|
:postfix => ' ',
|
13
14
|
:decimal => 0,
|
14
15
|
:color => '000000',
|
15
16
|
:size => 10}, params)
|
16
17
|
|
18
|
+
enforce_weak_primitives!([Array, NilClass], params[:data])
|
19
|
+
|
17
20
|
enforce_map!({
|
18
|
-
:type => [:axis, :data],
|
21
|
+
:type => [:axis, :x_axis, :y_axis, :data],
|
19
22
|
:prefix => :string,
|
20
23
|
:decimal => :integer,
|
21
24
|
:color => :hex_color,
|
@@ -31,7 +34,7 @@ module Analytica
|
|
31
34
|
@labels[params[:type]][:decimal] = params[:decimal]
|
32
35
|
@labels[params[:type]][:color] = params[:color]
|
33
36
|
@labels[params[:type]][:size] = params[:size]
|
34
|
-
@labels[params[:type]][:data] = data
|
37
|
+
@labels[params[:type]][:data] = params[:data]
|
35
38
|
end
|
36
39
|
|
37
40
|
def set_title(params)
|
@@ -77,9 +80,20 @@ module Analytica
|
|
77
80
|
:axis_labels => [@labels[:axis][:data], ["#{0}", "#{(datamax*0.5).to_i}", "#{datamax.to_i}"]]
|
78
81
|
}
|
79
82
|
options.merge!(axis_labels)
|
83
|
+
elsif @labels[:x_axis]
|
84
|
+
x_axis_label = {
|
85
|
+
:axis_with_labels => 'x',
|
86
|
+
:axis_labels => @labels[:x_axis][:data].nil? ? self.map{|n|"#{n}"} : @labels[:x_axis][:data]
|
87
|
+
}
|
88
|
+
options.merge!(x_axis_label)
|
89
|
+
elsif @labels[:y_axis]
|
90
|
+
y_axis_label = {
|
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]
|
93
|
+
}
|
94
|
+
options.merge!(y_axis_label)
|
80
95
|
end
|
81
96
|
end
|
82
|
-
puts "ended with label settings => #{options.inspect}"
|
83
97
|
options
|
84
98
|
end
|
85
99
|
|
@@ -95,7 +109,7 @@ module Analytica
|
|
95
109
|
include Strict
|
96
110
|
|
97
111
|
def datamax
|
98
|
-
(max > 0) ? (1.
|
112
|
+
(max > 0) ? (1.1*max) : 1
|
99
113
|
end
|
100
114
|
|
101
115
|
def to_linegraph(params={})
|
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: 59
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 18
|
10
|
+
version: 0.0.18
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Raeez Lorgat
|