technical_graph 0.0.2 → 0.0.3

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/Gemfile CHANGED
@@ -1,11 +1,12 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gem 'rmagick'
4
- gem 'jeweler'
5
4
 
6
5
  # Add dependencies to develop your gem here.
7
6
  # Include everything needed to run rake, tests, features, etc.
8
7
  group :development do
8
+ gem 'jeweler'
9
+
9
10
  gem "shoulda"
10
11
  gem "bundler", "~> 1.0.0"
11
12
  gem "rspec"
data/README.md CHANGED
@@ -18,6 +18,7 @@ or
18
18
  > tg = TechnicalGraph.new( options )
19
19
 
20
20
  where:
21
+
21
22
  * options - Hash of parameters, all parameters are described below.
22
23
 
23
24
  2. Add layer
@@ -29,6 +30,7 @@ or
29
30
  > tg.add_layer(layer_data, layer_params)
30
31
 
31
32
  where:
33
+
32
34
  * layer_data - Array of Hashes, like [{:x => 0, :y => 0}, {:x => 1, :y => 1}, ...]
33
35
  * layer_params - Hash of other parameters, all parameters will be described later.
34
36
 
@@ -47,7 +49,7 @@ or get image binary content.
47
49
  where format is image format, ex. 'png', 'jpeg', ...
48
50
 
49
51
 
50
- Option's Hash
52
+ Options Hash
51
53
  -------------
52
54
 
53
55
  Default ranges:
@@ -100,6 +102,26 @@ Possible #RRGGBB or color names (ex. 'white').
100
102
  * options[:background_hatch_color] - background hatch color
101
103
  * options[:axis_color] - color of axis
102
104
 
105
+ Anti-aliasing:
106
+
107
+ * options[:axis_antialias] - use anti-aliasing for axis, default false
108
+ * options[:layers_antialias] - use anti-aliasing for data layers, default false, can be override using layer option
109
+ * options[:font_antialias] - use anti-aliasing for all fonts, default false
110
+
111
+ Font size:
112
+
113
+ * options[:layers_font_size] - size of font used for values in graph
114
+ * options[:axis_font_size] - size of font used in axis
115
+ * options[:axis_label_font_size] - size of font used in options[:x_axis_label] and options[:y_axis_label]
116
+
117
+
118
+
119
+ Layer options Hash
120
+ ------------------
121
+
122
+ * layer_options[:color] - color of graph layer, ex.: 'red', 'green', '#FFFF00'
123
+ * layer_options[:antialias] - use anti-aliasing for this, default false, override options[:layers_antialias]
124
+
103
125
 
104
126
  Contributing to technical-graph
105
127
  -------------------------------
data/Rakefile CHANGED
@@ -19,7 +19,7 @@ Jeweler::Tasks.new do |gem|
19
19
  gem.homepage = "http://github.com/akwiatkowski/technical_graph"
20
20
  gem.license = "LGPLv3"
21
21
  gem.summary = %Q{Create simple and neat graphs}
22
- gem.description = %Q{Create simple and neat graphs}
22
+ gem.description = %Q{Purpose of this gem is to create neat, simple, technical graphs. This is alternative to most new libraries which create small, candy graphs using JavaScript.}
23
23
  gem.email = "bobikx@poczta.fm"
24
24
  gem.authors = ["Aleksander Kwiatkowski"]
25
25
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -7,8 +7,7 @@
7
7
  class DataLayer
8
8
 
9
9
  def initialize(d = [], options = { })
10
- @options = options
11
- @data_params = Hash.new
10
+ @data_params = options
12
11
 
13
12
  # set data and append initial data
14
13
  clear_data
@@ -38,7 +37,7 @@ class DataLayer
38
37
  end
39
38
 
40
39
  def antialias
41
- return @data_params[:antialias] == false
40
+ return @data_params[:antialias]
42
41
  end
43
42
 
44
43
  # Clear data
@@ -54,7 +53,6 @@ class DataLayer
54
53
  @data.delete_if { |d| d[:x].nil? or d[:y].nil? }
55
54
  @data.sort! { |d, e| d[:x] <=> e[:x] }
56
55
 
57
- @data_params = Hash.new
58
56
  # default X values, if data is not empty
59
57
  if @data.size > 0
60
58
  @data_params[:x_min] = @data.first[:x] || @options[:default_x_min]
@@ -107,6 +107,7 @@ class GraphAxis
107
107
  plot_axis_y_line.stroke_linecap('square')
