gruff 0.8.0 → 0.9.0

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.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +18 -0
  3. data/.gitignore +3 -0
  4. data/.rubocop.yml +93 -0
  5. data/.rubocop_todo.yml +23 -810
  6. data/.travis.yml +4 -4
  7. data/.yardopts +1 -0
  8. data/CHANGELOG.md +22 -0
  9. data/Gemfile +3 -1
  10. data/README.md +44 -21
  11. data/Rakefile +2 -206
  12. data/docker/Dockerfile +14 -0
  13. data/docker/build.sh +4 -0
  14. data/docker/launch.sh +4 -0
  15. data/gruff.gemspec +11 -8
  16. data/init.rb +2 -0
  17. data/lib/gruff.rb +23 -0
  18. data/lib/gruff/accumulator_bar.rb +6 -6
  19. data/lib/gruff/area.rb +13 -17
  20. data/lib/gruff/bar.rb +58 -41
  21. data/lib/gruff/base.rb +243 -566
  22. data/lib/gruff/bezier.rb +12 -14
  23. data/lib/gruff/bullet.rb +39 -57
  24. data/lib/gruff/dot.rb +25 -59
  25. data/lib/gruff/{bar_conversion.rb → helper/bar_conversion.rb} +13 -12
  26. data/lib/gruff/helper/bar_value_label_mixin.rb +30 -0
  27. data/lib/gruff/{stacked_mixin.rb → helper/stacked_mixin.rb} +7 -6
  28. data/lib/gruff/line.rb +95 -177
  29. data/lib/gruff/mini/bar.rb +6 -7
  30. data/lib/gruff/mini/legend.rb +16 -32
  31. data/lib/gruff/mini/pie.rb +6 -7
  32. data/lib/gruff/mini/side_bar.rb +4 -5
  33. data/lib/gruff/net.rb +37 -65
  34. data/lib/gruff/patch/rmagick.rb +33 -0
  35. data/lib/gruff/patch/string.rb +8 -0
  36. data/lib/gruff/photo_bar.rb +19 -19
  37. data/lib/gruff/pie.rb +22 -73
  38. data/lib/gruff/renderer/bezier.rb +21 -0
  39. data/lib/gruff/renderer/circle.rb +21 -0
  40. data/lib/gruff/renderer/dash_line.rb +22 -0
  41. data/lib/gruff/renderer/dot.rb +39 -0
  42. data/lib/gruff/renderer/ellipse.rb +21 -0
  43. data/lib/gruff/renderer/line.rb +34 -0
  44. data/lib/gruff/renderer/polygon.rb +23 -0
  45. data/lib/gruff/renderer/polyline.rb +21 -0
  46. data/lib/gruff/renderer/rectangle.rb +19 -0
  47. data/lib/gruff/renderer/renderer.rb +127 -0
  48. data/lib/gruff/renderer/text.rb +42 -0
  49. data/lib/gruff/scatter.rb +85 -156
  50. data/lib/gruff/scene.rb +22 -30
  51. data/lib/gruff/side_bar.rb +62 -58
  52. data/lib/gruff/side_stacked_bar.rb +47 -43
  53. data/lib/gruff/spider.rb +19 -36
  54. data/lib/gruff/stacked_area.rb +17 -21
  55. data/lib/gruff/stacked_bar.rb +50 -24
  56. data/lib/gruff/store/base_data.rb +34 -0
  57. data/lib/gruff/store/custom_data.rb +34 -0
  58. data/lib/gruff/store/store.rb +80 -0
  59. data/lib/gruff/store/xy_data.rb +55 -0
  60. data/lib/gruff/themes.rb +3 -3
  61. data/lib/gruff/version.rb +3 -1
  62. metadata +41 -30
  63. data/Manifest.txt +0 -81
  64. data/assets/bubble.png +0 -0
  65. data/assets/city_scene/background/0000.png +0 -0
  66. data/assets/city_scene/background/0600.png +0 -0
  67. data/assets/city_scene/background/2000.png +0 -0
  68. data/assets/city_scene/clouds/cloudy.png +0 -0
  69. data/assets/city_scene/clouds/partly_cloudy.png +0 -0
  70. data/assets/city_scene/clouds/stormy.png +0 -0
  71. data/assets/city_scene/grass/default.png +0 -0
  72. data/assets/city_scene/haze/true.png +0 -0
  73. data/assets/city_scene/number_sample/1.png +0 -0
  74. data/assets/city_scene/number_sample/2.png +0 -0
  75. data/assets/city_scene/number_sample/default.png +0 -0
  76. data/assets/city_scene/sky/0000.png +0 -0
  77. data/assets/city_scene/sky/0200.png +0 -0
  78. data/assets/city_scene/sky/0400.png +0 -0
  79. data/assets/city_scene/sky/0600.png +0 -0
  80. data/assets/city_scene/sky/0800.png +0 -0
  81. data/assets/city_scene/sky/1000.png +0 -0
  82. data/assets/city_scene/sky/1200.png +0 -0
  83. data/assets/city_scene/sky/1400.png +0 -0
  84. data/assets/city_scene/sky/1500.png +0 -0
  85. data/assets/city_scene/sky/1700.png +0 -0
  86. data/assets/city_scene/sky/2000.png +0 -0
  87. data/assets/pc306715.jpg +0 -0
  88. data/lib/gruff/deprecated.rb +0 -38
