technical_graph 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE.txt CHANGED
@@ -1,20 +1,165 @@
1
- Copyright (c) 2011 Aleksander Kwiatkowski
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/README.md ADDED
@@ -0,0 +1,117 @@
1
+ technical-graph
2
+ ===============
3
+
4
+ Create neat graphs.
5
+
6
+
7
+ Usage
8
+ -----
9
+
10
+ Check currents test when documentation is not enough :)
11
+
12
+ 1. Create instance
13
+
14
+ > tg = TechnicalGraph.new
15
+
16
+ or
17
+
18
+ > tg = TechnicalGraph.new( options )
19
+
20
+ where:
21
+ * options - Hash of parameters, all parameters are described below.
22
+
23
+ 2. Add layer
24
+
25
+ > tg.add_layer(layer_data)
26
+
27
+ or
28
+
29
+ > tg.add_layer(layer_data, layer_params)
30
+
31
+ where:
32
+ * layer_data - Array of Hashes, like [{:x => 0, :y => 0}, {:x => 1, :y => 1}, ...]
33
+ * layer_params - Hash of other parameters, all parameters will be described later.
34
+
35
+ 3. Render graph
36
+
37
+ > tg.render
38
+
39
+ 4. Save to file
40
+
41
+ > tg.image_drawer.save_to_file('image.png')
42
+
43
+ or get image binary content.
44
+
45
+ > tg.image_drawer.to_format(format)
46
+
47
+ where format is image format, ex. 'png', 'jpeg', ...
48
+
49
+
50
+ Option's Hash
51
+ -------------
52
+
53
+ Default ranges:
54
+
55
+ * options[:x_min]
56
+ * options[:x_max]
57
+ * options[:y_min]
58
+ * options[:y_max]
59
+
60
+ Ranges calculation mode:
61
+
62
+ * options[:xy_behaviour] = :default - ranges can be enlarged
63
+ * options[:xy_behaviour] = :fixed - fixed ranges
64
+
65
+ Axis can be calculated using fixed interval or fixed count per graph.
66
+
67
+ * options[:x_axis_fixed_interval] = true
68
+ * options[:y_axis_fixed_interval] = true
69
+
70
+ If fixed interval is set you should specify interval:
71
+
72
+ * options[:y_axis_interval] = 1.0
73
+ * options[:x_axis_interval] = 1.0
74
+
75
+ ...else, count of axis:
76
+
77
+ * options[:y_axis_count] = 10
78
+ * options[:x_axis_count] = 10
79
+
80
+ Labels has truncate string to define precision. Default it is "%.2f".
81
+
82
+ * options[:truncate_string] = "%.2f"
83
+
84
+ Graph image size:
85
+
86
+ * options[:width]
87
+ * options[:height]
88
+
89
+ Colors:
90
+
91
+ Possible #RRGGBB or color names (ex. 'white').
92
+
93
+ * options[:background_color] - background color of image
94
+ * options[:background_hatch_color] - background hatch color
95
+ * options[:axis_color] - color of axis
96
+
97
+
98
+ Contributing to technical-graph
99
+ -------------------------------
100
+
101
+ [![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=bobik314&url=https://github.com/akwiatkowski/technical_graph&title=technical_graph&language=en_GB&tags=github&category=software)
102
+
103
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
104
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
105
+ * Fork the project
106
+ * Start a feature/bugfix branch
107
+ * Commit and push until you are happy with your contribution
108
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
109
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
110
+
111
+
112
+ Copyright
113
+ ---------
114
+
115
+ Copyright (c) 2011 Aleksander Kwiatkowski. See LICENSE.txt for
116
+ further details.
117
+
data/Rakefile CHANGED
@@ -11,6 +11,7 @@ rescue Bundler::BundlerError => e
11
11
  end
12
12
  require 'rake'
13
13
 
14
+ # http://technicalpickles.com/posts/craft-the-perfect-gem-with-jeweler/
14
15
  require 'jeweler'
15
16
  Jeweler::Tasks.new do |gem|
16
17
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
@@ -25,47 +25,51 @@ class GraphAxis
25
25
  @technical_graph.image_drawer
26
26
  end
27
27
 
28
+ def truncate_string
29
+ options[:truncate_string]
30
+ end
31
+
28
32
  def initialize(technical_graph)
29
33
  @technical_graph = technical_graph
30
34
  end
31
35
 
32
36
  def x_axis_fixed?
33
- options[:x_axises_fixed_interval] == true
37
+ options[:x_axis_fixed_interval] == true
34
38
  end
35
39
 
36
40
  # Value axis has fixed count
37
41
  def y_axis_fixed?
38
- options[:y_axises_fixed_interval] == true
42
+ options[:y_axis_fixed_interval] == true
39
43
  end
40
44
 
41
45
  # Where to put axis values
42
- def value_axises
43
- return calc_axis(data_processor.y_min, data_processor.y_max, options[:y_axises_interval], options[:y_axises_count], y_axis_fixed?)
46
+ def value_axis
47
+ return calc_axis(data_processor.y_min, data_processor.y_max, options[:y_axis_interval], options[:y_axis_count], y_axis_fixed?)
44
48
  end
45
49
 
46
50
  # Where to put axis values
47
- def parameter_axises
48
- return calc_axis(data_processor.x_min, data_processor.x_max, options[:x_axises_interval], options[:x_axises_count], x_axis_fixed?)
51
+ def parameter_axis
52
+ return calc_axis(data_processor.x_min, data_processor.x_max, options[:x_axis_interval], options[:x_axis_count], x_axis_fixed?)
49
53
  end
50
54
 
51
55
  # Calculate axis using 2 methods
52
56
  def calc_axis(from, to, interval, count, fixed_interval)
53
- axises = Array.new
57
+ axis = Array.new
54
58
  l = to - from
55
59
  current = from
56
60
 
57
61
  if fixed_interval
58
62
  while current < to
59
- axises << current
63
+ axis << current
60
64
  current += interval
61
65
  end
62
- return axises
66
+ return axis
63
67
 
64
68
  else
65
69
  (0...count).each do |i|
66
- axises << from + (l.to_f * i.to_f) / count.to_f
70
+ axis << from + (l.to_f * i.to_f) / count.to_f
67
71
  end
68
- return axises
72
+ return axis
69
73
 
70
74
  end
71
75
  end
@@ -106,17 +110,19 @@ class GraphAxis
106
110
  plot_axis_y_text.text_align(Magick::LeftAlign)
107
111
  plot_axis_y_text.text_undercolor(options[:background_color])
108
112
 
109
- value_axises.each do |y|
113
+ value_axis.each do |y|
110
114
  by = image_drawer.calc_bitmap_y(y)
111
115
  plot_axis_y_line.line(
112
116
  0, by.round,
113
117
  @image.columns-1, by.round
114
118
  )
115
119
 
120
+ string_label = "#{truncate_string % y}"
121
+
116
122
  plot_axis_y_text.text(
117
123
  5,
118
124
  by.round + 15,
119
- "#{y}"
125
+ string_label
120
126
  )
121
127
  end
122
128
 
@@ -147,17 +153,19 @@ class GraphAxis
147
153
  plot_axis_x_text.text_align(Magick::LeftAlign)
148
154
  plot_axis_x_text.text_undercolor(options[:background_color])
149
155
 
150
- parameter_axises.each do |x|
156
+ parameter_axis.each do |x|
151
157
  bx = image_drawer.calc_bitmap_x(x)
152
158
  plot_axis_x_line.line(
153
159
  bx.round, 0,
154
160
  bx.round, @image.rows-1
155
161
  )
156
162
 
163
+ string_label = "#{truncate_string % x}"
164
+
157
165
  plot_axis_x_text.text(
158
166
  bx.round + 15,
159
167
  @image.rows - 15,
160
- "#{x}"
168
+ string_label
161
169
  )
162
170
  end
163
171
 
@@ -20,24 +20,24 @@ class GraphDataProcessor
20
20
  def initialize(technical_graph)
21
21
  @technical_graph = technical_graph
22
22
 
23
- options[:x_min] ||= (Time.now - 24 * 3600).to_f
24
- options[:x_max] ||= Time.now.to_f
23
+ options[:x_min] ||= 0.0 #(Time.now - 24 * 3600).to_f
24
+ options[:x_max] ||= 1.0 #Time.now.to_f
25
25
  options[:y_min] ||= 0.0
26
26
  options[:y_max] ||= 1.0
27
27
  # :default - coords are default
28
28
  # :fixed or whatever else - min/max coords are fixed
29
29
  options[:xy_behaviour] ||= :default
30
30
 
31
- # number of axises
32
- options[:y_axises_count] ||= 10
33
- options[:x_axises_count] ||= 10
31
+ # number of axis
32
+ options[:y_axis_count] ||= 10
33
+ options[:x_axis_count] ||= 10
34
34
  # interval
35
- options[:y_axises_interval] ||= 1.0
36
- options[:x_axises_interval] ||= 1.0
37
- # when false then axises are generated to meet 'count'
38
- # when true then axises are generated every X from lowest
39
- options[:x_axises_fixed_interval] = true if options[:x_axises_fixed_interval].nil?
40
- options[:y_axises_fixed_interval] = true if options[:y_axises_fixed_interval].nil?
35
+ options[:y_axis_interval] ||= 1.0
36
+ options[:x_axis_interval] ||= 1.0
37
+ # when false then axis are generated to meet 'count'
38
+ # when true then axis are generated every X from lowest
39
+ options[:x_axis_fixed_interval] = true if options[:x_axis_fixed_interval].nil?
40
+ options[:y_axis_fixed_interval] = true if options[:y_axis_fixed_interval].nil?
41
41
 
42
42
  # default truncate string used for rendering numbers
43
43
  options[:truncate_string] ||= "%.2f"
@@ -185,6 +185,17 @@ class GraphImageDrawer
185
185
  @image.write(file)
186
186
  end
187
187
 
188
+ # Export image
189
+ def to_format(format)
190
+ i = @image.flatten_images
191
+ i.format = format
192
+ return i.to_blob
193
+ end
188
194
 
189
- end
195
+ # Return binary PNG
196
+ def to_png
197
+ to_format('png')
198
+ end
190
199
 
200
+
201
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'technical_graph/axis_layer_draw_module'
4
4
 
5
- # Decide min/max values, recalculate all points and draw axises
5
+ # Decide min/max values, recalculate all points and draw axis
6
6
 
7
7
  class AxisLayer
8
8
  include AxisLayerDrawModule
@@ -17,16 +17,16 @@ class AxisLayer
17
17
  # :fixed or whatever else - min/max coords are fixed
18
18
  @options[:xy_behaviour] ||= :default
19
19
 
20
- # number of axises
21
- @options[:y_axises_count] ||= 10
22
- @options[:x_axises_count] ||= 10
20
+ # number of axis
21
+ @options[:y_axis_count] ||= 10
22
+ @options[:x_axis_count] ||= 10
23
23
  # interval
24
- @options[:y_axises_interval] ||= 1.0
25
- @options[:x_axises_interval] ||= 1.0
26
- # when false then axises are generated to meet 'count'
27
- # when true then axises are generated every X from lowest
28
- @options[:x_axises_fixed_interval] = true if @options[:x_axises_fixed_interval].nil?
29
- @options[:y_axises_fixed_interval] = true if @options[:y_axises_fixed_interval].nil?
24
+ @options[:y_axis_interval] ||= 1.0
25
+ @options[:x_axis_interval] ||= 1.0
26
+ # when false then axis are generated to meet 'count'
27
+ # when true then axis are generated every X from lowest
28
+ @options[:x_axis_fixed_interval] = true if @options[:x_axis_fixed_interval].nil?
29
+ @options[:y_axis_fixed_interval] = true if @options[:y_axis_fixed_interval].nil?
30
30
 
31
31
  @zoom_x = 1.0
32
32
  @zoom_y = 1.0
@@ -1,41 +1,41 @@
1
1
  module AxisLayerDrawModule
2
2
  def x_axis_fixed?
3
- @options[:x_axises_fixed_interval] == true
3
+ @options[:x_axis_fixed_interval] == true
4
4
  end
5
5
 
6
6
  # Value axis has fixed count
7
7
  def y_axis_fixed?
8
- @options[:y_axises_fixed_interval] == true
8
+ @options[:y_axis_fixed_interval] == true
9
9
  end
10
10
 
11
11
  # Where to put axis values
12
- def value_axises
13
- return calc_axis(self.y_min, self.y_max, @options[:y_axises_interval], @options[:y_axises_count], y_axis_fixed?)
12
+ def value_axis
13
+ return calc_axis(self.y_min, self.y_max, @options[:y_axis_interval], @options[:y_axis_count], y_axis_fixed?)
14
14
  end
15
15
 
16
16
  # Where to put axis values
17
- def parameter_axises
18
- return calc_axis(self.x_min, self.x_max, @options[:x_axises_interval], @options[:x_axises_count], x_axis_fixed?)
17
+ def parameter_axis
18
+ return calc_axis(self.x_min, self.x_max, @options[:x_axis_interval], @options[:x_axis_count], x_axis_fixed?)
19
19
  end
20
20
 
21
21
  # Calculate axis using 2 methods
22
22
  def calc_axis(from, to, interval, count, fixed_interval)
23
- axises = Array.new
23
+ axis = Array.new
24
24
  l = to - from
25
25
  current = from
26
26
 
27
27
  if fixed_interval
28
28
  while current < to
29
- axises << current
29
+ axis << current
30
30
  current += interval
31
31
  end
32
- return axises
32
+ return axis
33
33
 
34
34
  else
35
35
  (0...count).each do |i|
36
- axises << from + (l.to_f * i.to_f) / count.to_f
36
+ axis << from + (l.to_f * i.to_f) / count.to_f
37
37
  end
38
- return axises
38
+ return axis
39
39
 
40
40
  end
41
41
  end
@@ -81,7 +81,7 @@ module AxisLayerDrawModule
81
81
  plot_axis_y_text.text_align(Magick::LeftAlign)
82
82
  plot_axis_y_text.text_undercolor(@image.options[:background_color])
83
83
 
84
- value_axises.each do |y|
84
+ value_axis.each do |y|
85
85
  by = calc_bitmap_y(y)
86
86
  plot_axis_y_line.line(
87
87
  0, by.round,
@@ -120,7 +120,7 @@ module AxisLayerDrawModule
120
120
  plot_axis_x_text.text_align(Magick::LeftAlign)
121
121
  plot_axis_x_text.text_undercolor(@image.options[:background_color])
122
122
 
123
- parameter_axises.each do |x|
123
+ parameter_axis.each do |x|
124
124
  bx = calc_bitmap_x(x)
125
125
  plot_axis_x_line.line(
126
126
  bx.round, 0,
@@ -194,12 +194,12 @@ class TestTechnicalGraphAxis < Test::Unit::TestCase
194
194
  :y_max => y_max,
195
195
  :xy_behaviour => :fixed,
196
196
 
197
- :y_axises_count => 10,
198
- :x_axises_count => 10,
199
- :y_axises_interval => 1.0,
200
- :x_axises_interval => 4.0,
201
- :x_axises_fixed_interval => true,
202
- :y_axises_fixed_interval => true
197
+ :y_axis_count => 10,
198
+ :x_axis_count => 10,
199
+ :y_axis_interval => 1.0,
200
+ :x_axis_interval => 4.0,
201
+ :x_axis_fixed_interval => true,
202
+ :y_axis_fixed_interval => true
203
203
  }
204
204
  )
205
205
 
@@ -217,8 +217,8 @@ class TestTechnicalGraphAxis < Test::Unit::TestCase
217
217
 
218
218
  @tg.render
219
219
 
220
- @tg.axis.value_axises.should == [-5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0]
221
- @tg.axis.parameter_axises.should == [-5.0, -1.0, 3.0]
220
+ @tg.axis.value_axis.should == [-5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0]
221
+ @tg.axis.parameter_axis.should == [-5.0, -1.0, 3.0]
222
222
  end
223
223
 
224
224
 
@@ -236,12 +236,12 @@ class TestTechnicalGraphAxis < Test::Unit::TestCase
236
236
  :y_max => y_max,
237
237
  :xy_behaviour => :fixed,
238
238
 
239
- :x_axises_count => 8,
240
- :y_axises_count => 4,
241
- :x_axises_interval => 2.0,
242
- :y_axises_interval => 1.0,
243
- :x_axises_fixed_interval => false,
244
- :y_axises_fixed_interval => false
239
+ :x_axis_count => 8,
240
+ :y_axis_count => 4,
241
+ :x_axis_interval => 2.0,
242
+ :y_axis_interval => 1.0,
243
+ :x_axis_fixed_interval => false,
244
+ :y_axis_fixed_interval => false
245
245
  }
246
246
  )
