gruff 0.6.0-java → 0.11.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +5 -5
  2. data/.editorconfig +14 -0
  3. data/.github/ISSUE_TEMPLATE.md +18 -0
  4. data/.gitignore +3 -0
  5. data/.rubocop.yml +109 -0
  6. data/.rubocop_todo.yml +112 -0
  7. data/.travis.yml +24 -15
  8. data/.yardopts +1 -0
  9. data/{History.txt → CHANGELOG.md} +72 -25
  10. data/Gemfile +3 -7
  11. data/README.md +57 -25
  12. data/Rakefile +21 -192
  13. data/assets/plastik/blue.png +0 -0
  14. data/assets/plastik/green.png +0 -0
  15. data/assets/plastik/red.png +0 -0
  16. data/docker/Dockerfile +14 -0
  17. data/docker/build.sh +4 -0
  18. data/docker/launch.sh +4 -0
  19. data/gruff.gemspec +21 -13
  20. data/init.rb +2 -0
  21. data/lib/gruff.rb +26 -2
  22. data/lib/gruff/accumulator_bar.rb +18 -8
  23. data/lib/gruff/area.rb +33 -19
  24. data/lib/gruff/bar.rb +76 -45
  25. data/lib/gruff/base.rb +435 -704
  26. data/lib/gruff/bezier.rb +32 -17
  27. data/lib/gruff/bullet.rb +62 -68
  28. data/lib/gruff/dot.rb +38 -82
  29. data/lib/gruff/helper/bar_conversion.rb +47 -0
  30. data/lib/gruff/helper/bar_value_label_mixin.rb +30 -0
  31. data/lib/gruff/helper/stacked_mixin.rb +23 -0
  32. data/lib/gruff/histogram.rb +60 -0
  33. data/lib/gruff/line.rb +134 -170
  34. data/lib/gruff/mini/bar.rb +17 -10
  35. data/lib/gruff/mini/legend.rb +24 -36
  36. data/lib/gruff/mini/pie.rb +18 -12
  37. data/lib/gruff/mini/side_bar.rb +26 -12
  38. data/lib/gruff/net.rb +68 -81
  39. data/lib/gruff/patch/rmagick.rb +33 -0
  40. data/lib/gruff/patch/string.rb +10 -0
  41. data/lib/gruff/photo_bar.rb +39 -42
  42. data/lib/gruff/pie.rb +180 -89
  43. data/lib/gruff/renderer/bezier.rb +21 -0
  44. data/lib/gruff/renderer/circle.rb +21 -0
  45. data/lib/gruff/renderer/dash_line.rb +22 -0
  46. data/lib/gruff/renderer/dot.rb +39 -0
  47. data/lib/gruff/renderer/ellipse.rb +21 -0
  48. data/lib/gruff/renderer/line.rb +42 -0
  49. data/lib/gruff/renderer/polygon.rb +23 -0
  50. data/lib/gruff/renderer/polyline.rb +21 -0
  51. data/lib/gruff/renderer/rectangle.rb +19 -0
  52. data/lib/gruff/renderer/renderer.rb +132 -0
  53. data/lib/gruff/renderer/text.rb +53 -0
  54. data/lib/gruff/scatter.rb +163 -182
  55. data/lib/gruff/scene.rb +31 -41
  56. data/lib/gruff/side_bar.rb +81 -65
  57. data/lib/gruff/side_stacked_bar.rb +78 -62
  58. data/lib/gruff/spider.rb +49 -57
  59. data/lib/gruff/stacked_area.rb +40 -32
  60. data/lib/gruff/stacked_bar.rb +86 -53
  61. data/lib/gruff/store/base_data.rb +38 -0
  62. data/lib/gruff/store/custom_data.rb +38 -0
  63. data/lib/gruff/store/store.rb +80 -0
  64. data/lib/gruff/store/xy_data.rb +59 -0
  65. data/lib/gruff/themes.rb +32 -33
  66. data/lib/gruff/version.rb +3 -1
  67. metadata +80 -102
  68. data/Manifest.txt +0 -81
  69. data/RELEASE.md +0 -30
  70. data/assets/bubble.png +0 -0
  71. data/assets/city_scene/background/0000.png +0 -0
  72. data/assets/city_scene/background/0600.png +0 -0
  73. data/assets/city_scene/background/2000.png +0 -0
  74. data/assets/city_scene/clouds/cloudy.png +0 -0
  75. data/assets/city_scene/clouds/partly_cloudy.png +0 -0
  76. data/assets/city_scene/clouds/stormy.png +0 -0
  77. data/assets/city_scene/grass/default.png +0 -0
  78. data/assets/city_scene/haze/true.png +0 -0
  79. data/assets/city_scene/number_sample/1.png +0 -0
  80. data/assets/city_scene/number_sample/2.png +0 -0
  81. data/assets/city_scene/number_sample/default.png +0 -0
  82. data/assets/city_scene/sky/0000.png +0 -0
  83. data/assets/city_scene/sky/0200.png +0 -0
  84. data/assets/city_scene/sky/0400.png +0 -0
  85. data/assets/city_scene/sky/0600.png +0 -0
  86. data/assets/city_scene/sky/0800.png +0 -0
  87. data/assets/city_scene/sky/1000.png +0 -0
  88. data/assets/city_scene/sky/1200.png +0 -0
  89. data/assets/city_scene/sky/1400.png +0 -0
  90. data/assets/city_scene/sky/1500.png +0 -0
  91. data/assets/city_scene/sky/1700.png +0 -0
  92. data/assets/city_scene/sky/2000.png +0 -0
  93. data/assets/pc306715.jpg +0 -0
  94. data/lib/gruff/bar_conversion.rb +0 -46
  95. data/lib/gruff/deprecated.rb +0 -39
  96. data/lib/gruff/stacked_mixin.rb +0 -23
  97. data/test/gruff_test_case.rb +0 -154
  98. data/test/image_compare.rb +0 -58
  99. data/test/test_accumulator_bar.rb +0 -51
  100. data/test/test_area.rb +0 -134
  101. data/test/test_bar.rb +0 -505
  102. data/test/test_base.rb +0 -8
  103. data/test/test_bezier.rb +0 -33
  104. data/test/test_bullet.rb +0 -26
  105. data/test/test_dot.rb +0 -263
  106. data/test/test_labels_for_null_data.rb +0 -27
  107. data/test/test_legend.rb +0 -68
  108. data/test/test_line.rb +0 -657
  109. data/test/test_mini_bar.rb +0 -33
  110. data/test/test_mini_pie.rb +0 -25
  111. data/test/test_mini_side_bar.rb +0 -36
  112. data/test/test_net.rb +0 -231
  113. data/test/test_photo.rb +0 -41
  114. data/test/test_pie.rb +0 -161
  115. data/test/test_scatter.rb +0 -233
  116. data/test/test_scene.rb +0 -100
  117. data/test/test_side_bar.rb +0 -56
  118. data/test/test_sidestacked_bar.rb +0 -105
  119. data/test/test_spider.rb +0 -226
  120. data/test/test_stacked_area.rb +0 -52
  121. data/test/test_stacked_bar.rb +0 -68