@@ -1,12 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ##
2
4
  #
3
5
  # Makes a small bar graph suitable for display at 200px or even smaller.
4
6
  #
5
7
  module Gruff
6
8
  module Mini
7
-
8
9
  class Bar < Gruff::Bar
9
-
10
10
  include Gruff::Mini::Legend
11
11
 
12
12
  def initialize_ivars
@@ -17,10 +17,11 @@ module Gruff
17
17
  @hide_line_numbers = true
18
18
 
19
19
  @marker_font_size = 50.0
20
- @minimum_value = 0.0
21
- @maximum_value = 0.0
22
20
  @legend_font_size = 60.0
21
+
22
+ @minimum_value = 0.0
23
23
  end
24
+ private :initialize_ivars
24
25
 
25
26
  def draw
26
27
  expand_canvas_for_vertical_legend
@@ -28,10 +29,8 @@ module Gruff
28
29
  super
29
30
 
30
31
  draw_vertical_legend
31
- @d.draw(@base_image)
32
+ Gruff::Renderer.finish
32
33
  end
33
-
34
34
  end
35
-
36
35
  end
37
36
  end
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gruff
2
4
  module Mini
3
5
  module Legend
4
-
5
6
  attr_accessor :hide_mini_legend, :legend_position
6
7
 
7
8
  def initialize(*)
@@ -16,11 +17,9 @@ module Gruff
16
17
  def expand_canvas_for_vertical_legend
17
18
  return if @hide_mini_legend
18
19
 
19
- @legend_labels = @data.collect { |item| item[Gruff::Base::DATA_LABEL_INDEX] }
20
+ @legend_labels = store.data.map(&:label)
20
21
 
21
- legend_height = scale_fontsize(
22
- @data.length * calculate_line_height +
23
- @top_margin + @bottom_margin)
22
+ legend_height = scale_fontsize(store.length * calculate_line_height + @top_margin + @bottom_margin)
24
23
 
25
24
  @original_rows = @raw_rows
26
25
  @original_columns = @raw_columns
@@ -30,9 +29,10 @@ module Gruff
30
29
  @rows = [@rows, legend_height].max
31
30
  @columns += calculate_legend_width + @left_margin
32
31
  else
33
- @rows += @data.length * calculate_caps_height(scale_fontsize(@legend_font_size)) * 1.7
32
+ @rows += store.length * calculate_caps_height(scale_fontsize(@legend_font_size)) * 1.7
34
33
  end
35
- render_background
34
+
35
+ Gruff::Renderer.setup(@columns, @rows, @font, @scale, @theme_options)
36
36
  end
37
37
 
38
38
  def calculate_line_height
@@ -54,10 +54,6 @@ module Gruff
54
54
  @legend_left_margin = 100.0
55
55
  legend_top_margin = 40.0
56
56
 
57
- # May fix legend drawing problem at small sizes
58
- @d.font = @font if @font
59
- @d.pointsize = @legend_font_size
60
-
61
57
  case @legend_position
62
58
  when :right then
63
59
  current_x_offset = @original_columns + @left_margin
@@ -67,32 +63,21 @@ module Gruff
67
63
  current_y_offset = @original_rows + legend_top_margin
68
64
  end
69
65
 
70
- debug { @d.line 0.0, current_y_offset, @raw_columns, current_y_offset }
71
-
72
66
  @legend_labels.each_with_index do |legend_label, index|
73
67
  # Draw label