108
108
  plot_axis_y_line.stroke_linejoin('miter')
109
109
 
110
+ plot_axis_y_text.pointsize(options[:axis_font_size])
110
111
  plot_axis_y_text.font_family('helvetica')
111
112
  plot_axis_y_text.font_style(Magick::NormalStyle)
112
113
  plot_axis_y_text.text_align(Magick::LeftAlign)
@@ -150,6 +151,7 @@ class GraphAxis
150
151
  plot_axis_x_line.stroke_linecap('square')
151
152
  plot_axis_x_line.stroke_linejoin('miter')
152
153
 
154
+ plot_axis_x_text.pointsize(options[:axis_font_size])
153
155
  plot_axis_x_text.font_family('helvetica')
154
156
  plot_axis_x_text.font_style(Magick::NormalStyle)
155
157
  plot_axis_x_text.text_align(Magick::LeftAlign)
@@ -165,7 +167,7 @@ class GraphAxis
165
167
  string_label = "#{truncate_string % x}"
166
168
 
167
169
  plot_axis_x_text.text(
168
- bx.round + 15,
170
+ bx.round + 5,
169
171
  @image.rows - 15,
170
172
  string_label
171
173
  )
@@ -194,6 +196,7 @@ class GraphAxis
194
196
  plot_axis_y_line.stroke_linecap('square')
195
197
  plot_axis_y_line.stroke_linejoin('miter')
196
198
 
199
+ plot_axis_y_text.pointsize(options[:axis_font_size])
197
200
  plot_axis_y_text.font_family('helvetica')
198
201
  plot_axis_y_text.font_style(Magick::NormalStyle)
199
202
  plot_axis_y_text.text_align(Magick::LeftAlign)
@@ -232,6 +235,7 @@ class GraphAxis
232
235
  plot_axis_x_line.stroke_linecap('square')
233
236
  plot_axis_x_line.stroke_linejoin('miter')
234
237
 
238
+ plot_axis_x_text.pointsize(options[:axis_font_size])
235
239
  plot_axis_x_text.font_family('helvetica')
236
240
  plot_axis_x_text.font_style(Magick::NormalStyle)
237
241
  plot_axis_x_text.text_align(Magick::LeftAlign)
@@ -260,6 +264,7 @@ class GraphAxis
260
264
  plot_axis_text = Magick::Draw.new
261
265
  plot_axis_text.text_antialias(axis_antialias)
262
266
 
267
+ plot_axis_text.pointsize(options[:axis_label_font_size])
263
268
  plot_axis_text.font_family('helvetica')
264
269
  plot_axis_text.font_style(Magick::NormalStyle)
265
270
  plot_axis_text.text_align(Magick::LeftAlign)
@@ -277,6 +282,7 @@ class GraphAxis
277
282
  plot_axis_text = Magick::Draw.new
278
283
  plot_axis_text.text_antialias(axis_antialias)
279
284
 
285
+ plot_axis_text.pointsize(options[:axis_label_font_size])
280
286
  plot_axis_text.font_family('helvetica')
281
287
  plot_axis_text.font_style(Magick::NormalStyle)
282
288
  plot_axis_text.text_align(Magick::LeftAlign)
@@ -37,6 +37,10 @@ class GraphImageDrawer
37
37
  options[:truncate_string]
38
38
  end
39
39
 
40
+ def axis_font_size
41
+ options[:axis_font_size]
42
+ end
43
+
40
44
 
41
45
  # default sizes
42
46
  DEFAULT_WIDTH = 1600
@@ -52,6 +56,16 @@ class GraphImageDrawer
52
56
  options[:background_color] ||= 'white'
53
57
  options[:background_hatch_color] ||= 'lightcyan2'
54
58
  options[:axis_color] ||= '#aaaaaa'
59
+
60
+ # antialias
61
+ options[:layers_antialias] = false if options[:layers_antialias].nil?
62
+ options[:axis_antialias] = false if options[:axis_antialias].nil?
63
+ options[:font_antialias] = false if options[:font_antialias].nil?
64
+
65
+ # font sizes
66
+ options[:axis_font_size] ||= 10
67
+ options[:layers_font_size] ||= 10
68
+ options[:axis_label_font_size] ||= 10
55
69
  end
56
70
 
57
71
  def width
@@ -111,7 +125,11 @@ class GraphImageDrawer
111
125
  layer_line = Magick::Draw.new
