technical_graph 0.0.1 → 0.0.2

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/README.md CHANGED
@@ -77,6 +77,12 @@ If fixed interval is set you should specify interval:
77
77
  * options[:y_axis_count] = 10
78
78
  * options[:x_axis_count] = 10
79
79
 
80
+ Axis labels:
81
+
82
+ * options[:x_axis_label] = 'x'
83
+ * options[:y_axis_label] = 'y'
84
+
85
+
80
86
  Labels has truncate string to define precision. Default it is "%.2f".
81
87
 
82
88
  * options[:truncate_string] = "%.2f"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -84,6 +84,8 @@ class GraphAxis
84
84
 
85
85
  render_values_zero_axis
86
86
  render_parameters_zero_axis
87
+
88
+ render_axis_labels
87
89
  end
88
90
 
89
91
  def axis_antialias
@@ -253,4 +255,42 @@ class GraphAxis
253
255
  plot_axis_x_text.draw(@image)
254
256
  end
255
257
 
258
+ def render_axis_labels
259
+ if options[:x_axis_label].to_s.size > 0
260
+ plot_axis_text = Magick::Draw.new
261
+ plot_axis_text.text_antialias(axis_antialias)
262
+
263
+ plot_axis_text.font_family('helvetica')
264
+ plot_axis_text.font_style(Magick::NormalStyle)
265
+ plot_axis_text.text_align(Magick::LeftAlign)
266
+ plot_axis_text.text_undercolor(options[:background_color])
267
+
268
+ plot_axis_text.text(
269
+ (@image.columns / 2).to_i,
270
+ @image.rows - 40,
271
+ options[:x_axis_label].to_s
272
+ )
273
+ plot_axis_text.draw(@image)
274
+ end
275
+
276
+ if options[:y_axis_label].to_s.size > 0
277
+ plot_axis_text = Magick::Draw.new
278
+ plot_axis_text.text_antialias(axis_antialias)
279
+
280
+ plot_axis_text.font_family('helvetica')
281
+ plot_axis_text.font_style(Magick::NormalStyle)
282
+ plot_axis_text.text_align(Magick::LeftAlign)
283
+ plot_axis_text.text_undercolor(options[:background_color])
284
+
285
+ plot_axis_text = plot_axis_text.rotate(90)
286
+ plot_axis_text.text(
287
+ (@image.rows / 2).to_i,
288
+ -40,
289
+ options[:y_axis_label].to_s
290
+ )
291
+
292
+ plot_axis_text.draw(@image)
293
+ end
294
+ end
295
+
256
296
  end
@@ -20,6 +20,10 @@ class GraphDataProcessor
20
20
  def initialize(technical_graph)
21
21
  @technical_graph = technical_graph
22
22
 
23
+ # axis label
24
+ options[:x_axis_label] ||= ''
25
+ options[:y_axis_label] ||= ''
26
+
23
27
  options[:x_min] ||= 0.0 #(Time.now - 24 * 3600).to_f
24
28
  options[:x_max] ||= 1.0 #Time.now.to_f
25
29
  options[:y_min] ||= 0.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{technical_graph}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aleksander Kwiatkowski"]
12
- s.date = %q{2011-09-19}
12
+ s.date = %q{2011-09-22}
13
13
  s.description = %q{Create simple and neat graphs}
14
14
  s.email = %q{bobikx@poczta.fm}
15
15
  s.extra_rdoc_files = [
@@ -5,6 +5,11 @@ class TestTechnicalGraph < Test::Unit::TestCase
5
5
  should 'draw simple graph' do
6
6
  @tg = TechnicalGraph.new(
7
7
  {
8
+ :truncate_string => "%.1f",
9
+
10
+ :x_axis_label => 'x',
11
+ :y_axis_label => 'y',
12
+
8
13
  #:x_axis_count => 20,
9
14
  #:y_axis_count => 20,
10
15
  #:x_axis_interval => 1.0,
@@ -18,7 +23,7 @@ class TestTechnicalGraph < Test::Unit::TestCase
18
23
  #:y_max => 10.0,
19
24
 
20
25
  #:width => 4000,
21
- #:height => 3000
26
+ #:height => 3000,
22
27
  }
23
28
  )
24
29
 
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: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
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-09-19 00:00:00 +02:00
18
+ date: 2011-09-22 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency