technical_graph 0.3.2 → 0.4.0
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/DOCUMENTATION.md +14 -4
- data/DOCUMENTATION.textile +68 -1
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/VERSION +1 -1
- data/lib/technical_graph/array.rb +25 -0
- data/lib/technical_graph/data_layer.rb +45 -7
- data/lib/technical_graph/data_layer_processor.rb +4 -1
- data/lib/technical_graph/data_layer_processor_noise_removal.rb +4 -23
- data/lib/technical_graph/data_layer_processor_simple_smoother.rb +9 -3
- data/lib/technical_graph/graph_axis.rb +69 -217
- data/lib/technical_graph/graph_color_library.rb +38 -22
- data/lib/technical_graph/graph_data_processor.rb +13 -1
- data/lib/technical_graph/graph_image_drawer.rb +97 -114
- data/lib/technical_graph/graph_image_drawer_module.rb +72 -0
- data/lib/technical_graph/graph_image_drawer_rasem.rb +185 -0
- data/lib/technical_graph/graph_image_drawer_rmagick.rb +237 -0
- data/lib/technical_graph.rb +23 -8
- data/test/helper.rb +4 -0
- data/test/test_technical_autocolor.rb +2 -2
- data/test/test_technical_axis_enlarge.rb +2 -3
- data/test/test_technical_graph.rb +4 -3
- data/test/test_technical_graph_axis.rb +2 -2
- data/test/test_technical_multilayer.rb +2 -2
- data/test/test_technical_rasem.rb +22 -0
- data/test/test_technical_readme.rb +39 -18
- data/test/test_technical_simple_graph.rb +2 -2
- data/test/test_technical_smoother.rb +2 -2
- data/test/test_technical_smoother_adv.rb +15 -5
- metadata +32 -14
@@ -0,0 +1,237 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'RMagick'
|
3
|
+
require 'technical_graph/graph_image_drawer_module'
|
4
|
+
|
5
|
+
class GraphImageDrawerRmagick
|
6
|
+
include GraphImageDrawerModule
|
7
|
+
|
8
|
+
def create_blank_image
|
9
|
+
@image = Magick::ImageList.new
|
10
|
+
@image.new_image(
|
11
|
+
width,
|
12
|
+
height,
|
13
|
+
Magick::HatchFill.new(
|
14
|
+
options[:background_color],
|
15
|
+
options[:background_hatch_color]
|
16
|
+
)
|
17
|
+
)
|
18
|
+
|
19
|
+
return @image
|
20
|
+
end
|
21
|
+
|
22
|
+
# Layer used for drawing axis
|
23
|
+
def axis_draw_object
|
24
|
+
plot_axis = Magick::Draw.new
|
25
|
+
|
26
|
+
plot_axis.stroke_antialias(options[:antialias])
|
27
|
+
plot_axis.text_antialias(options[:antialias])
|
28
|
+
plot_axis.fill_opacity(1.0)
|
29
|
+
plot_axis.stroke(options[:axis_color])
|
30
|
+
plot_axis.stroke_opacity(1.0)
|
31
|
+
plot_axis.stroke_width(1.0)
|
32
|
+
plot_axis.stroke_linecap('square')
|
33
|
+
plot_axis.stroke_linejoin('miter')
|
34
|
+
|
35
|
+
plot_axis.pointsize(options[:axis_font_size])
|
36
|
+
plot_axis.font_family('helvetica')
|
37
|
+
plot_axis.font_style(Magick::NormalStyle)
|
38
|
+
plot_axis.text_align(Magick::LeftAlign)
|
39
|
+
plot_axis.text_undercolor(options[:background_color])
|
40
|
+
|
41
|
+
return plot_axis
|
42
|
+
end
|
43
|
+
|
44
|
+
# Layer used for drawing main labels (parameter, value)
|
45
|
+
def axis_labels_draw_object
|
46
|
+
draw = axis_draw_object
|
47
|
+
draw.pointsize(options[:axis_label_font_size])
|
48
|
+
draw.font_style(Magick::NormalStyle)
|
49
|
+
draw.text_align(Magick::CenterAlign)
|
50
|
+
|
51
|
+
return draw
|
52
|
+
end
|
53
|
+
|
54
|
+
# Layer used for drawing value labels
|
55
|
+
def layer_value_labels_draw_object(layer)
|
56
|
+
draw = axis_draw_object
|
57
|
+
draw.pointsize(options[:layers_font_size])
|
58
|
+
return draw
|
59
|
+
end
|
60
|
+
|
61
|
+
# Layer used for drawing chart, lines and dots
|
62
|
+
def layer_draw_object(layer)
|
63
|
+
draw = axis_draw_object
|
64
|
+
draw.fill(layer.color)
|
65
|
+
draw.stroke(layer.color)
|
66
|
+
return draw
|
67
|
+
end
|
68
|
+
|
69
|
+
# Create no-stroke draw object
|
70
|
+
def layer_no_stroke(_draw)
|
71
|
+
draw = _draw.clone
|
72
|
+
draw.stroke_opacity(0.0)
|
73
|
+
draw.stroke_width(0.0)
|
74
|
+
return draw
|
75
|
+
end
|
76
|
+
|
77
|
+
# Create no-fill draw object
|
78
|
+
def layer_no_fill(_draw)
|
79
|
+
draw = _draw.clone
|
80
|
+
draw.fill_opacity(0.0)
|
81
|
+
return draw
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
# Draw both array axis
|
86
|
+
def axis(x_array, y_array, _options = { :color => 'black', :width => 1 }, render_labels = false, x_labels = [], y_labels = [])
|
87
|
+
# for single axis
|
88
|
+
x_array = [x_array] if not x_array.kind_of? Array
|
89
|
+
y_array = [y_array] if not y_array.kind_of? Array
|
90
|
+
|
91
|
+
plot_axis = axis_draw_object
|
92
|
+
plot_axis.stroke(_options[:color])
|
93
|
+
plot_axis.stroke_width(_options[:width])
|
94
|
+
plot_axis_text = layer_no_stroke(plot_axis)
|
95
|
+
plot_axis_text.fill(_options[:color])
|
96
|
+
|
97
|
+
x_array.each_with_index do |x, i|
|
98
|
+
plot_axis.line(x, 0, x, height)
|
99
|
+
|
100
|
+
# labels
|
101
|
+
label = x_labels[i]
|
102
|
+
if render_labels and not label.nil?
|
103
|
+
label = "#{truncate_string % label}"
|
104
|
+
plot_axis_text.text(x + 15, height - 15, label)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
y_array.each_with_index do |y, i|
|
109
|
+
plot_axis.line(0, y, width, y)
|
110
|
+
|
111
|
+
# labels
|
112
|
+
label = y_labels[i]
|
113
|
+
if render_labels and not label.nil?
|
114
|
+
label = "#{truncate_string % label}"
|
115
|
+
plot_axis_text.text(15, y + 15, label)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
plot_axis.draw(@image)
|
120
|
+
plot_axis_text.draw(@image)
|
121
|
+
end
|
122
|
+
|
123
|
+
# Label for parameters and values
|
124
|
+
def axis_labels(parameter_label, value_label, _options = { :color => 'black', :width => 1, :size => 20 })
|
125
|
+
if options[:x_axis_label].to_s.size > 0
|
126
|
+
plot = axis_labels_draw_object
|
127
|
+
plot.stroke(_options[:color])
|
128
|
+
plot.stroke_width(_options[:width])
|
129
|
+
|
130
|
+
plot.text(
|
131
|
+
(width / 2).to_i,
|
132
|
+
height - 40,
|
133
|
+
options[:x_axis_label].to_s
|
134
|
+
)
|
135
|
+
plot.draw(@image)
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
if options[:y_axis_label].to_s.size > 0
|
140
|
+
plot = axis_labels_draw_object
|
141
|
+
plot.stroke(_options[:color])
|
142
|
+
plot.stroke_width(_options[:width])
|
143
|
+
plot = plot.rotate(90)
|
144
|
+
|
145
|
+
plot.text(
|
146
|
+
(height / 2).to_i,
|
147
|
+
-40,
|
148
|
+
options[:y_axis_label].to_s
|
149
|
+
)
|
150
|
+
plot.draw(@image)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def render_data_layer(l, coords)
|
155
|
+
# value labels
|
156
|
+
if l.value_labels
|
157
|
+
plot = layer_no_stroke(layer_value_labels_draw_object(l))
|
158
|
+
coords.each do |c|
|
159
|
+
string_label = "#{truncate_string % c[:dy]}"
|
160
|
+
plot.text(
|
161
|
+
c[:ax] + 5, c[:ay],
|
162
|
+
string_label
|
163
|
+
)
|
164
|
+
end
|
165
|
+
plot.draw(@image)
|
166
|
+
end
|
167
|
+
|
168
|
+
# lines and dots
|
169
|
+
plot = layer_draw_object(l)
|
170
|
+
coords.each do |c|
|
171
|
+
# additional circle
|
172
|
+
plot.circle(c[:ax], c[:ay], c[:ax] + 2, c[:ay])
|
173
|
+
plot.circle(c[:bx], c[:by], c[:bx] + 2, c[:by])
|
174
|
+
|
175
|
+
# line
|
176
|
+
plot.line(
|
177
|
+
c[:ax], c[:ay],
|
178
|
+
c[:bx], c[:by]
|
179
|
+
)
|
180
|
+
|
181
|
+
drawer.post_dot_drawn(c[:ax], c[:ay])
|
182
|
+
drawer.post_dot_drawn(c[:bx], c[:by])
|
183
|
+
end
|
184
|
+
plot.draw(@image)
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
def legend(legend_data)
|
189
|
+
legend_data.each do |l|
|
190
|
+
plot = axis_draw_object
|
191
|
+
plot_text = layer_no_stroke(plot)
|
192
|
+
|
193
|
+
plot.fill(l[:color])
|
194
|
+
plot.stroke(l[:color])
|
195
|
+
plot_text.fill(l[:color])
|
196
|
+
|
197
|
+
plot.circle(l[:x], l[:y], l[:x] + 2, l[:y])
|
198
|
+
plot_text.text(l[:x] + 5, l[:y], l[:label])
|
199
|
+
|
200
|
+
plot.draw(@image)
|
201
|
+
plot_text.draw(@image)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
def close
|
206
|
+
# only for compatibility
|
207
|
+
@closed = true
|
208
|
+
end
|
209
|
+
|
210
|
+
def closed?
|
211
|
+
@closed
|
212
|
+
end
|
213
|
+
|
214
|
+
# Save output to file
|
215
|
+
def save(file)
|
216
|
+
t = Time.now
|
217
|
+
|
218
|
+
@image.write(file)
|
219
|
+
|
220
|
+
logger.debug "saving image"
|
221
|
+
logger.debug " TIME COST #{Time.now - t}"
|
222
|
+
end
|
223
|
+
|
224
|
+
# Export image
|
225
|
+
def to_format(format)
|
226
|
+
t = Time.now
|
227
|
+
i = @image.flatten_images
|
228
|
+
i.format = format
|
229
|
+
blob = i.to_blob
|
230
|
+
|
231
|
+
logger.debug "exporting image as string"
|
232
|
+
logger.debug " TIME COST #{Time.now - t}"
|
233
|
+
|
234
|
+
return blob
|
235
|
+
end
|
236
|
+
|
237
|
+
end
|
data/lib/technical_graph.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#encoding: utf-8
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
|
+
require 'logger'
|
4
5
|
require 'technical_graph/data_layer'
|
5
6
|
require 'technical_graph/graph_data_processor'
|
6
7
|
require 'technical_graph/graph_image_drawer'
|
@@ -20,21 +21,35 @@ class TechnicalGraph
|
|
20
21
|
|
21
22
|
def initialize(options = { })
|
22
23
|
@options = options
|
24
|
+
|
25
|
+
@log_device = options[:log_device] || STDOUT
|
26
|
+
@logger = Logger.new(@log_device)
|
27
|
+
@logger.level = options[:log_level] || Logger::INFO
|
28
|
+
|
23
29
|
@data_processor = GraphDataProcessor.new(self)
|
24
30
|
@image_drawer = GraphImageDrawer.new(self)
|
25
31
|
@axis = GraphAxis.new(self)
|
26
32
|
@layers = Array.new
|
27
33
|
end
|
28
|
-
attr_reader :options
|
29
|
-
attr_reader :data_processor
|
30
|
-
attr_reader :image_drawer
|
31
|
-
attr_reader :axis
|
32
34
|
|
33
|
-
attr_reader :layers
|
35
|
+
attr_reader :options, :data_processor, :image_drawer, :axis, :layers, :logger
|
36
|
+
|
37
|
+
# Best output image format, used for testing
|
38
|
+
def best_output_format
|
39
|
+
if options[:drawer_class] == :rasem
|
40
|
+
return 'svg'
|
41
|
+
end
|
42
|
+
if options[:drawer_class] == :rmagick
|
43
|
+
return 'png'
|
44
|
+
end
|
45
|
+
end
|
34
46
|
|
35
47
|
# Add new data layer to layer array
|
36
|
-
def add_layer(data = [], options = {})
|
37
|
-
|
48
|
+
def add_layer(data = [], options = { })
|
49
|
+
t = Time.now
|
50
|
+
@layers << DataLayer.new(data, options, self)
|
51
|
+
logger.debug "layer added, size #{data.size}"
|
52
|
+
logger.debug " TIME COST #{Time.now - t}"
|
38
53
|
end
|
39
54
|
|
40
55
|
# Create graph
|
@@ -44,7 +59,7 @@ class TechnicalGraph
|
|
44
59
|
@layers.each do |l|
|
45
60
|
@data_processor.process_data_layer(l)
|
46
61
|
end
|
47
|
-
|
62
|
+
|
48
63
|
# draw axis
|
49
64
|
@axis.render_on_image(@image)
|
50
65
|
# draw layers
|
data/test/helper.rb
CHANGED
@@ -15,5 +15,9 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
15
15
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
16
16
|
require 'technical_graph'
|
17
17
|
|
18
|
+
# default drawer class
|
19
|
+
#DRAWER_CLASS = :rmagick
|
20
|
+
DRAWER_CLASS = :rasem
|
21
|
+
|
18
22
|
class Test::Unit::TestCase
|
19
23
|
end
|
@@ -83,8 +83,8 @@ class TestTechnicalAutocolor < Test::Unit::TestCase
|
|
83
83
|
|
84
84
|
@tg.render
|
85
85
|
|
86
|
-
@tg.image_drawer.save_to_file(
|
87
|
-
@tg.image_drawer.
|
86
|
+
@tg.image_drawer.save_to_file("samples/tests/test_autocolor.#{@tg.best_output_format}")
|
87
|
+
@tg.image_drawer.to_format(@tg.best_output_format).class.should == String
|
88
88
|
|
89
89
|
end
|
90
90
|
end
|
@@ -59,9 +59,8 @@ class TestTechnicalAxisEnlarge < Test::Unit::TestCase
|
|
59
59
|
|
60
60
|
@tg.render
|
61
61
|
|
62
|
-
@tg.image_drawer.save_to_file(
|
63
|
-
@tg.image_drawer.
|
64
|
-
@tg.image_drawer.to_png.class.should == String
|
62
|
+
@tg.image_drawer.save_to_file("samples/tests/test_axis_enlarge.#{@tg.best_output_format}")
|
63
|
+
@tg.image_drawer.to_format(@tg.best_output_format).class.should == String
|
65
64
|
|
66
65
|
end
|
67
66
|
end
|
@@ -70,11 +70,12 @@ class TestTechnicalGraph < Test::Unit::TestCase
|
|
70
70
|
layer.processed_data.size.should == 2 * @data_size
|
71
71
|
|
72
72
|
# @tg.render
|
73
|
-
# @tg.image.save_to_file(
|
73
|
+
# @tg.image.save_to_file("samples/tests/test1.#{@th.best_output_format}")
|
74
74
|
end
|
75
75
|
|
76
76
|
should 'has ability to filter records with similar x\'es' do
|
77
|
-
|
77
|
+
# was turned off by default, performance issue
|
78
|
+
@tg.add_layer([], {:perform_parameter_uniq => true})
|
78
79
|
layer = @tg.layers.last
|
79
80
|
layer.raw_data.size.should == 0
|
80
81
|
layer.processed_data.size.should == 0
|
@@ -103,7 +104,7 @@ class TestTechnicalGraph < Test::Unit::TestCase
|
|
103
104
|
|
104
105
|
# uniq check
|
105
106
|
layer.append_data([{ :z => 0, :y => 1 }])
|
106
|
-
layer.append_data([{}])
|
107
|
+
layer.append_data([{ }])
|
107
108
|
layer.raw_data.size.should == 1
|
108
109
|
layer.processed_data.size.should == 1
|
109
110
|
end
|
@@ -267,7 +267,7 @@ class TestTechnicalGraphAxis < Test::Unit::TestCase
|
|
267
267
|
@tg.axis.parameter_axis.should == [-8.0, -6.0, -4.0, -2.0, 0.0, 2.0, 4.0, 6.0]
|
268
268
|
@tg.axis.value_axis.should == [-4.0, -2.0, 0.0, 2.0]
|
269
269
|
|
270
|
-
@tg.image_drawer.save_to_file(
|
270
|
+
@tg.image_drawer.save_to_file("samples/tests/test1.#{@tg.best_output_format}")
|
271
271
|
end
|
272
272
|
|
273
273
|
|
@@ -303,7 +303,7 @@ class TestTechnicalGraphAxis < Test::Unit::TestCase
|
|
303
303
|
|
304
304
|
@tg.render
|
305
305
|
|
306
|
-
@tg.image_drawer.save_to_file(
|
306
|
+
@tg.image_drawer.save_to_file("samples/tests/test2.#{@tg.best_output_format}")
|
307
307
|
end
|
308
308
|
|
309
309
|
end
|
@@ -87,8 +87,8 @@ class TestTechnicalMultilayer < Test::Unit::TestCase
|
|
87
87
|
|
88
88
|
@tg.render
|
89
89
|
|
90
|
-
@tg.image_drawer.save_to_file(
|
91
|
-
@tg.image_drawer.
|
90
|
+
@tg.image_drawer.save_to_file("samples/tests/test_multilayer.#{@tg.best_output_format}")
|
91
|
+
@tg.image_drawer.to_format(@tg.best_output_format).class.should == String
|
92
92
|
|
93
93
|
end
|
94
94
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestTechnicalRasem < Test::Unit::TestCase
|
4
|
+
context 'drawing SVG graphs using rasem' do
|
5
|
+
|
6
|
+
should 'do some initials' do
|
7
|
+
fake_drawer_class = Struct.new('GraphImageDrawerFake', :width, :height)
|
8
|
+
fake_drawer = fake_drawer_class.new
|
9
|
+
fake_drawer[:width] = 800
|
10
|
+
fake_drawer[:height] = 600
|
11
|
+
d = GraphImageDrawerRasem.new(fake_drawer)
|
12
|
+
d.x_axis([ 0, 100, 200, 300 ])
|
13
|
+
d.close
|
14
|
+
|
15
|
+
d.save("samples/tests/rasem_init.svg")
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
end
|
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
+
# run only latest test to create new graphs for documentation
|
4
|
+
DO_NOT_RUN_OLD_TESTS = true
|
5
|
+
|
3
6
|
class TestTechnicalReadme < Test::Unit::TestCase
|
4
7
|
context 'generate sample graphs using readme options description' do
|
5
8
|
setup do
|
@@ -31,7 +34,7 @@ class TestTechnicalReadme < Test::Unit::TestCase
|
|
31
34
|
|
32
35
|
#
|
33
36
|
should 'create simplest graph' do
|
34
|
-
return
|
37
|
+
return if DO_NOT_RUN_OLD_TESTS
|
35
38
|
@tg = TechnicalGraph.new
|
36
39
|
@tg.add_layer(@simple_data_array)
|
37
40
|
@tg.render
|
@@ -39,13 +42,13 @@ class TestTechnicalReadme < Test::Unit::TestCase
|
|
39
42
|
@tg.image_drawer.save_to_file(file_name)
|
40
43
|
|
41
44
|
# test
|
42
|
-
@tg.image_drawer.
|
45
|
+
@tg.image_drawer.to_format(@tg.best_output_format).class.should == String
|
43
46
|
File.exist?(file_name).should == true
|
44
47
|
end
|
45
48
|
|
46
49
|
#
|
47
50
|
should 'create 2-layer graph' do
|
48
|
-
return
|
51
|
+
return if DO_NOT_RUN_OLD_TESTS
|
49
52
|
@tg = TechnicalGraph.new
|
50
53
|
@tg.add_layer(@simple_data_array)
|
51
54
|
@tg.add_layer(@simple_data_array_b)
|
@@ -54,13 +57,13 @@ class TestTechnicalReadme < Test::Unit::TestCase
|
|
54
57
|
@tg.image_drawer.save_to_file(file_name)
|
55
58
|
|
56
59
|
# test
|
57
|
-
@tg.image_drawer.
|
60
|
+
@tg.image_drawer.to_format(@tg.best_output_format).class.should == String
|
58
61
|
File.exist?(file_name).should == true
|
59
62
|
end
|
60
63
|
|
61
64
|
#
|
62
65
|
should 'change ranges' do
|
63
|
-
return
|
66
|
+
return if DO_NOT_RUN_OLD_TESTS
|
64
67
|
@tg = TechnicalGraph.new(
|
65
68
|
{
|
66
69
|
:x_min => -2,
|
@@ -74,12 +77,12 @@ class TestTechnicalReadme < Test::Unit::TestCase
|
|
74
77
|
@tg.image_drawer.save_to_file(file_name)
|
75
78
|
|
76
79
|
# test
|
77
|
-
@tg.image_drawer.
|
80
|
+
@tg.image_drawer.to_format(@tg.best_output_format).class.should == String
|
78
81
|
File.exist?(file_name).should == true
|
79
82
|
end
|
80
83
|
|
81
84
|
should 'change ranges (fixed)' do
|
82
|
-
return
|
85
|
+
return if DO_NOT_RUN_OLD_TESTS
|
83
86
|
@tg = TechnicalGraph.new(
|
84
87
|
{
|
85
88
|
:x_min => 1,
|
@@ -94,12 +97,12 @@ class TestTechnicalReadme < Test::Unit::TestCase
|
|
94
97
|
@tg.image_drawer.save_to_file(file_name)
|
95
98
|
|
96
99
|
# test
|
97
|
-
@tg.image_drawer.
|
100
|
+
@tg.image_drawer.to_format(@tg.best_output_format).class.should == String
|
98
101
|
File.exist?(file_name).should == true
|
99
102
|
end
|
100
103
|
|
101
104
|
should 'fixed amount of axis' do
|
102
|
-
return
|
105
|
+
return if DO_NOT_RUN_OLD_TESTS
|
103
106
|
@tg = TechnicalGraph.new(
|
104
107
|
{
|
105
108
|
:x_axis_fixed_interval => false,
|
@@ -113,12 +116,12 @@ class TestTechnicalReadme < Test::Unit::TestCase
|
|
113
116
|
@tg.image_drawer.save_to_file(file_name)
|
114
117
|
|
115
118
|
# test
|
116
|
-
@tg.image_drawer.
|
119
|
+
@tg.image_drawer.to_format(@tg.best_output_format).class.should == String
|
117
120
|
File.exist?(file_name).should == true
|
118
121
|
end
|
119
122
|
|
120
123
|
should 'fixed axis interval' do
|
121
|
-
return
|
124
|
+
return if DO_NOT_RUN_OLD_TESTS
|
122
125
|
@tg = TechnicalGraph.new(
|
123
126
|
{
|
124
127
|
:x_axis_fixed_interval => true,
|
@@ -142,12 +145,12 @@ class TestTechnicalReadme < Test::Unit::TestCase
|
|
142
145
|
@tg.image_drawer.save_to_file(file_name)
|
143
146
|
|
144
147
|
# test
|
145
|
-
@tg.image_drawer.
|
148
|
+
@tg.image_drawer.to_format(@tg.best_output_format).class.should == String
|
146
149
|
File.exist?(file_name).should == true
|
147
150
|
end
|
148
151
|
|
149
152
|
should 'let choose axis label' do
|
150
|
-
return
|
153
|
+
return if DO_NOT_RUN_OLD_TESTS
|
151
154
|
@tg = TechnicalGraph.new(
|
152
155
|
{
|
153
156
|
:x_axis_label => 'parameter',
|
@@ -160,13 +163,13 @@ class TestTechnicalReadme < Test::Unit::TestCase
|
|
160
163
|
@tg.image_drawer.save_to_file(file_name)
|
161
164
|
|
162
165
|
# test
|
163
|
-
@tg.image_drawer.
|
166
|
+
@tg.image_drawer.to_format(@tg.best_output_format).class.should == String
|
164
167
|
File.exist?(file_name).should == true
|
165
168
|
end
|
166
169
|
|
167
170
|
|
168
171
|
should 'test truncate string' do
|
169
|
-
|
172
|
+
return if DO_NOT_RUN_OLD_TESTS
|
170
173
|
@tg = TechnicalGraph.new(
|
171
174
|
{
|
172
175
|
:truncate_string => "%.3f"
|
@@ -180,12 +183,12 @@ class TestTechnicalReadme < Test::Unit::TestCase
|
|
180
183
|
@tg.image_drawer.save_to_file(file_name)
|
181
184
|
|
182
185
|
# test
|
183
|
-
@tg.image_drawer.
|
186
|
+
@tg.image_drawer.to_format(@tg.best_output_format).class.should == String
|
184
187
|
File.exist?(file_name).should == true
|
185
188
|
end
|
186
189
|
|
187
190
|
should 'test truncate string 2' do
|
188
|
-
|
191
|
+
return if DO_NOT_RUN_OLD_TESTS
|
189
192
|
@tg = TechnicalGraph.new(
|
190
193
|
{
|
191
194
|
:truncate_string => "%.1f"
|
@@ -199,9 +202,27 @@ class TestTechnicalReadme < Test::Unit::TestCase
|
|
199
202
|
@tg.image_drawer.save_to_file(file_name)
|
200
203
|
|
201
204
|
# test
|
202
|
-
@tg.image_drawer.
|
205
|
+
@tg.image_drawer.to_format(@tg.best_output_format).class.should == String
|
203
206
|
File.exist?(file_name).should == true
|
204
207
|
end
|
205
208
|
|
209
|
+
should 'test image size' do
|
210
|
+
#return if DO_NOT_RUN_OLD_TESTS
|
211
|
+
@tg = TechnicalGraph.new(
|
212
|
+
{
|
213
|
+
:width => 600,
|
214
|
+
:height => 300
|
215
|
+
})
|
216
|
+
@tg.add_layer(@simple_data_array)
|
217
|
+
@tg.render
|
218
|
+
file_name = 'samples/readme/09_image_size.png'
|
219
|
+
@tg.image_drawer.save_to_file(file_name)
|
220
|
+
|
221
|
+
# test
|
222
|
+
@tg.image_drawer.to_format(@tg.best_output_format).class.should == String
|
223
|
+
File.exist?(file_name).should == true
|
224
|
+
end
|
225
|
+
|
226
|
+
|
206
227
|
end
|
207
228
|
end
|
@@ -55,8 +55,8 @@ class TestTechnicalSimpleGraph < Test::Unit::TestCase
|
|
55
55
|
|
56
56
|
@tg.render
|
57
57
|
|
58
|
-
@tg.image_drawer.save_to_file(
|
59
|
-
@tg.image_drawer.
|
58
|
+
@tg.image_drawer.save_to_file("samples/tests/test_simple.#{@tg.best_output_format}")
|
59
|
+
@tg.image_drawer.to_format(@tg.best_output_format).class.should == String
|
60
60
|
|
61
61
|
end
|
62
62
|
end
|
@@ -126,7 +126,7 @@ class TestTechnicalSmoother < Test::Unit::TestCase
|
|
126
126
|
tg.add_layer(layer_data_b, layer_params_b)
|
127
127
|
|
128
128
|
tg.render
|
129
|
-
tg.image_drawer.save_to_file(
|
129
|
+
tg.image_drawer.save_to_file("samples/tests/test_simple_gauss.#{tg.best_output_format}")
|
130
130
|
end
|
131
131
|
|
132
132
|
should 'create simple graph using only layer params' do
|
@@ -204,7 +204,7 @@ class TestTechnicalSmoother < Test::Unit::TestCase
|
|
204
204
|
|
205
205
|
|
206
206
|
tg.render
|
207
|
-
tg.image_drawer.save_to_file(
|
207
|
+
tg.image_drawer.save_to_file("samples/tests/test_smoothing_multiple.#{tg.best_output_format}")
|
208
208
|
end
|
209
209
|
|
210
210
|
|
@@ -52,8 +52,9 @@ class TestTechnicalSmootherAdv < Test::Unit::TestCase
|
|
52
52
|
|
53
53
|
tg = TechnicalGraph.new(
|
54
54
|
{
|
55
|
-
:
|
56
|
-
:
|
55
|
+
:drawer_class => DRAWER_CLASS,
|
56
|
+
:width => 2000, #8000,
|
57
|
+
:height => 1500, #6000,
|
57
58
|
|
58
59
|
:legend => true,
|
59
60
|
:legend_auto => true,
|
@@ -61,9 +62,15 @@ class TestTechnicalSmootherAdv < Test::Unit::TestCase
|
|
61
62
|
:legend_margin => 60,
|
62
63
|
:legend_x => 50,
|
63
64
|
:legend_y => 50,
|
65
|
+
|
66
|
+
:log_level => Logger::DEBUG,
|
67
|
+
|
68
|
+
:x_axis_label => "Parameter",
|
69
|
+
:y_axis_label => "Value",
|
70
|
+
:axis_label_font_size => 28
|
64
71
|
}
|
65
72
|
)
|
66
|
-
max = 2000
|
73
|
+
max = 50 #2000
|
67
74
|
|
68
75
|
layer_data = Array.new
|
69
76
|
(0..max).each do |i|
|
@@ -78,6 +85,7 @@ class TestTechnicalSmootherAdv < Test::Unit::TestCase
|
|
78
85
|
|
79
86
|
# adding simple layer
|
80
87
|
layer_params = {
|
88
|
+
#:perform_parameter_uniq => true,
|
81
89
|
:antialias => false,
|
82
90
|
:color => 'red',
|
83
91
|
:label => 'raw',
|
@@ -85,7 +93,9 @@ class TestTechnicalSmootherAdv < Test::Unit::TestCase
|
|
85
93
|
:simple_smoother => false,
|
86
94
|
:simple_smoother_level => 1,
|
87
95
|
:simple_smoother_strategy => :gauss,
|
88
|
-
:simple_smoother_x => false
|
96
|
+
:simple_smoother_x => false,
|
97
|
+
|
98
|
+
:value_labels => true
|
89
99
|
}
|
90
100
|
layer_params_c = layer_params.clone.merge(
|
91
101
|
{
|
@@ -105,7 +115,7 @@ class TestTechnicalSmootherAdv < Test::Unit::TestCase
|
|
105
115
|
tg.add_layer(layer_data.clone, layer_params_d)
|
106
116
|
|
107
117
|
tg.render
|
108
|
-
tg.image_drawer.save_to_file(
|
118
|
+
tg.image_drawer.save_to_file("samples/tests/test_smoothing_x_values.#{tg.best_output_format}")
|
109
119
|
end
|
110
120
|
|
111
121
|
|