74
- @d.fill = @font_color
75
- @d.font = @font if @font
76
- @d.pointsize = scale_fontsize(@legend_font_size)
77
- @d.stroke = 'transparent'
78
- @d.font_weight = Magick::NormalWeight
79
- @d.gravity = Magick::WestGravity
80
- @d = @d.annotate_scaled(@base_image,
81
- @raw_columns, 1.0,
82
- current_x_offset + (legend_square_width * 1.7), current_y_offset,
83
- truncate_legend_label(legend_label), @scale)
68
+ label = truncate_legend_label(legend_label)
69
+ text_renderer = Gruff::Renderer::Text.new(label, font: @font, size: @legend_font_size, color: @font_color)
70
+ text_renderer.render(@raw_columns, 1.0, current_x_offset + (legend_square_width * 1.7), current_y_offset, Magick::WestGravity)
84
71
 
85
72
  # Now draw box with color of this dataset
86
- @d = @d.stroke 'transparent'
87
- @d = @d.fill @data[index][Gruff::Base::DATA_COLOR_INDEX]
88
- @d = @d.rectangle(current_x_offset,
89
- current_y_offset - legend_square_width / 2.0,
90
- current_x_offset + legend_square_width,
91
- current_y_offset + legend_square_width / 2.0)
73
+ rect_renderer = Gruff::Renderer::Rectangle.new(color: store.data[index].color)
74
+ rect_renderer.render(current_x_offset,
75
+ current_y_offset - legend_square_width / 2.0,
76
+ current_x_offset + legend_square_width,
77
+ current_y_offset + legend_square_width / 2.0)
92
78
 
93
79
  current_y_offset += calculate_line_height
94
80
  end
95
- @color_index = 0
96
81
  end
97
82
 
98
83
  ##
@@ -105,9 +90,8 @@ module Gruff
105
90
  while calculate_width(scale_fontsize(@legend_font_size), truncated_label) > (@columns - @legend_left_margin - @right_margin) && (truncated_label.length > 1)
106
91
  truncated_label = truncated_label[0..truncated_label.length - 2]
107
92
  end
108
- truncated_label + (truncated_label.length < label.to_s.length ? "..." : '')
93
+ truncated_label + (truncated_label.length < label.to_s.length ? '...' : '')
109
94
  end
110
-
111
95
  end
112
96
  end
113
97
  end
@@ -1,12 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ##
2
4
  #
3
5
  # Makes a small pie graph suitable for display at 200px or even smaller.
4
6
  #
5
7
  module Gruff
6
8
  module Mini
7
-
8
9
  class Pie < Gruff::Pie
9
-
10
10
  include Gruff::Mini::Legend
11
11
 
12
12
  def initialize_ivars
@@ -19,6 +19,7 @@ module Gruff
19
19
  @marker_font_size = 60.0
20
20
  @legend_font_size = 60.0
21
21
  end
22
+ private :initialize_ivars
22
23
 
23
24
  def draw
24
25
  expand_canvas_for_vertical_legend
@@ -27,10 +28,8 @@ module Gruff
27
28
 
28
29
  draw_vertical_legend
29
30
 
30
- @d.draw(@base_image)
31
- end # def draw
32
-
33
- end # class Pie
34
-
31
+ Gruff::Renderer.finish
32
+ end
33
+ end
35
34
  end
36
35
  end
@@ -1,12 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ##
2
4
  #
3
5
  # Makes a small pie graph suitable for display at 200px or even smaller.
4
6
  #
5
7
  module Gruff
6
8
  module Mini
7
-
8
9
  class SideBar < Gruff::SideBar
9
-
10
10
  include Gruff::Mini::Legend
11
11
 
12
12
  def initialize_ivars
@@ -18,6 +18,7 @@ module Gruff
18
18
  @marker_font_size = 50.0
19
19
  @legend_font_size = 50.0
20
20
  end
21
+ private :initialize_ivars
21
22
 
22
23
  def draw
23
24
  expand_canvas_for_vertical_legend
@@ -26,10 +27,8 @@ module Gruff
26
27
 
27
28
  draw_vertical_legend
28
29
 
29
- @d.draw(@base_image)
30
+ Gruff::Renderer.finish
30
31
  end
31
-
32
32
  end
33
-
34
33
  end
35
34
  end
@@ -1,106 +1,84 @@
1
- require File.dirname(__FILE__) + '/base'
1
+ # frozen_string_literal: true
2
+
3
+ require 'gruff/base'
2
4
 
3
5
  # Experimental!!! See also the Spider graph.
4
6
  class Gruff::Net < Gruff::Base
5
-
6
7
  # Hide parts of the graph to fit more datapoints, or for a different appearance.