247
247
 
@@ -259,8 +259,8 @@ class TestTechnicalGraphAxis < Test::Unit::TestCase
259
259
 
260
260
  @tg.render
261
261
 
262
- @tg.axis.parameter_axises.should == [-8.0, -6.0, -4.0, -2.0, 0.0, 2.0, 4.0, 6.0]
263
- @tg.axis.value_axises.should == [-4.0, -2.0, 0.0, 2.0]
262
+ @tg.axis.parameter_axis.should == [-8.0, -6.0, -4.0, -2.0, 0.0, 2.0, 4.0, 6.0]
263
+ @tg.axis.value_axis.should == [-4.0, -2.0, 0.0, 2.0]
264
264
 
265
265
  @tg.image.save_to_file('test1.png')
266
266
  end
@@ -269,12 +269,12 @@ class TestTechnicalGraphAxis < Test::Unit::TestCase
269
269
  should 'draw simple graph' do
270
270
  @tg = TechnicalGraph.new(
271
271
  {
272
- :x_axises_count => 10,
273
- :y_axises_count => 10,
274
- :x_axises_interval => 1.0,
275
- :y_axises_interval => 1.0,
276
- :x_axises_fixed_interval => false,
277
- :y_axises_fixed_interval => false,
272
+ :x_axis_count => 10,
273
+ :y_axis_count => 10,
274
+ :x_axis_interval => 1.0,
275
+ :y_axis_interval => 1.0,
276
+ :x_axis_fixed_interval => false,
277
+ :y_axis_fixed_interval => false,
278
278
 
279
279
  :x_min => -10.0,
280
280
  :x_max => 10.0,
@@ -0,0 +1,82 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{technical_graph}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Aleksander Kwiatkowski"]
12
+ s.date = %q{2011-09-19}
13
+ s.description = %q{Create simple and neat graphs}
14
+ s.email = %q{bobikx@poczta.fm}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".idea/dictionaries/olek.xml",
22
+ ".rvmrc",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.md",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "lib/technical_graph.rb",
30
+ "lib/technical_graph/data_layer.rb",
31
+ "lib/technical_graph/graph_axis.rb",
32
+ "lib/technical_graph/graph_data_processor.rb",
33
+ "lib/technical_graph/graph_image_drawer.rb",
34
+ "lib/technical_graph/refactoring_backup/lib/technical_graph.rb",
35
+ "lib/technical_graph/refactoring_backup/lib/technical_graph/axis_layer.rb",
36
+ "lib/technical_graph/refactoring_backup/lib/technical_graph/axis_layer_draw_module.rb",
37
+ "lib/technical_graph/refactoring_backup/test/test_technical_graph.rb",
38
+ "lib/technical_graph/refactoring_backup/test/test_technical_graph_axis.rb",
39
+ "samples/1.png",
40
+ "technical_graph.gemspec",
41
+ "test/helper.rb",
42
+ "test/test_technical_graph.rb",
43
+ "test/test_technical_graph_axis.rb",
44
+ "test/test_technical_simple_graph.rb"
45
+ ]
46
+ s.homepage = %q{http://github.com/akwiatkowski/technical_graph}
47
+ s.licenses = ["LGPLv3"]
48
+ s.require_paths = ["lib"]
49
+ s.rubygems_version = %q{1.6.2}
50
+ s.summary = %q{Create simple and neat graphs}
51
+
52
+ if s.respond_to? :specification_version then
53
+ s.specification_version = 3
54
+
55
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
56
+ s.add_runtime_dependency(%q<rmagick>, [">= 0"])
57
+ s.add_runtime_dependency(%q<jeweler>, [">= 0"])
58
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
59
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
60
+ s.add_development_dependency(%q<rspec>, [">= 0"])
61
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
62
+ s.add_development_dependency(%q<rcov>, [">= 0"])
63
+ else
64
+ s.add_dependency(%q<rmagick>, [">= 0"])
65
+ s.add_dependency(%q<jeweler>, [">= 0"])
66
+ s.add_dependency(%q<shoulda>, [">= 0"])
67
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
68
+ s.add_dependency(%q<rspec>, [">= 0"])
69
+ s.add_dependency(%q<jeweler>, [">= 0"])
70
+ s.add_dependency(%q<rcov>, [">= 0"])
71
+ end
72
+ else
73
+ s.add_dependency(%q<rmagick>, [">= 0"])
74
+ s.add_dependency(%q<jeweler>, [">= 0"])
75
+ s.add_dependency(%q<shoulda>, [">= 0"])
76
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
77
+ s.add_dependency(%q<rspec>, [">= 0"])
78
+ s.add_dependency(%q<jeweler>, [">= 0"])
79
+ s.add_dependency(%q<rcov>, [">= 0"])
80
+ end
81
+ end
82
+
@@ -194,12 +194,12 @@ class TestTechnicalGraphAxis < Test::Unit::TestCase
194
194
  :y_max => y_max,
195
195
  :xy_behaviour => :fixed,
196
196
 
197
- :y_axises_count => 10,
198
- :x_axises_count => 10,
199
- :y_axises_interval => 1.0,
200
- :x_axises_interval => 4.0,
201
- :x_axises_fixed_interval => true,
202
- :y_axises_fixed_interval => true
197
+ :y_axis_count => 10,
198
+ :x_axis_count => 10,
199
+ :y_axis_interval => 1.0,
200
+ :x_axis_interval => 4.0,
201
+ :x_axis_fixed_interval => true,
202
+ :y_axis_fixed_interval => true
203
203
  }
204
204
  )
