technical_graph 0.5.0 → 0.5.1
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/VERSION +1 -1
- data/lib/technical_graph/graph_data_processor.rb +18 -0
- data/test/test_technical_fix1.rb +64 -0
- metadata +5 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1
|
@@ -68,21 +68,39 @@ class GraphDataProcessor
|
|
68
68
|
|
69
69
|
# Ranges without zoom
|
70
70
|
def raw_x_min
|
71
|
+
enforce_x_axis_range
|
71
72
|
options[:x_min]
|
72
73
|
end
|
73
74
|
|
74
75
|
def raw_x_max
|
76
|
+
enforce_x_axis_range
|
75
77
|
options[:x_max]
|
76
78
|
end
|
77
79
|
|
78
80
|
def raw_y_min
|
81
|
+
enforce_y_axis_range
|
79
82
|
options[:y_min]
|
80
83
|
end
|
81
84
|
|
82
85
|
def raw_y_max
|
86
|
+
enforce_y_axis_range
|
83
87
|
options[:y_max]
|
84
88
|
end
|
85
89
|
|
90
|
+
def enforce_x_axis_range
|
91
|
+
if options[:x_min] == options[:x_max]
|
92
|
+
options[:x_min] -= 0.01
|
93
|
+
options[:x_max] += 0.01
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def enforce_y_axis_range
|
98
|
+
if options[:y_min] == options[:y_max]
|
99
|
+
options[:y_min] -= 0.01
|
100
|
+
options[:y_max] += 0.01
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
86
104
|
# Ranges with zoom
|
87
105
|
def x_min
|
88
106
|
calc_x_zoomed([self.raw_x_min]).first
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestTechnicalFix1 < Test::Unit::TestCase
|
4
|
+
context 'y_min = y_max' do
|
5
|
+
should 'draw graph without error - NaN' do
|
6
|
+
@tg = TechnicalGraph.new(
|
7
|
+
{
|
8
|
+
# code from HomeIO
|
9
|
+
:x_axis_label => 'label',
|
10
|
+
:y_axis_label => 'value',
|
11
|
+
|
12
|
+
:x_axis_interval => 1.0,
|
13
|
+
:y_axis_count => 10,
|
14
|
+
:x_axis_fixed_interval => true,
|
15
|
+
:y_axis_fixed_interval => false,
|
16
|
+
:width => 800,
|
17
|
+
:height => 600,
|
18
|
+
|
19
|
+
:axis_antialias => false,
|
20
|
+
:layers_font_size => 10,
|
21
|
+
:axis_font_size => 10,
|
22
|
+
:axis_label_font_size => 24,
|
23
|
+
|
24
|
+
:x_min => -10.0,
|
25
|
+
:x_max => 40.0,
|
26
|
+
:y_max => 10.0,
|
27
|
+
:y_min => 10.0
|
28
|
+
}
|
29
|
+
)
|
30
|
+
|
31
|
+
max = 50
|
32
|
+
layer_data_a = Array.new
|
33
|
+
(0..max).each do |i|
|
34
|
+
layer_data_a << { :x => -10.0 + i.to_f, :y => 10.0 }
|
35
|
+
end
|
36
|
+
@tg.add_layer(layer_data_a)
|
37
|
+
@tg.render
|
38
|
+
@tg.image_drawer.to_format(@tg.best_output_format).class.should == String
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
should 'draw graph without another error' do
|
43
|
+
@tg = TechnicalGraph.new(
|
44
|
+
{
|
45
|
+
:x_min => -10.0,
|
46
|
+
:x_max => 40.0,
|
47
|
+
:y_max => 10.0,
|
48
|
+
:y_min => 10.0
|
49
|
+
}
|
50
|
+
)
|
51
|
+
|
52
|
+
max = 50
|
53
|
+
layer_data_a = Array.new
|
54
|
+
(0..max).each do |i|
|
55
|
+
layer_data_a << { :x => -10.0 + i.to_f, :y => 10.0 }
|
56
|
+
end
|
57
|
+
@tg.add_layer(layer_data_a)
|
58
|
+
@tg.render
|
59
|
+
@tg.image_drawer.to_format(@tg.best_output_format).class.should == String
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: technical_graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 1
|
10
|
+
version: 0.5.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Aleksander Kwiatkowski
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-11
|
18
|
+
date: 2011-12-11 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -153,6 +153,7 @@ files:
|
|
153
153
|
- test/helper.rb
|
154
154
|
- test/test_technical_autocolor.rb
|
155
155
|
- test/test_technical_axis_enlarge.rb
|
156
|
+
- test/test_technical_fix1.rb
|
156
157
|
- test/test_technical_graph.rb
|
157
158
|
- test/test_technical_graph_axis.rb
|
158
159
|
- test/test_technical_multilayer.rb
|