prawn-graph 0.9.9 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/prawn/graph/chart_components/series_renderer.rb +31 -29
- data/lib/prawn/graph/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb2a51bcf0e59ebb68b1d71b874dc8342343810e
|
4
|
+
data.tar.gz: 051ab456f7af3318a2c8a9d4a1e9b6a05669bbcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c31371f3411e0d707e1a1145718190268cb04516395bf490eb54172f6824bf510b681d370ebfa3bcedaf11394c5aee7f38b4230ff234059b5e8606190c924ef
|
7
|
+
data.tar.gz: 7fc938b7daffc5f4379207fc06893ea62120f962d6e90a7a2876d48af0dff72ca3c06f904ce8d6576ca119a37cf477f54cebfce88531cb12e75610cc7acb23bb
|
@@ -146,20 +146,20 @@ module Prawn
|
|
146
146
|
prawn.stroke_vertical_line(0, @plot_area_height, at: 0)
|
147
147
|
prawn.fill_and_stroke_ellipse [ 0,0], 1
|
148
148
|
|
149
|
-
max = @series.max
|
150
|
-
min = @series.min
|
151
|
-
avg = @series.avg
|
152
|
-
mid = (min + max) / 2
|
149
|
+
max = @series.max || 0
|
150
|
+
min = @series.min || 0
|
151
|
+
avg = @series.avg || 0
|
152
|
+
mid = (min + max) / 2 rescue 0
|
153
153
|
|
154
|
-
max_y = (point_height_percentage(max) * @plot_area_height)
|
155
|
-
min_y = (point_height_percentage(min) * @plot_area_height)
|
156
|
-
mid_y = (point_height_percentage(mid) * @plot_area_height)
|
157
|
-
avg_y = (point_height_percentage(avg) * @plot_area_height)
|
154
|
+
max_y = (point_height_percentage(max) * @plot_area_height)
|
155
|
+
min_y = (point_height_percentage(min) * @plot_area_height)
|
156
|
+
mid_y = (point_height_percentage(mid) * @plot_area_height)
|
157
|
+
avg_y = (point_height_percentage(avg) * @plot_area_height)
|
158
158
|
|
159
|
-
prawn.text_box "#{max}", at: [-14, max_y], height: 5, overflow: :shrink_to_fit, width: 12, valign: :bottom, align: :right
|
160
|
-
prawn.text_box "#{mid}", at: [-14, mid_y], height: 5, overflow: :shrink_to_fit, width: 12, valign: :bottom, align: :right
|
161
|
-
prawn.text_box "#{avg}", at: [-14, avg_y], height: 5, overflow: :shrink_to_fit, width: 12, valign: :bottom, align: :right
|
162
|
-
prawn.text_box "#{min}", at: [-14, min_y], height: 5, overflow: :shrink_to_fit, width: 12, valign: :bottom, align: :right
|
159
|
+
prawn.text_box "#{max}", at: [-14, max_y], height: 5, overflow: :shrink_to_fit, width: 12, valign: :bottom, align: :right unless max.zero?
|
160
|
+
prawn.text_box "#{mid}", at: [-14, mid_y], height: 5, overflow: :shrink_to_fit, width: 12, valign: :bottom, align: :right unless mid.zero?
|
161
|
+
prawn.text_box "#{avg}", at: [-14, avg_y], height: 5, overflow: :shrink_to_fit, width: 12, valign: :bottom, align: :right unless avg.zero?
|
162
|
+
prawn.text_box "#{min}", at: [-14, min_y], height: 5, overflow: :shrink_to_fit, width: 12, valign: :bottom, align: :right unless min.zero?
|
163
163
|
|
164
164
|
return if @canvas.options[:xaxis_labels].size.zero?
|
165
165
|
|
@@ -177,7 +177,7 @@ module Prawn
|
|
177
177
|
# the series.
|
178
178
|
#
|
179
179
|
def point_height_percentage(value)
|
180
|
-
((BigDecimal(value, 10)/BigDecimal(@canvas.series.collect(&:max).max, 10)) * BigDecimal(1)).round(2)
|
180
|
+
((BigDecimal(value, 10)/BigDecimal(@canvas.series.collect(&:max).max, 10)) * BigDecimal(1)).round(2) rescue 0
|
181
181
|
end
|
182
182
|
|
183
183
|
def prawn
|
@@ -219,8 +219,8 @@ module Prawn
|
|
219
219
|
|
220
220
|
prawn.save_graphics_state do
|
221
221
|
num_points = @series[0].size
|
222
|
-
width_per_point = (@plot_area_width / num_points)
|
223
|
-
width = ((width_per_point *
|
222
|
+
width_per_point = (@plot_area_width / num_points)
|
223
|
+
width = (((width_per_point * 0.9) / @series.size).round(2)).to_f
|
224
224
|
min_marked = false
|
225
225
|
max_marked = false
|
226
226
|
|
@@ -293,20 +293,20 @@ module Prawn
|
|
293
293
|
prawn.stroke_vertical_line(0, @plot_area_height, at: 0)
|
294
294
|
prawn.fill_and_stroke_ellipse [ 0,0], 1
|
295
295
|
|
296
|
-
max = @series.collect(&:max).max
|
297
|
-
min = @series.collect(&:min).min
|
298
|
-
avg = ((BigDecimal(@series.collect(&:avg).inject(:+), 10) / @series.collect(&:avg).size).round(2)).to_f
|
299
|
-
mid = (min + max) / 2
|
296
|
+
max = @series.collect(&:max).max || 0
|
297
|
+
min = @series.collect(&:min).min || 0
|
298
|
+
avg = ((BigDecimal(@series.collect(&:avg).inject(:+), 10) / @series.collect(&:avg).size).round(2)).to_f || 0
|
299
|
+
mid = (min + max) / 2 || 0
|
300
300
|
|
301
|
-
max_y = (point_height_percentage(max) * @plot_area_height)
|
302
|
-
min_y = (point_height_percentage(min) * @plot_area_height)
|
303
|
-
mid_y = (point_height_percentage(mid) * @plot_area_height)
|
304
|
-
avg_y = (point_height_percentage(avg) * @plot_area_height)
|
301
|
+
max_y = (point_height_percentage(max) * @plot_area_height)
|
302
|
+
min_y = (point_height_percentage(min) * @plot_area_height)
|
303
|
+
mid_y = (point_height_percentage(mid) * @plot_area_height)
|
304
|
+
avg_y = (point_height_percentage(avg) * @plot_area_height)
|
305
305
|
|
306
|
-
prawn.text_box "#{max}", at: [-14, max_y], height: 5, overflow: :shrink_to_fit, width: 12, valign: :bottom, align: :right
|
307
|
-
prawn.text_box "#{mid}", at: [-14, mid_y], height: 5, overflow: :shrink_to_fit, width: 12, valign: :bottom, align: :right
|
308
|
-
prawn.text_box "#{avg}", at: [-14, avg_y], height: 5, overflow: :shrink_to_fit, width: 12, valign: :bottom, align: :right
|
309
|
-
prawn.text_box "#{min}", at: [-14, min_y], height: 5, overflow: :shrink_to_fit, width: 12, valign: :bottom, align: :right
|
306
|
+
prawn.text_box "#{max}", at: [-14, max_y], height: 5, overflow: :shrink_to_fit, width: 12, valign: :bottom, align: :right unless max.zero?
|
307
|
+
prawn.text_box "#{mid}", at: [-14, mid_y], height: 5, overflow: :shrink_to_fit, width: 12, valign: :bottom, align: :right unless mid.zero?
|
308
|
+
prawn.text_box "#{avg}", at: [-14, avg_y], height: 5, overflow: :shrink_to_fit, width: 12, valign: :bottom, align: :right unless avg.zero?
|
309
|
+
prawn.text_box "#{min}", at: [-14, min_y], height: 5, overflow: :shrink_to_fit, width: 12, valign: :bottom, align: :right unless min.zero?
|
310
310
|
|
311
311
|
return if @canvas.options[:xaxis_labels].size.zero?
|
312
312
|
|
@@ -324,7 +324,9 @@ module Prawn
|
|
324
324
|
# the series.
|
325
325
|
#
|
326
326
|
def point_height_percentage(value)
|
327
|
-
((BigDecimal(value, 10)/BigDecimal(@series.collect(&:max).max, 10)) * BigDecimal(1)).round(2)
|
327
|
+
pc = ((BigDecimal(value, 10)/BigDecimal(@series.collect(&:max).max, 10)) * BigDecimal(1)).round(2)
|
328
|
+
pc = 0 if pc.nan?
|
329
|
+
pc
|
328
330
|
end
|
329
331
|
|
330
332
|
def prawn
|
@@ -334,4 +336,4 @@ module Prawn
|
|
334
336
|
end
|
335
337
|
end
|
336
338
|
end
|
337
|
-
end
|
339
|
+
end
|
data/lib/prawn/graph/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prawn-graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Stenhouse
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-07-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|