@@ -1,26 +1,35 @@
1
- ##
1
+ # frozen_string_literal: true
2
+
2
3
  #
3
4
  # Makes a small bar graph suitable for display at 200px or even smaller.
4
5
  #
6
+ # Here's how to set up a Gruff::Mini::Bar.
7
+ #
8
+ # g = Gruff::Mini::Bar.new
9
+ # g.title = 'Mini Bar Graph'
10
+ # g.data :Art, [0, 5, 8, 15]
11
+ # g.data :Philosophy, [10, 3, 2, 8]
12
+ # g.data :Science, [2, 15, 8, 11]
13
+ # g.write('mini_bar.png')
14
+ #
5
15
  module Gruff
6
16
  module Mini
7
-
8
17
  class Bar < Gruff::Bar
9
-
10
18
  include Gruff::Mini::Legend
11
-
19
+
12
20
  def initialize_ivars
13
21
  super
14
-
22
+
15
23
  @hide_legend = true
16
24
  @hide_title = true
17
25
  @hide_line_numbers = true
18
26
 
19
27
  @marker_font_size = 50.0
20
- @minimum_value = 0.0
21
- @maximum_value = 0.0
22
28
  @legend_font_size = 60.0
29
+
30
+ @minimum_value = 0.0
23
31
  end