7
8
  attr_accessor :hide_dots
8
9
 
9
- # Dimensions of lines and dots; calculated based on dataset size if left unspecified
10
+ # Dimensions of lines and dots; calculated based on dataset size if left unspecified.
10
11
  attr_accessor :line_width
11
12
  attr_accessor :dot_radius
12
13
 
13
- def initialize(*args)
14
+ def initialize_ivars
14
15
  super
15
16
 
16
17
  @hide_dots = false
17
18
  @hide_line_numbers = true
18
19
  @sorted_drawing = true
19
20
  end
21
+ private :initialize_ivars
20
22
 
21
23
  def draw
22
24
  super
23
25
 
24
- return unless @has_data
25
-
26
- @radius = @graph_height / 2.0
27
- @center_x = @graph_left + (@graph_width / 2.0)
28
- @center_y = @graph_top + (@graph_height / 2.0) - 10 # Move graph up a bit
29
-
30
- @x_increment = @graph_width / (@column_count - 1).to_f
31
- circle_radius = dot_radius ||
32
- clip_value_if_greater_than(@columns / (@norm_data.first[DATA_VALUES_INDEX].size * 2.5), 5.0)
33
-
34
- @d = @d.stroke_opacity 1.0
35
- @d = @d.stroke_width line_width ||
36
- clip_value_if_greater_than(@columns / (@norm_data.first[DATA_VALUES_INDEX].size * 4), 5.0)
37
-
38
- if defined?(@norm_baseline)
39
- level = @graph_top + (@graph_height - @norm_baseline * @graph_height)
40
- @d = @d.push
41
- @d.stroke_color @baseline_color
42
- @d.fill_opacity 0.0
43
- @d.stroke_dasharray(10, 20)
44
- @d.stroke_width 5
45
- @d.line(@graph_left, level, @graph_left + @graph_width, level)
46
- @d = @d.pop
47
- end
26
+ return unless data_given?
48
27
 
49
- @norm_data.each do |data_row|
50
- @d = @d.stroke data_row[DATA_COLOR_INDEX]
51
- @d = @d.fill data_row[DATA_COLOR_INDEX]
28
+ stroke_width = line_width || clip_value_if_greater_than(@columns / (store.norm_data.first.points.size * 4), 5.0)
29
+ circle_radius = dot_radius || clip_value_if_greater_than(@columns / (store.norm_data.first.points.size * 2.5), 5.0)
52
30
 
53
- data_row[DATA_VALUES_INDEX].each_with_index do |data_point, index|
31
+ store.norm_data.each do |data_row|
32
+ data_row.points.each_with_index do |data_point, index|
54
33
  next if data_point.nil?
55
34
 
56
- rad_pos = index * Math::PI * 2 / @column_count
35
+ rad_pos = index * Math::PI * 2 / column_count
57
36
  point_distance = data_point * @radius
58
- start_x = @center_x + Math::sin(rad_pos) * point_distance
59
- start_y = @center_y - Math::cos(rad_pos) * point_distance
37
+ start_x = @center_x + Math.sin(rad_pos) * point_distance
38
+ start_y = @center_y - Math.cos(rad_pos) * point_distance
60
39
 
61
- next_index = index + 1 < data_row[DATA_VALUES_INDEX].length ? index + 1 : 0
40
+ next_index = index + 1 < data_row.points.length ? index + 1 : 0
62
41
 
63
- next_rad_pos = next_index * Math::PI * 2 / @column_count
64
- next_point_distance = data_row[DATA_VALUES_INDEX][next_index] * @radius
65
- end_x = @center_x + Math::sin(next_rad_pos) * next_point_distance
66
- end_y = @center_y - Math::cos(next_rad_pos) * next_point_distance
42
+ next_rad_pos = next_index * Math::PI * 2 / column_count
43
+ next_point_distance = data_row.points[next_index] * @radius
44
+ end_x = @center_x + Math.sin(next_rad_pos) * next_point_distance
45
+ end_y = @center_y - Math.cos(next_rad_pos) * next_point_distance
67
46
 
68
- @d = @d.line(start_x, start_y, end_x, end_y)
47
+ Gruff::Renderer::Line.new(color: data_row.color, width: stroke_width).render(start_x, start_y, end_x, end_y)
69
48
 
70
- @d = @d.circle(start_x, start_y, start_x - circle_radius, start_y) unless @hide_dots
49
+ Gruff::Renderer::Circle.new(color: data_row.color, width: stroke_width).render(start_x, start_y, start_x - circle_radius, start_y) unless @hide_dots
71
50
  end