112
126
  layer_text = Magick::Draw.new
113
127
 
114
- layer_line.stroke_antialias(l.antialias)
128
+ # global layer antialias can be override using layer option
129
+ layer_antialias = l.antialias
130
+ layer_antialias = options[:layers_antialias] if layer_antialias.nil?
131
+
132
+ layer_line.stroke_antialias(layer_antialias)
115
133
  layer_line.fill(l.color)
116
134
  layer_line.fill_opacity(1)
117
135
  layer_line.stroke(l.color)
@@ -121,7 +139,7 @@ class GraphImageDrawer
121
139
  layer_line.stroke_linejoin('miter')
122
140
 
123
141
  layer_text.text_antialias(font_antialias)
124
- layer_text.pointsize(10)
142
+ layer_text.pointsize(options[:layers_font_size])
125
143
  layer_text.font_family('helvetica')
126
144
  layer_text.font_style(Magick::NormalStyle)
127
145
  layer_text.text_align(Magick::LeftAlign)
Binary file
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{technical_graph}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
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-22}
13
- s.description = %q{Create simple and neat graphs}
12
+ s.date = %q{2011-09-24}
13
+ s.description = %q{Purpose of this gem is to create neat, simple, technical graphs. This is alternative to most new libraries which create small, candy graphs using JavaScript.}
14
14
  s.email = %q{bobikx@poczta.fm}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
@@ -37,6 +37,7 @@ Gem::Specification.new do |s|
37
37
  "lib/technical_graph/refactoring_backup/test/test_technical_graph.rb",
38
38
  "lib/technical_graph/refactoring_backup/test/test_technical_graph_axis.rb",
39
39
  "samples/1.png",
40
+ "samples/home_io_batt_voltage.png",
40
41
  "technical_graph.gemspec",
41
42
  "test/helper.rb",
42
43
  "test/test_technical_graph.rb",
@@ -54,7 +55,7 @@ Gem::Specification.new do |s|
54
55
 
55
56
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
56
57
  s.add_runtime_dependency(%q<rmagick>, [">= 0"])
57
- s.add_runtime_dependency(%q<jeweler>, [">= 0"])
58
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
58
59
  s.add_development_dependency(%q<shoulda>, [">= 0"])
59
60
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
60
61
  s.add_development_dependency(%q<rspec>, [">= 0"])
@@ -10,6 +10,14 @@ class TestTechnicalGraph < Test::Unit::TestCase
10
10
  :x_axis_label => 'x',
11
11
  :y_axis_label => 'y',
12
12
 
13
+ :axis_antialias => true,
14
+ :layers_antialias => true,
15
+ :font_antialias => true,
16
+
17
+ :layers_font_size => 6,
18
+ :axis_font_size => 8,
19
+ :axis_label_font_size => 20,
20
+
13
21
  #:x_axis_count => 20,
14
22
  #:y_axis_count => 20,
15
23
  #:x_axis_interval => 1.0,
@@ -31,7 +39,9 @@ class TestTechnicalGraph < Test::Unit::TestCase
31
39
 
32
40
  # adding simple layer
33
41
  layer_params = {
34
- :antialias => true
42
+ :antialias => false,
43
+ #:color => 'red'
44
+ :color => '#FFFF00'
35
45
  }
36
46
  layer_data = Array.new
37
47
  (0..max).each do |i|
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: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
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-22 00:00:00 +02:00
18
+ date: 2011-09-24 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -33,7 +33,7 @@ dependencies:
33
33
  version_requirements: *id001
34
34
  prerelease: false
35
35
  - !ruby/object:Gem::Dependency
36
- type: :runtime
36
+ type: :development
37
37
  requirement: &id002 !ruby/object:Gem::Requirement
38
38
  none: false
39
39
  requirements:
@@ -118,7 +118,7 @@ dependencies:
118
118
  name: rcov
119
119
  version_requirements: *id007
120
120
  prerelease: false
121
- description: Create simple and neat graphs
121
+ description: Purpose of this gem is to create neat, simple, technical graphs. This is alternative to most new libraries which create small, candy graphs using JavaScript.
122
122
  email: bobikx@poczta.fm
123
123
  executables: []
124
124
 
@@ -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
+ - samples/home_io_batt_voltage.png
151
152
  - technical_graph.gemspec
152
153
  - test/helper.rb
153
154
  - test/test_technical_graph.rb