prawn-graph 0.9.6 → 0.9.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28701ddd8575d49883e813d18fbf43297ed88cb9
4
- data.tar.gz: 01ace96eb5fca82f47f1095d59f0a8b4dd4b4c4c
3
+ metadata.gz: 804e9234484be154069bb231f7fa2e888e6e8c8a
4
+ data.tar.gz: 548f36e31f80f7ec89d9d9753b084c206b6670d7
5
5
  SHA512:
6
- metadata.gz: c809b60ff93e6fb1729e48c9d982dcdc8dc959125ad790a5d70fb12164063be420c686ca79192567324ad71283e5de68bb40cfa002d0574959b22550e35481d7
7
- data.tar.gz: 562932100c59e894f7cc16882203609bde13f8eec75920139e2babed166305f4e4a7340fbb8183a0686d3b78d526ab3a4348fabd023bf0a2ce9c503453d82d65
6
+ metadata.gz: 3874e72db6f60168ac807977c982971cfb2285f3e7d8753bbf224537d35bd5419fcf2995c6654bef430a4cd38f1055b8c6f9a6511dd1c86c1827ae4b90a17c4d
7
+ data.tar.gz: 6a9b880eb51c053419ce53fc40d8aab4372c4263186536d46609c774e45b04c672c91fd228527855dc99e8bd4373d494831cb5d736b684386f8840d605bd54b5
@@ -57,11 +57,11 @@ module Prawn
57
57
  this_x_offset = ((spacing * j) - spacing) + (spacing / 2.0)
58
58
 
59
59
 
60
- prawn.stroke_line([previous_x_offset, previous_y], [ this_x_offset, this_y ])
60
+ prawn.stroke_line([previous_x_offset, previous_y], [ this_x_offset, this_y ]) unless previous_value.zero? || this_value.zero?
61
61
 
62
62
  prawn.fill_color = @canvas.theme.markers
63
- prawn.fill_ellipse([ ( previous_x_offset), previous_y ], 1)
64
- prawn.fill_ellipse([ ( this_x_offset), this_y ], 1)
63
+ prawn.fill_ellipse([ ( previous_x_offset), previous_y ], 1) unless previous_value.zero? || this_value.zero?
64
+ prawn.fill_ellipse([ ( this_x_offset), this_y ], 1) unless previous_value.zero? || this_value.zero?
65
65
 
66
66
  if @series.mark_minimum? && min_marked == false && previous_value != 0 && previous_value == @series.min
67
67
  prawn.save_graphics_state do
@@ -146,6 +146,21 @@ 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
153
+
154
+ max_y = (point_height_percentage(max) * @plot_area_height).to_f
155
+ min_y = (point_height_percentage(min) * @plot_area_height).to_f
156
+ mid_y = (point_height_percentage(mid) * @plot_area_height).to_f
157
+ avg_y = (point_height_percentage(avg) * @plot_area_height).to_f
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
163
+
149
164
  return if @canvas.options[:xaxis_labels].size.zero?
150
165
 
151
166
  width_of_each_label = (@plot_area_width / @canvas.options[:xaxis_labels].size) - 1
@@ -222,7 +237,7 @@ module Prawn
222
237
  x_position = ( (starting + (series_offset * width) ).to_f - (width / 2.0))
223
238
  y_position = ((point_height_percentage(@series[series_index].values[point]) * @plot_area_height) - 5).to_f
224
239
 
225
- prawn.fill_and_stroke_line([ x_position ,0], [x_position ,y_position])
240
+ prawn.fill_and_stroke_line([ x_position ,0], [x_position ,y_position]) unless @series[series_index].values[point].zero?
226
241
 
227
242
  if @series[series_index].mark_average?
228
243
  average_y_coordinate = (point_height_percentage(@series[series_index].avg) * @plot_area_height) - 5
@@ -278,6 +293,21 @@ module Prawn
278
293
  prawn.stroke_vertical_line(0, @plot_area_height, at: 0)
279
294
  prawn.fill_and_stroke_ellipse [ 0,0], 1
280
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
300
+
301
+ max_y = (point_height_percentage(max) * @plot_area_height).to_f
302
+ min_y = (point_height_percentage(min) * @plot_area_height).to_f
303
+ mid_y = (point_height_percentage(mid) * @plot_area_height).to_f
304
+ avg_y = (point_height_percentage(avg) * @plot_area_height).to_f
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
310
+
281
311
  return if @canvas.options[:xaxis_labels].size.zero?
282
312
 
283
313
  width_of_each_label = (@plot_area_width / @canvas.options[:xaxis_labels].size) - 1
@@ -1,5 +1,5 @@
1
1
  module Prawn
2
2
  module Graph
3
- VERSION = "0.9.6"
3
+ VERSION = "0.9.7"
4
4
  end
5
5
  end
data/test.pdf ADDED
Binary file
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.6
4
+ version: 0.9.7
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-06-16 00:00:00.000000000 Z
12
+ date: 2016-06-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -144,6 +144,7 @@ files:
144
144
  - lib/prawn/graph/theme.rb
145
145
  - lib/prawn/graph/version.rb
146
146
  - prawn-graph.gemspec
147
+ - test.pdf
147
148
  homepage: http://prawn-graph.ryanstenhouse.jp
148
149
  licenses:
149
150
  - MIT