72
51
  end
73
52
 
74
- @d.draw(@base_image)
53
+ Gruff::Renderer.finish
75
54
  end
76
55
 
77
- # the lines connecting in the center, with the first line vertical
78
- def draw_line_markers
79
- return if @hide_line_markers
56
+ private
57
+
58
+ def setup_drawing
59
+ super
80
60
 
81
- # have to do this here (AGAIN)... see draw() in this class
82
- # because this funtion is called before the @radius, @center_x and @center_y are set
83
61
  @radius = @graph_height / 2.0
84
62
  @center_x = @graph_left + (@graph_width / 2.0)
85
63
  @center_y = @graph_top + (@graph_height / 2.0) - 10 # Move graph up a bit
64
+ end
86
65
 
87
- # Draw horizontal line markers and annotate with numbers
88
- @d = @d.stroke(@marker_color)
89
- @d = @d.stroke_width 1
66
+ # the lines connecting in the center, with the first line vertical
67
+ def draw_line_markers
68
+ return if @hide_line_markers
90
69
 
91
- (0..@column_count - 1).each do |index|
92
- rad_pos = index * Math::PI * 2 / @column_count
70
+ # Draw horizontal line markers and annotate with numbers
71
+ (0..column_count - 1).each do |index|
72
+ rad_pos = index * Math::PI * 2 / column_count
93
73
 
94
- @d = @d.line(@center_x, @center_y, @center_x + Math::sin(rad_pos) * @radius, @center_y - Math::cos(rad_pos) * @radius)
74
+ Gruff::Renderer::Line.new(color: @marker_color)
75
+ .render(@center_x, @center_y, @center_x + Math.sin(rad_pos) * @radius, @center_y - Math.cos(rad_pos) * @radius)
95
76
 
96
77
  marker_label = labels[index] ? labels[index].to_s : '000'
97
-
98
78
  draw_label(@center_x, @center_y, rad_pos * 360 / (2 * Math::PI), @radius, marker_label)
99
79
  end
100
80
  end
101
81
 
102
- private
103
-
104
82
  def draw_label(center_x, center_y, angle, radius, amount)
105
83
  r_offset = 1.1
106
84
  x_offset = center_x # + 15 # The label points need to be tweaked slightly
@@ -109,13 +87,7 @@ private
109
87
  y = y_offset - (radius * r_offset * Math.cos(deg2rad(angle)))
110
88
 
111
89
  # Draw label
112
- @d.fill = @marker_color
113
- @d.font = @font if @font
114
- @d.pointsize = scale_fontsize(20)
115
- @d.stroke = 'transparent'
116
- @d.font_weight = BoldWeight
117
- @d.gravity = CenterGravity
118
- @d.annotate_scaled(@base_image, 0, 0, x, y, amount, @scale)
90
+ text_renderer = Gruff::Renderer::Text.new(amount, font: @font, size: 20, color: @marker_color, weight: Magick::BoldWeight)
91
+ text_renderer.render(0, 0, x, y, Magick::CenterGravity)
119
92
  end
120
-
121
93
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Magick
4
+ class Draw
5
+ # Additional method to scale annotation text since Draw.scale doesn't.
6
+ def annotate_scaled(img, width, height, x, y, text, scale)
7
+ scaled_width = (width * scale) >= 1 ? (width * scale) : 1
8
+ scaled_height = (height * scale) >= 1 ? (height * scale) : 1
9
+
10
+ annotate(img,
11
+ scaled_width, scaled_height,
12
+ x * scale, y * scale,
13
+ text.gsub('%', '%%'))
14
+ end
15
+
16
+ remove_method :stroke_opacity
17
+ def stroke_opacity(_opacity)
18
+ raise '#stroke_opacity method has different behavior between RMagick and RMagick4J. Should not use this method.'
19
+ end
20
+
21
+ if defined? JRUBY_VERSION
22
+ # FIXME(uwe): We should NOT need to implement this method.
23
+ # Remove this method as soon as RMagick4J Issue #16 is fixed.
24
+ # https://github.com/Serabe/RMagick4J/issues/16
25
+ def fill=(fill)
26
+ fill = { white: '#FFFFFF' }[fill.to_sym] || fill
27
+ @draw.fill = Magick4J.ColorDatabase.query_default(fill)
28
+ self
29
+ end
30
+ # EMXIF
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class String
4
+ #Taken from http://codesnippets.joyent.com/posts/show/330
5
+ def commify(delimiter = ',')
6
+ gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{delimiter}")
7
+ end
8
+ end
@@ -1,11 +1,12 @@
1
- require File.dirname(__FILE__) + '/base'
1
+ # frozen_string_literal: true
2
+
3
+ require 'gruff/base'
2
4
 
