lilygraph 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/lilygraph.rb +16 -13
  3. data/lilygraph.gemspec +1 -1
  4. metadata +1 -1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.3
1
+ 0.4.4
data/lib/lilygraph.rb CHANGED
@@ -203,23 +203,26 @@ class Lilygraph
203
203
  if @options[:bar_text]
204
204
  last_bar_height = false
205
205
  data.each_with_index do |number, number_index|
206
- height = ((dy / 10.0) * number).round
206
+ if number > 0
207
+ height = ((dy / 10.0) * number).round
207
208
 
208
- bar_x = (x + ((dx - width) / 2.0) + (number_index * bar_width)).round
209
- text_x = (bar_x + (bar_width / 2.0)).round
209
+ bar_x = (x + ((dx - width) / 2.0) + (number_index * bar_width)).round
210
+ text_x = (bar_x + (bar_width / 2.0)).round
210
211
 
211
- bar_y = @options[:viewbox][:height] - @options[:margin][:bottom] - height
212
- text_y = bar_y - 3
212
+ bar_y = @options[:viewbox][:height] - @options[:margin][:bottom] - height
213
+ text_y = bar_y - 3
213
214
 
214
- if last_bar_height && (last_bar_height < (number + 5) && last_bar_height > (number - 5))
215
- text_y -= (14 - ((number - last_bar_height) * (dy / 10.0)))
216
- last_bar_height = false
215
+ if last_bar_height && (last_bar_height - height).abs < 14
216
+ text_y -= (14 - (height - last_bar_height))
217
+ last_bar_height = false
218
+ else
219
+ last_bar_height = height
220
+ end
221
+
222
+ xml.text number, :x => text_x, :y => text_y, 'text-anchor' => 'middle'
217
223
  else
218
- last_bar_height = number
224
+ last_bar_height = false
219
225
  end
220
-
221
- # xml.text number, :x => text_x, :y => text_y + 1, 'text-anchor' => 'middle', 'font-size' => '13px', 'stroke-width' => 1.0, :fill => '#ffffff', :stroke => '#ffffff'
222
- xml.text number, :x => text_x, :y => text_y, 'text-anchor' => 'middle'
223
226
  end
224
227
  end
225
228
  end
@@ -228,7 +231,7 @@ class Lilygraph
228
231
  # Legend
229
232
  if @legend
230
233
  legend_x = @options[:viewbox][:width] - (3 * @options[:margin][:right])
231
- legend_y = @options[:margin][:top] / 2
234
+ legend_y = (@options[:margin][:top] / 2) + @options[:margin][:top]
232
235
  xml.rect :fill => '#ffffff', :stroke => '#000000', 'stroke-width' => 2, :x => legend_x, :y => legend_y, :width => (2.5 * @options[:margin][:right]), :height => (@legend.size * 15) + 16
233
236
 
234
237
  @legend.sort.each_with_index do |data, index|
data/lilygraph.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{lilygraph}
8
- s.version = "0.4.3"
8
+ s.version = "0.4.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Christopher Giroir"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lilygraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Giroir