32
+ private :initialize_ivars
24
33
 
25
34
  def draw
26
35
  expand_canvas_for_vertical_legend
@@ -28,10 +37,8 @@ module Gruff
28
37
  super
29
38
 
30
39
  draw_vertical_legend
31
- @d.draw(@base_image)
40
+ Gruff::Renderer.finish
32
41
  end
33
-
34
42
  end
35
-
36
43
  end
37
44
  end
@@ -1,20 +1,25 @@
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
 
8
+ def initialize(*)
9
+ @hide_mini_legend = false
10
+ @legend_position = nil
11
+ super
12
+ end
13
+
7
14
  ##
8
15
  # The canvas needs to be bigger so we can put the legend beneath it.
9
16
 
10
17
  def expand_canvas_for_vertical_legend
11
18
  return if @hide_mini_legend
12
19
 
13
- @legend_labels = @data.collect {|item| item[Gruff::Base::DATA_LABEL_INDEX] }
20
+ @legend_labels = store.data.map(&:label)
14
21
 
15
- legend_height = scale_fontsize(
16
- @data.length * calculate_line_height +
17
- @top_margin + @bottom_margin)
22
+ legend_height = scale_fontsize(store.length * calculate_line_height + @top_margin + @bottom_margin)
18
23
 
19
24
  @original_rows = @raw_rows
20
25
  @original_columns = @raw_columns
@@ -24,9 +29,10 @@ module Gruff
24
29
  @rows = [@rows, legend_height].max
25
30
  @columns += calculate_legend_width + @left_margin
26
31
  else
27
- @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
28
33
  end
29
- render_background
34
+
35
+ Gruff::Renderer.setup(@columns, @rows, @font, @scale, @theme_options)
30
36
  end
31
37
 
32
38
  def calculate_line_height
@@ -35,7 +41,7 @@ module Gruff
35
41
 
36
42
  def calculate_legend_width
37
43
  width = @legend_labels.map { |label| calculate_width(@legend_font_size, label) }.max
38
- scale_fontsize(width + 40*1.7)
44
+ scale_fontsize(width + 40 * 1.7)
39
45
  end
40
46
 
41
47
  ##
@@ -45,14 +51,9 @@ module Gruff
45
51
  return if @hide_mini_legend
46
52
 
47
53
  legend_square_width = 40.0 # small square with color of this item
48
- legend_square_margin = 10.0
49
54
  @legend_left_margin = 100.0
50
55
  legend_top_margin = 40.0
51
56
 
52
- # May fix legend drawing problem at small sizes
53
- @d.font = @font if @font
54
- @d.pointsize = @legend_font_size
55
-
56
57
  case @legend_position
57
58
  when :right then
58
59
  current_x_offset = @original_columns + @left_margin
@@ -62,33 +63,21 @@ module Gruff
62
63
  current_y_offset = @original_rows + legend_top_margin
63
64
  end
64
65
 
65
- debug { @d.line 0.0, current_y_offset, @raw_columns, current_y_offset }
66
-
67
66
  @legend_labels.each_with_index do |legend_label, index|
68
-
69
67
  # Draw label