3
5
  # EXPERIMENTAL!
4
6
  #
5
7
  # Doesn't work yet.
6
8
  #
7
9
  class Gruff::PhotoBar < Gruff::Base
8
-
9
10
  # TODO
10
11
  #
11
12
  # define base and cap in yml
@@ -25,11 +26,11 @@ class Gruff::PhotoBar < Gruff::Base
25
26
 
26
27
  def draw
27
28
  super
28
- return unless @has_data
29
+ return unless data_given?
29
30
 
30
- return # TODO Remove for further development
31
+ return # TODO: Remove for further development
31
32
 
32
- init_photo_bar_graphics()
33
+ init_photo_bar_graphics
33
34
 
34
35
  #Draw#define_clip_path()
35
36
  #Draw#clip_path(pathname)
@@ -44,33 +45,33 @@ class Gruff::PhotoBar < Gruff::Base
44
45
  #
45
46
  # Columns sit side-by-side.
46
47
  spacing_factor = 0.9
47
- @bar_width = @norm_data[0][DATA_COLOR_INDEX].columns
48
+ bar_width = store.norm_data[0].color.columns
48
49
 
49
- @norm_data.each_with_index do |data_row, row_index|
50
- data_row[DATA_VALUES_INDEX].each_with_index do |data_point, point_index|
50
+ store.norm_data.each_with_index do |data_row, row_index|
51
+ data_row.points.each_with_index do |data_point, point_index|
51
52
  data_point = 0 if data_point.nil?
52
53
  # Use incremented x and scaled y
53
- left_x = @graph_left + (@bar_width * (row_index + point_index + ((@data.length - 1) * point_index)))
54
+ left_x = @graph_left + (bar_width * (row_index + point_index + ((store.length - 1) * point_index)))
54
55
  left_y = @graph_top + (@graph_height - data_point * @graph_height) + 1
55
- right_x = left_x + @bar_width * spacing_factor
56
+ right_x = left_x + bar_width * spacing_factor
56
57
  right_y = @graph_top + @graph_height - 1
57
58
 
58
- bar_image_width = data_row[DATA_COLOR_INDEX].columns
59
+ bar_image_width = data_row.color.columns
59
60
  bar_image_height = right_y.to_f - left_y.to_f
60
61
 
61
62
  # Crop to scale for data
62
- bar_image = data_row[DATA_COLOR_INDEX].crop(0, 0, bar_image_width, bar_image_height)
63
+ bar_image = data_row.color.crop(0, 0, bar_image_width, bar_image_height)
63
64
 
64
- @d.gravity = NorthWestGravity
65
- @d = @d.composite(left_x, left_y, bar_image_width, bar_image_height, bar_image)
65
+ @d.gravity = Magick::NorthWestGravity
66
+ @d.composite(left_x, left_y, bar_image_width, bar_image_height, bar_image)
66
67
 
67
68
  # Calculate center based on bar_width and current row
68
- label_center = @graph_left + (@data.length * @bar_width * point_index) + (@data.length * @bar_width / 2.0)
69
+ label_center = @graph_left + (store.length * bar_width * point_index) + (store.length * bar_width / 2.0)
69
70
  draw_label(label_center, point_index)
70
71
  end
71
72
  end
72
73
 
73
- @d.draw(@base_image)
74
+ Gruff::Renderer.finish
74
75
  end
75
76
 
76
77
  # Return the chosen theme or the default
@@ -83,15 +84,14 @@ protected
83
84
  # Sets up colors with a list of images that will be used.
84
85
  # Images should be 340px tall
85
86
  def init_photo_bar_graphics
86
- color_list = Array.new
87
+ color_list = []
87
88
  theme_dir = File.dirname(__FILE__) + '/../../assets/' + theme
88
89
 
89
90
  Dir.open(theme_dir).each do |file|
90
91
  next unless /\.png$/.match(file)
91
92
 
92
- color_list << Image.read("#{theme_dir}/#{file}").first
93
+ color_list << Magick::Image.read("#{theme_dir}/#{file}").first
93
94
  end
94
95
  @colors = color_list
95
96
  end
96
-
97
97
  end