205
205
 
@@ -217,8 +217,8 @@ class TestTechnicalGraphAxis < Test::Unit::TestCase
217
217
 
218
218
  @tg.render
219
219
 
220
- @tg.axis.value_axises.should == [-5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0]
221
- @tg.axis.parameter_axises.should == [-5.0, -1.0, 3.0]
220
+ @tg.axis.value_axis.should == [-5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0]
221
+ @tg.axis.parameter_axis.should == [-5.0, -1.0, 3.0]
222
222
  end
223
223
 
224
224
 
@@ -236,12 +236,12 @@ class TestTechnicalGraphAxis < Test::Unit::TestCase
236
236
  :y_max => y_max,
237
237
  :xy_behaviour => :fixed,
238
238
 
239
- :x_axises_count => 8,
240
- :y_axises_count => 4,
241
- :x_axises_interval => 2.0,
242
- :y_axises_interval => 1.0,
243
- :x_axises_fixed_interval => false,
244
- :y_axises_fixed_interval => false
239
+ :x_axis_count => 8,
240
+ :y_axis_count => 4,
241
+ :x_axis_interval => 2.0,
242
+ :y_axis_interval => 1.0,
243
+ :x_axis_fixed_interval => false,
244
+ :y_axis_fixed_interval => false
245
245
  }