70
- @d.fill = @font_color
71
- @d.font = @font if @font
72
- @d.pointsize = scale_fontsize(@legend_font_size)
73
- @d.stroke = 'transparent'
74
- @d.font_weight = Magick::NormalWeight
75
- @d.gravity = Magick::WestGravity
76
- @d = @d.annotate_scaled( @base_image,
77
- @raw_columns, 1.0,
78
- current_x_offset + (legend_square_width * 1.7), current_y_offset,
79
- 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.add_to_render_queue(@raw_columns, 1.0, current_x_offset + (legend_square_width * 1.7), current_y_offset, Magick::WestGravity)
80
71
 
81
72
  # Now draw box with color of this dataset
82
- @d = @d.stroke 'transparent'
83
- @d = @d.fill @data[index][Gruff::Base::DATA_COLOR_INDEX]
84
- @d = @d.rectangle(current_x_offset,
85
- current_y_offset - legend_square_width / 2.0,
86
- current_x_offset + legend_square_width,
87
- 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)
88
78
 
89
79
  current_y_offset += calculate_line_height
90
80
  end
91
- @color_index = 0
92
81
  end
93
82
 
94
83
  ##
@@ -99,11 +88,10 @@ module Gruff
99
88
  def truncate_legend_label(label)
100
89
  truncated_label = label.to_s
101
90
  while calculate_width(scale_fontsize(@legend_font_size), truncated_label) > (@columns - @legend_left_margin - @right_margin) && (truncated_label.length > 1)
102
- truncated_label = truncated_label[0..truncated_label.length-2]
91
+ truncated_label = truncated_label[0..truncated_label.length - 2]
103
92
  end
104
- truncated_label + (truncated_label.length < label.to_s.length ? "..." : '')
93
+ truncated_label + (truncated_label.length < label.to_s.length ? '...' : '')
105
94
  end
106
-
107
95
  end
108
96
  end
109
97
  end
@@ -1,36 +1,42 @@
1
- ##
1
+ # frozen_string_literal: true
2
+
2
3
  #
3
4
  # Makes a small pie graph suitable for display at 200px or even smaller.
4
5
  #
6
+ # Here's how to set up a Gruff::Mini::Pie.
7
+ #
8
+ # g = Gruff::Mini::Pie.new
9
+ # g.title = "Visual Pie Graph Test"
10
+ # g.data 'Fries', 20
11
+ # g.data 'Hamburgers', 50
12
+ # g.write("mini_pie_keynote.png")
13
+ #
5
14
  module Gruff
6
15
  module Mini
7
-
8
16
  class Pie < Gruff::Pie
9
-
10
17
  include Gruff::Mini::Legend
11
18
 
12
19
  def initialize_ivars
13
20
  super
14
-
21
+
15
22
  @hide_legend = true
16
23
  @hide_title = true
17
24
  @hide_line_numbers = true
18
-
25
+
19
26
  @marker_font_size = 60.0
20
27
  @legend_font_size = 60.0
21
28
  end
29
+ private :initialize_ivars
22
30
 
23
31
  def draw
24
32
  expand_canvas_for_vertical_legend
25
-
33
+
26
34
  super
27
-
35
+
28
36
  draw_vertical_legend
29
-
30
- @d.draw(@base_image)
31
- end # def draw
32
37
 
33
- end # class Pie
34
-
38
+ Gruff::Renderer.finish
39
+ end
40
+ end
35
41
  end
36
42
  end
@@ -1,14 +1,29 @@
1
- ##
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Makes a small side bar graph suitable for display at 200px or even smaller.
5
+ #
6
+ # Here's how to set up a Gruff::Mini::SideBar.
2
7
  #
3
- # Makes a small pie graph suitable for display at 200px or even smaller.
8
+ # g = Gruff::Mini::SideBar.new
9
+ # g.title = 'SideBar Graph'
10
+ # g.labels = {
11
+ # 0 => '5/6',
12
+ # 1 => '5/15',
13
+ # 2 => '5/24',
14
+ # 3 => '5/30',
15
+ # }
16
+ # g.group_spacing = 20
17
+ # g.data :Art, [0, 5, 8, 15]
18
+ # g.data :Philosophy, [10, 3, 2, 8]
19
+ # g.data :Science, [2, 15, 8, 11]
20
+ # g.write('mini_sidebar.png')
4
21
  #
5
22
  module Gruff
6
23
  module Mini
7
-
8
24
  class SideBar < Gruff::SideBar
9
-
10
25
  include Gruff::Mini::Legend
11
-
26
+
12
27
  def initialize_ivars
13
28
  super
14
29
  @hide_legend = true
@@ -18,18 +33,17 @@ module Gruff
18
33
  @marker_font_size = 50.0
19
34
  @legend_font_size = 50.0
20
35
  end
21
-
36
+ private :initialize_ivars
37
+
22
38
  def draw
23
39
  expand_canvas_for_vertical_legend
24
-
40
+
25
41
  super
26
-
42
+
27
43
  draw_vertical_legend
28
-
29
- @d.draw(@base_image)
44
+
45
+ Gruff::Renderer.finish
30
46
  end
31
-
32
47
  end
33
-
34
48
  end
35
49
  end
@@ -1,127 +1,114 @@
1
- require File.dirname(__FILE__) + '/base'
2
-
3
- # Experimental!!! See also the Spider graph.
1
+ # frozen_string_literal: true
2
+
3
+ require 'gruff/base'
4
+
5
+ # See also the Spider graph.
6
+ #
7
+ # Here's how to make a Gruff::Net.
8
+ #
9
+ # g = Gruff::Net.new
10
+ # g.title = "Net Graph"
11
+ # g.labels = {
12
+ # 0 => '5/6',
13
+ # 1 => '5/15',
14
+ # 2 => '5/24',
15
+ # 3 => '5/30',
16
+ # 4 => '6/4',
17
+ # 5 => '6/12',
18
+ # 6 => '6/21',
19
+ # 7 => '6/28'
20
+ # }
21
+ # g.line_width = 3
22
+ # g.dot_radius = 4
23
+ # g.data :Jimmy, [25, 36, 86, 39, 25, 31, 79, 88]
24
+ # g.data :Julie, [22, 29, 35, 38, 36, 40, 46, 57]
25
+ # g.write("net.png")
26
+ #
4
27
  class Gruff::Net < Gruff::Base
5
-
6
28
  # Hide parts of the graph to fit more datapoints, or for a different appearance.
7
- attr_accessor :hide_dots
29
+ attr_writer :hide_dots
8
30
 
9
- # Dimensions of lines and dots; calculated based on dataset size if left unspecified
10
- attr_accessor :line_width
11
- attr_accessor :dot_radius
31
+ # Dimensions of lines and dots; calculated based on dataset size if left unspecified.
32
+ attr_writer :line_width
33
+ attr_writer :dot_radius
12
34
 
13
- def initialize(*args)
35
+ def initialize_ivars
14
36
  super
15
37
 
16
38
  @hide_dots = false
39
+ @line_width = nil
40
+ @dot_radius = nil
17
41
  @hide_line_numbers = true
18
42
  @sorted_drawing = true
19
43
  end
44
+ private :initialize_ivars
20
45
 
21
46
  def draw
22
47
  super
23
48
 
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
48
-
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]
49
+ return unless data_given?
52
50
 
53
- data_row[DATA_VALUES_INDEX].each_with_index do |data_point, index|
51
+ store.norm_data.each do |data_row|
52
+ data_row.points.each_with_index do |data_point, index|
54
53
  next if data_point.nil?
55
54
 
56
- rad_pos = index * Math::PI * 2 / @column_count
55
+ rad_pos = index * Math::PI * 2 / column_count
57
56
  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
57
+ start_x = @center_x + Math.sin(rad_pos) * point_distance
58
+ start_y = @center_y - Math.cos(rad_pos) * point_distance
60
59
 
61
- next_index = index + 1 < data_row[DATA_VALUES_INDEX].length ? index + 1 : 0
60
+ next_index = index + 1 < data_row.points.length ? index + 1 : 0
62
61
 
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
62
+ next_rad_pos = next_index * Math::PI * 2 / column_count
63
+ next_point_distance = data_row.points[next_index] * @radius
64
+ end_x = @center_x + Math.sin(next_rad_pos) * next_point_distance
65
+ end_y = @center_y - Math.cos(next_rad_pos) * next_point_distance
67
66
 
68
- @d = @d.line(start_x, start_y, end_x, end_y)
67
+ Gruff::Renderer::Line.new(color: data_row.color, width: @stroke_width).render(start_x, start_y, end_x, end_y)
69
68
 