246
246
  )
247
247
 
@@ -259,8 +259,8 @@ class TestTechnicalGraphAxis < Test::Unit::TestCase
259
259
 
260
260
  @tg.render
261
261
 
262
- @tg.axis.parameter_axises.should == [-8.0, -6.0, -4.0, -2.0, 0.0, 2.0, 4.0, 6.0]
263
- @tg.axis.value_axises.should == [-4.0, -2.0, 0.0, 2.0]
262
+ @tg.axis.parameter_axis.should == [-8.0, -6.0, -4.0, -2.0, 0.0, 2.0, 4.0, 6.0]
263
+ @tg.axis.value_axis.should == [-4.0, -2.0, 0.0, 2.0]
264
264
 
265
265
  @tg.image_drawer.save_to_file('test1.png')
266
266
  end
@@ -269,12 +269,12 @@ class TestTechnicalGraphAxis < Test::Unit::TestCase
269
269
  should 'draw simple graph' do
270
270
  @tg = TechnicalGraph.new(
271
271
  {
272
- :x_axises_count => 10,
273
- :y_axises_count => 10,
274
- :x_axises_interval => 1.0,
275
- :y_axises_interval => 1.0,
276
- :x_axises_fixed_interval => false,
277
- :y_axises_fixed_interval => false,
272
+ :x_axis_count => 10,
273
+ :y_axis_count => 10,
274
+ :x_axis_interval => 1.0,
275
+ :y_axis_interval => 1.0,
276
+ :x_axis_fixed_interval => false,
277
+ :y_axis_fixed_interval => false,
278
278
 
279
279
  :x_min => -10.0,
280
280
  :x_max => 10.0,
@@ -5,20 +5,20 @@ class TestTechnicalGraph < Test::Unit::TestCase
5
5
  should 'draw simple graph' do
6
6
  @tg = TechnicalGraph.new(
7
7
  {
8
- :x_axises_count => 20,
9
- :y_axises_count => 20,
10
- :x_axises_interval => 1.0,
11
- :y_axises_interval => 1.0,
12
- :x_axises_fixed_interval => false,
13
- :y_axises_fixed_interval => false,
14
-
15
- :x_min => -10.0,
16
- :x_max => 10.0,
17
- :y_min => -10.0,
18
- :y_max => 10.0,
19
-
20
- :width => 4000,
21
- :height => 3000
8
+ #:x_axis_count => 20,
9
+ #:y_axis_count => 20,
10
+ #:x_axis_interval => 1.0,
11
+ #:y_axis_interval => 1.0,
12
+ #:x_axis_fixed_interval => false,
13
+ #:y_axis_fixed_interval => false,
14
+
15
+ #:x_min => -10.0,
16
+ #:x_max => 10.0,
17
+ #:y_min => -10.0,
18
+ #:y_max => 10.0,
19
+
20
+ #:width => 4000,
21
+ #:height => 3000
22
22
  }
23
23
  )
24
24
 
@@ -34,12 +34,14 @@ class TestTechnicalGraph < Test::Unit::TestCase
34
34
  end
35
35
  @tg.add_layer(layer_data, layer_params)
36
36
  # should be added
37
- @tg.layers.last.data.size > 0
37
+ @tg.layers.last.data.size.should > 0
38
38
  # checking ranger for layer
39
39
 
40
40
  @tg.render
41
41
 
42
42
  @tg.image_drawer.save_to_file('test_simple.png')
43
+ @tg.image_drawer.to_png.class.should == String
44
+
43
45
  end
44
46
  end
45
47
 
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: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 0
10
- version: 0.0.0
9
+ - 1
10
+ version: 0.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aleksander Kwiatkowski
@@ -126,7 +126,7 @@ extensions: []
126
126
 
127
127
  extra_rdoc_files:
128
128
  - LICENSE.txt
129
- - README.rdoc
129
+ - README.md
130
130
  files:
131
131
  - .document
132
132
  - .idea/dictionaries/olek.xml
@@ -134,7 +134,7 @@ files:
134
134
  - Gemfile
135
135
  - Gemfile.lock
136
136
  - LICENSE.txt
137
- - README.rdoc
137
+ - README.md
138
138
  - Rakefile
139
139
  - VERSION
140
140
  - lib/technical_graph.rb
@@ -148,6 +148,7 @@ files:
148
148
  - lib/technical_graph/refactoring_backup/test/test_technical_graph.rb
149
149
  - lib/technical_graph/refactoring_backup/test/test_technical_graph_axis.rb
150
150
  - samples/1.png
151
+ - technical_graph.gemspec
151
152
  - test/helper.rb
152
153
  - test/test_technical_graph.rb
153
154
  - test/test_technical_graph_axis.rb
data/README.rdoc DELETED
@@ -1,19 +0,0 @@
1
- = technical-graph
2
-
3
- Create neat graphs.
4
-
5
- == Contributing to technical-graph
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
- * Fork the project
10
- * Start a feature/bugfix branch
11
- * Commit and push until you are happy with your contribution
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2011 Aleksander Kwiatkowski. See LICENSE.txt for
18
- further details.
19
-