70
- @d = @d.circle(start_x, start_y, start_x - circle_radius, start_y) unless @hide_dots
69
+ 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
70
  end
72
-
73
71
  end
74
72
 
75
- @d.draw(@base_image)
73
+ Gruff::Renderer.finish
76
74
  end
77
75
 
76
+ private
78
77
 
79
- # the lines connecting in the center, with the first line vertical
80
- def draw_line_markers
81
- return if @hide_line_markers
82
-
78
+ def setup_drawing
79
+ super
83
80
 
84
- # have to do this here (AGAIN)... see draw() in this class
85
- # because this funtion is called before the @radius, @center_x and @center_y are set
86
81
  @radius = @graph_height / 2.0
82
+ @circle_radius = @dot_radius || clip_value_if_greater_than(@columns / (store.norm_data.first.points.size * 2.5), 5.0)
83
+ @stroke_width = @line_width || clip_value_if_greater_than(@columns / (store.norm_data.first.points.size * 4), 5.0)
87
84
  @center_x = @graph_left + (@graph_width / 2.0)
88
- @center_y = @graph_top + (@graph_height / 2.0) - 10 # Move graph up a bit
85
+ @center_y = @graph_top + (@graph_height / 2.0) + 10
86
+ end
89
87
 
88
+ # the lines connecting in the center, with the first line vertical
89
+ def draw_line_markers
90
+ return if @hide_line_markers
90
91
 
91
92
  # Draw horizontal line markers and annotate with numbers
92
- @d = @d.stroke(@marker_color)
93
- @d = @d.stroke_width 1
94
-
93
+ (0..column_count - 1).each do |index|
94
+ rad_pos = index * Math::PI * 2 / column_count
95
95
 
96
- (0..@column_count-1).each do |index|
97
- rad_pos = index * Math::PI * 2 / @column_count
96
+ Gruff::Renderer::Line.new(color: @marker_color)
97
+ .render(@center_x, @center_y, @center_x + Math.sin(rad_pos) * @radius, @center_y - Math.cos(rad_pos) * @radius)
98
98
 
99
- @d = @d.line(@center_x, @center_y, @center_x + Math::sin(rad_pos) * @radius, @center_y - Math::cos(rad_pos) * @radius)
100
-
101
-
102
- marker_label = labels[index] ? labels[index].to_s : '000'
103
-
104
- draw_label(@center_x, @center_y, rad_pos * 360 / (2 * Math::PI), @radius, marker_label)
99
+ marker_label = @labels[index] ? @labels[index].to_s : '000'
100
+ draw_label(@center_x, @center_y, rad_pos * 360 / (2 * Math::PI), @radius + @circle_radius, marker_label)
105
101
  end
106
102
  end
107
103
 
108
- private
109
-
110
104
  def draw_label(center_x, center_y, angle, radius, amount)
111
- r_offset = 1.1
112
105
  x_offset = center_x # + 15 # The label points need to be tweaked slightly
113
106
  y_offset = center_y # + 0 # This one doesn't though
114
- x = x_offset + (radius * r_offset * Math.sin(deg2rad(angle)))
115
- y = y_offset - (radius * r_offset * Math.cos(deg2rad(angle)))
107
+ x = x_offset + (radius + LABEL_MARGIN) * Math.sin(deg2rad(angle))
108
+ y = y_offset - (radius + LABEL_MARGIN) * Math.cos(deg2rad(angle))
116
109
 
117
110
  # Draw label
118
- @d.fill = @marker_color
119
- @d.font = @font if @font
120
- @d.pointsize = scale_fontsize(20)
121
- @d.stroke = 'transparent'
122
- @d.font_weight = BoldWeight
123
- @d.gravity = CenterGravity
124
- @d.annotate_scaled(@base_image, 0, 0, x, y, amount, @scale)
111
+ text_renderer = Gruff::Renderer::Text.new(amount, font: @font, size: 20, color: @marker_color, weight: Magick::BoldWeight)
112
+ text_renderer.add_to_render_queue(0, 0, x, y, Magick::CenterGravity)
125
113
  end
126
-
127
114
  end