gruff 0.13.0-java → 0.14.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +66 -0
  3. data/.rubocop.yml +6 -10
  4. data/.rubocop_todo.yml +19 -85
  5. data/CHANGELOG.md +10 -0
  6. data/README.md +6 -7
  7. data/gruff.gemspec +2 -4
  8. data/lib/gruff.rb +1 -0
  9. data/lib/gruff/accumulator_bar.rb +3 -1
  10. data/lib/gruff/area.rb +5 -8
  11. data/lib/gruff/bar.rb +19 -23
  12. data/lib/gruff/base.rb +134 -96
  13. data/lib/gruff/bezier.rb +4 -6
  14. data/lib/gruff/bullet.rb +11 -10
  15. data/lib/gruff/dot.rb +10 -10
  16. data/lib/gruff/font.rb +39 -0
  17. data/lib/gruff/helper/stacked_mixin.rb +1 -2
  18. data/lib/gruff/histogram.rb +9 -7
  19. data/lib/gruff/line.rb +55 -46
  20. data/lib/gruff/mini/bar.rb +9 -6
  21. data/lib/gruff/mini/legend.rb +12 -8
  22. data/lib/gruff/mini/pie.rb +9 -6
  23. data/lib/gruff/mini/side_bar.rb +9 -6
  24. data/lib/gruff/net.rb +9 -15
  25. data/lib/gruff/patch/string.rb +1 -1
  26. data/lib/gruff/pie.rb +23 -65
  27. data/lib/gruff/renderer/bezier.rb +8 -9
  28. data/lib/gruff/renderer/circle.rb +8 -9
  29. data/lib/gruff/renderer/dash_line.rb +9 -10
  30. data/lib/gruff/renderer/dot.rb +13 -14
  31. data/lib/gruff/renderer/ellipse.rb +8 -9
  32. data/lib/gruff/renderer/line.rb +8 -9
  33. data/lib/gruff/renderer/polygon.rb +9 -10
  34. data/lib/gruff/renderer/polyline.rb +8 -9
  35. data/lib/gruff/renderer/rectangle.rb +7 -8
  36. data/lib/gruff/renderer/renderer.rb +21 -36
  37. data/lib/gruff/renderer/text.rb +21 -37
  38. data/lib/gruff/scatter.rb +41 -46
  39. data/lib/gruff/scene.rb +15 -13
  40. data/lib/gruff/side_bar.rb +14 -30
  41. data/lib/gruff/side_stacked_bar.rb +8 -11
  42. data/lib/gruff/spider.rb +11 -16
  43. data/lib/gruff/stacked_area.rb +10 -11
  44. data/lib/gruff/stacked_bar.rb +9 -9
  45. data/lib/gruff/store/store.rb +6 -10
  46. data/lib/gruff/themes.rb +6 -6
  47. data/lib/gruff/version.rb +1 -1
  48. data/rails_generators/gruff/templates/controller.rb +1 -1
  49. metadata +4 -21
  50. data/.travis.yml +0 -23
  51. data/assets/plastik/blue.png +0 -0
  52. data/assets/plastik/green.png +0 -0
  53. data/assets/plastik/red.png +0 -0
  54. data/lib/gruff/photo_bar.rb +0 -93
data/lib/gruff/bezier.rb CHANGED
@@ -19,11 +19,9 @@
19
19
  # g.write('bezier.png')
20
20
  #
21
21
  class Gruff::Bezier < Gruff::Base
22
- def draw
23
- super
24
-
25
- return unless data_given?
22
+ private
26
23
 
24
+ def draw_graph
27
25
  x_increment = @graph_width / (column_count - 1).to_f
28
26
 
29
27
  store.norm_data.each do |data_row|
@@ -48,9 +46,9 @@ class Gruff::Bezier < Gruff::Base
48
46
  stroke_width = clip_value_if_greater_than(@columns / (store.norm_data.first[1].size * 4), 5.0)
49
47
 
50
48
  if RUBY_PLATFORM == 'java'
51
- Gruff::Renderer::Polyline.new(color: data_row.color, width: stroke_width).render(poly_points)
49
+ Gruff::Renderer::Polyline.new(renderer, color: data_row.color, width: stroke_width).render(poly_points)
52
50
  else
53
- Gruff::Renderer::Bezier.new(color: data_row.color, width: stroke_width).render(poly_points)
51
+ Gruff::Renderer::Bezier.new(renderer, color: data_row.color, width: stroke_width).render(poly_points)
54
52
  end
55
53
  end
56
54
  end
data/lib/gruff/bullet.rb CHANGED
@@ -27,12 +27,13 @@ class Gruff::Bullet < Gruff::Base
27
27
  self.theme = Gruff::Themes::GREYSCALE
28
28
  end
29
29
 
30
- def initialize_ivars
30
+ def initialize_attributes
31
31
  super
32
32
 
33
- @title_font_size = 20
33
+ @title_font.size = 20
34
+ @title_font.bold = false
34
35
  end
35
- private :initialize_ivars
36
+ private :initialize_attributes
36
37
 
37
38
  def data(value, maximum_value, options = {})
38
39
  @value = value.to_f
@@ -51,7 +52,7 @@ class Gruff::Bullet < Gruff::Base
51
52
 
52
53
  draw_title
53
54
 
54
- title_width = calculate_width(@title_font_size, @title)
55
+ title_width = calculate_width(@title_font, @title)
55
56
  margin = 30.0
56
57
  thickness = @raw_rows / 6.0
57
58
  right_margin = margin
@@ -60,7 +61,7 @@ class Gruff::Bullet < Gruff::Base
60
61
  graph_height = thickness * 3.0
61
62
 
62
63
  # Background
63
- rect_renderer = Gruff::Renderer::Rectangle.new(color: @colors[0])
64
+ rect_renderer = Gruff::Renderer::Rectangle.new(renderer, color: @colors[0])
64
65
  rect_renderer.render(graph_left, 0, graph_left + graph_width, graph_height)
65
66
 
66
67
  [:high, :low].each_with_index do |indicator, index|
@@ -68,7 +69,7 @@ class Gruff::Bullet < Gruff::Base
68
69
 
69
70
  indicator_width_x = graph_left + graph_width * (@options[indicator] / maximum_value)
70
71
 
71
- rect_renderer = Gruff::Renderer::Rectangle.new(color: @colors[index + 1])
72
+ rect_renderer = Gruff::Renderer::Rectangle.new(renderer, color: @colors[index + 1])
72
73
  rect_renderer.render(graph_left, 0, indicator_width_x, graph_height)
73
74
  end
74
75
 
@@ -76,12 +77,12 @@ class Gruff::Bullet < Gruff::Base
76
77
  target_x = graph_left + graph_width * (@options[:target] / maximum_value)
77
78
  half_thickness = thickness / 2.0
78
79
 
79
- rect_renderer = Gruff::Renderer::Rectangle.new(color: @font_color)
80
+ rect_renderer = Gruff::Renderer::Rectangle.new(renderer, color: @marker_color)
80
81
  rect_renderer.render(target_x, half_thickness, target_x + half_thickness, thickness * 2 + half_thickness)
81
82
  end
82
83
 
83
84
  # Value
84
- rect_renderer = Gruff::Renderer::Rectangle.new(color: @font_color)
85
+ rect_renderer = Gruff::Renderer::Rectangle.new(renderer, color: @marker_color)
85
86
  rect_renderer.render(graph_left, thickness, graph_left + graph_width * (@value / maximum_value), thickness * 2)
86
87
  end
87
88
 
@@ -90,9 +91,9 @@ private
90
91
  def draw_title
91
92
  return if hide_title?
92
93
 
93
- font_height = calculate_caps_height(scale_fontsize(@title_font_size))
94
+ font_height = calculate_caps_height(@title_font)
94
95
 
95
- text_renderer = Gruff::Renderer::Text.new(@title, font: @font, size: @title_font_size, color: @font_color)
96
+ text_renderer = Gruff::Renderer::Text.new(renderer, @title, font: @title_font)
96
97
  text_renderer.add_to_render_queue(1.0, 1.0, font_height / 2, font_height / 2, Magick::NorthWestGravity)
97
98
  end
98
99
  end
data/lib/gruff/dot.rb CHANGED
@@ -14,12 +14,14 @@
14
14
  # g.write('dot.png')
15
15
  #
16
16
  class Gruff::Dot < Gruff::Base
17
- def draw
18
- @has_left_labels = true
19
- super
17
+ private
20
18
 
21
- return unless data_given?
19
+ def initialize_attributes
20
+ super
21
+ @has_left_labels = true
22
+ end
22
23
 
24
+ def draw_graph
23
25
  # Setup spacing.
24
26
  #
25
27
  spacing_factor = 1.0
@@ -34,18 +36,16 @@ class Gruff::Dot < Gruff::Base
34
36
  y_pos = @graph_top + (items_width * point_index) + padding + (items_width.to_f / 2.0).round
35
37
 
36
38
  if row_index == 0
37
- Gruff::Renderer::Line.new(color: @marker_color).render(@graph_left, y_pos, @graph_left + @graph_width, y_pos)
39
+ Gruff::Renderer::Line.new(renderer, color: @marker_color).render(@graph_left, y_pos, @graph_left + @graph_width, y_pos)
38
40
  end
39
41
 
40
- Gruff::Renderer::Circle.new(color: data_row.color).render(x_pos, y_pos, x_pos + (item_width.to_f / 3.0).round, y_pos)
42
+ Gruff::Renderer::Circle.new(renderer, color: data_row.color).render(x_pos, y_pos, x_pos + (item_width.to_f / 3.0).round, y_pos)
41
43
 
42
44
  draw_label(y_pos, point_index)
43
45
  end
44
46
  end
45
47
  end
46
48
 
47
- protected
48
-
49
49
  # Instead of base class version, draws vertical background lines and label
50
50
  def draw_line_markers
51
51
  return if @hide_line_markers
@@ -54,12 +54,12 @@ protected
54
54
  marker_label = BigDecimal(index.to_s) * BigDecimal(@increment.to_s) + BigDecimal(minimum_value.to_s)
55
55
  x = @graph_left + (marker_label - minimum_value) * @graph_width / @spread
56
56
 
57
- line_renderer = Gruff::Renderer::Line.new(color: @marker_color, shadow_color: @marker_shadow_color)
57
+ line_renderer = Gruff::Renderer::Line.new(renderer, color: @marker_color, shadow_color: @marker_shadow_color)
58
58
  line_renderer.render(x, @graph_bottom, x, @graph_bottom + 5)
59
59
 
60
60
  unless @hide_line_numbers
61
61
  label = y_axis_label(marker_label, @increment)
62
- text_renderer = Gruff::Renderer::Text.new(label, font: @font, size: @marker_font_size, color: @font_color)
62
+ text_renderer = Gruff::Renderer::Text.new(renderer, label, font: @marker_font)
63
63
  text_renderer.add_to_render_queue(0, 0, x, @graph_bottom + (LABEL_MARGIN * 1.5), Magick::CenterGravity)
64
64
  end
65
65
  end
data/lib/gruff/font.rb ADDED
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Handle font setting to draw texts
4
+ class Gruff::Font
5
+ BOLD_PATH = File.expand_path(File.join(__FILE__, '../../../assets/fonts/Roboto-Bold.ttf')).freeze
6
+ REGULAR_PATH = File.expand_path(File.join(__FILE__, '../../../assets/fonts/Roboto-Regular.ttf')).freeze
7
+
8
+ # Get/set font path.
9
+ attr_accessor :path
10
+
11
+ # Get/set font size.
12
+ attr_accessor :size
13
+
14
+ # Get/set font setting whether render bold text.
15
+ attr_accessor :bold
16
+
17
+ # Get/set font color.
18
+ attr_accessor :color
19
+
20
+ def initialize(path: nil, size: 20.0, bold: false, color: 'white')
21
+ @path = path
22
+ @bold = bold
23
+ @size = size
24
+ @color = color
25
+ end
26
+
27
+ # Get font weight.
28
+ # @return [Magick::WeightType] font weight
29
+ def weight
30
+ @bold ? Magick::BoldWeight : Magick::NormalWeight
31
+ end
32
+
33
+ # @private
34
+ def file_path
35
+ return @path if @path
36
+
37
+ @bold ? BOLD_PATH : REGULAR_PATH
38
+ end
39
+ end
@@ -7,10 +7,9 @@ module Gruff::Base::StackedMixin
7
7
  # tsal: moved from Base 03 FEB 2007
8
8
  def calculate_maximum_by_stack
9
9
  # Get sum of each stack
10
- max_hash = {}
10
+ max_hash = Hash.new { |h, k| h[k] = 0.0 }
11
11
  store.data.each do |data_set|
12
12
  data_set.points.each_with_index do |data_point, i|
13
- max_hash[i] = 0.0 unless max_hash[i]
14
13
  max_hash[i] += data_point.to_f
15
14
  end
16
15
  end
@@ -28,19 +28,21 @@ class Gruff::Histogram < Gruff::Bar
28
28
  @data = []
29
29
  end
30
30
 
31
- def initialize_ivars
31
+ def data(name, data_points = [], color = nil)
32
+ @data << [name, data_points, color]
33
+ end
34
+
35
+ private
36
+
37
+ def initialize_attributes
32
38
  super
33
39
  @bin_width = 10
34
40
  @minimum_bin = nil
35
41
  @maximum_bin = nil
36
42
  end
37
- private :initialize_ivars
38
-
39
- def data(name, data_points = [], color = nil)
40
- @data << [name, data_points, color]
41
- end
43
+ private :initialize_attributes
42
44
 
43
- def draw
45
+ def setup_data
44
46
  @data.each do |(name, data_points, color)|
45
47
  bins, freqs = HistogramArray.new(data_points).histogram(bin_width: @bin_width, min: @minimum_bin, max: @maximum_bin)
46
48
  bins.each_with_index do |bin, index|
data/lib/gruff/line.rb CHANGED
@@ -37,6 +37,9 @@ class Gruff::Line < Gruff::Base
37
37
  # accessors for support of xy data.
38
38
  attr_writer :maximum_x_value
39
39
 
40
+ # The number of vertical lines shown.
41
+ attr_writer :marker_x_count
42
+
40
43
  # Get the value if somebody has defined it.
41
44
  def baseline_value
42
45
  if @reference_lines.key?(:baseline)
@@ -78,29 +81,6 @@ class Gruff::Line < Gruff::Base
78
81
  end
79
82
  end
80
83
 
81
- def initialize_store
82
- @store = Gruff::Store.new(Gruff::Store::XYData)
83
- end
84
- private :initialize_store
85
-
86
- def initialize_ivars
87
- super
88
- @reference_lines = {}
89
- @reference_line_default_color = 'red'
90
- @reference_line_default_width = 5
91
-
92
- @hide_dots = @hide_lines = false
93
- @maximum_x_value = nil
94
- @minimum_x_value = nil
95
-
96
- @line_width = nil
97
- @dot_radius = nil
98
- @dot_style = 'circle'
99
-
100
- @show_vertical_markers = false
101
- end
102
- private :initialize_ivars
103
-
104
84
  # This method allows one to plot a dataset with both X and Y data.
105
85
  #
106
86
  # @overload dataxy(name, x_data_points = [], y_data_points = [], color = nil)
@@ -152,10 +132,34 @@ class Gruff::Line < Gruff::Base
152
132
  store.add(name, y_data_points, color, x_data_points)
153
133
  end
154
134
 
135
+ private
136
+
137
+ def initialize_store
138
+ @store = Gruff::Store.new(Gruff::Store::XYData)
139
+ end
140
+
141
+ def initialize_attributes
142
+ super
143
+ @reference_lines = {}
144
+ @reference_line_default_color = 'red'
145
+ @reference_line_default_width = 5
146
+
147
+ @hide_dots = @hide_lines = false
148
+ @maximum_x_value = nil
149
+ @minimum_x_value = nil
150
+ @marker_x_count = nil
151
+
152
+ @line_width = nil
153
+ @dot_radius = nil
154
+ @dot_style = 'circle'
155
+
156
+ @show_vertical_markers = false
157
+ end
158
+
155
159
  def draw_reference_line(reference_line, left, right, top, bottom)
156
160
  color = reference_line[:color] || @reference_line_default_color
157
161
  width = reference_line[:width] || @reference_line_default_width
158
- Gruff::Renderer::DashLine.new(color: color, width: width).render(left, top, right, bottom)
162
+ Gruff::Renderer::DashLine.new(renderer, color: color, width: width).render(left, top, right, bottom)
159
163
  end
160
164
 
161
165
  def draw_horizontal_reference_line(reference_line)
@@ -168,11 +172,7 @@ class Gruff::Line < Gruff::Base
168
172
  draw_reference_line(reference_line, index, index, @graph_top, @graph_top + @graph_height)
169
173
  end
170
174
 
171
- def draw
172
- super
173
-
174
- return unless data_given?
175
-
175
+ def draw_graph
176
176
  # Check to see if more than one datapoint was given. NaN can result otherwise.
177
177
  @x_increment = (column_count > 1) ? (@graph_width / (column_count - 1).to_f) : @graph_width
178
178
 
@@ -181,18 +181,6 @@ class Gruff::Line < Gruff::Base
181
181
  draw_vertical_reference_line(curr_reference_line) if curr_reference_line.key?(:index)
182
182
  end
183
183
 
184
- if @show_vertical_markers
185
- (0..column_count).each do |column|
186
- x = @graph_left + @graph_width - column.to_f * @x_increment
187
-
188
- Gruff::Renderer::Line.new(color: @marker_color).render(x, @graph_bottom, x, @graph_top)
189
- #If the user specified a marker shadow color, draw a shadow just below it
190
- if @marker_shadow_color
191
- Gruff::Renderer::Line.new(color: @marker_shadow_color).render(x + 1, @graph_bottom, x + 1, @graph_top)
192
- end
193
- end
194
- end
195
-
196
184
  store.norm_data.each do |data_row|
197
185
  prev_x = prev_y = nil
198
186
 
@@ -200,7 +188,7 @@ class Gruff::Line < Gruff::Base
200
188
 
201
189
  data_row.coordinates.each_with_index do |(x_data, y_data), index|
202
190
  if x_data.nil?
203
- #use the old method: equally spaced points along the x-axis
191
+ # use the old method: equally spaced points along the x-axis
204
192
  new_x = @graph_left + (@x_increment * index)
205
193
  draw_label(new_x, index)
206
194
  else
@@ -221,12 +209,12 @@ class Gruff::Line < Gruff::Base
221
209
  circle_radius = @dot_radius || clip_value_if_greater_than(@columns / (store.norm_data.first.y_points.size * 2.5), 5.0)
222
210
 
223
211
  if !@hide_lines && prev_x && prev_y
224
- Gruff::Renderer::Line.new(color: data_row.color, width: stroke_width)
212
+ Gruff::Renderer::Line.new(renderer, color: data_row.color, width: stroke_width)
225
213
  .render(prev_x, prev_y, new_x, new_y)
226
214
  end
227
215
 
228
216
  if one_point || !@hide_dots
229
- Gruff::Renderer::Dot.new(@dot_style, color: data_row.color, width: stroke_width).render(new_x, new_y, circle_radius)
217
+ Gruff::Renderer::Dot.new(renderer, @dot_style, color: data_row.color, width: stroke_width).render(new_x, new_y, circle_radius)
230
218
  end
231
219
 
232
220
  prev_x = new_x
@@ -235,8 +223,6 @@ class Gruff::Line < Gruff::Base
235
223
  end
236
224
  end
237
225
 
238
- private
239
-
240
226
  def setup_data
241
227
  # Update the global min/max values for the x data
242
228
  @maximum_x_value ||= store.max_x
@@ -259,6 +245,11 @@ private
259
245
  super
260
246
  end
261
247
 
248
+ def setup_drawing
249
+ @marker_x_count ||= column_count - 1
250
+ super
251
+ end
252
+
262
253
  def normalize
263
254
  return unless data_given?
264
255
 
@@ -277,6 +268,24 @@ private
277
268
  super unless store.data.any?(&:x_points)
278
269
  end
279
270
 
271
+ def draw_line_markers
272
+ # do all of the stuff for the horizontal lines on the y-axis
273
+ super
274
+ return if @hide_line_markers
275
+
276
+ (0..@marker_x_count).each do |index|
277
+ if @show_vertical_markers
278
+ x = @graph_left + @graph_width - index * @graph_width / @marker_x_count
279
+
280
+ Gruff::Renderer::Line.new(renderer, color: @marker_color).render(x, @graph_bottom, x, @graph_top)
281
+ # If the user specified a marker shadow color, draw a shadow just below it
282
+ if @marker_shadow_color
283
+ Gruff::Renderer::Line.new(renderer, color: @marker_shadow_color).render(x + 1, @graph_bottom, x + 1, @graph_top)
284
+ end
285
+ end
286
+ end
287
+ end
288
+
280
289
  def get_x_coord(x_data_point, width, offset)
281
290
  x_data_point * width + offset
282
291
  end
@@ -16,27 +16,30 @@ module Gruff
16
16
  module Mini
17
17
  # A class for drawing a small bar graph.
18
18
  class Bar < Gruff::Bar
19
+ private
20
+
19
21
  include Gruff::Mini::Legend
20
22
 
21
- def initialize_ivars
23
+ def initialize_attributes
22
24
  super
23
25
 
24
26
  @hide_legend = true
25
27
  @hide_title = true
26
28
  @hide_line_numbers = true
27
29
 
28
- @marker_font_size = 50.0
29
- @legend_font_size = 60.0
30
+ @marker_font.size = 50.0
31
+ @legend_font.size = 60.0
30
32
 
31
33
  @minimum_value = 0.0
32
34
  end
33
- private :initialize_ivars
34
35
 
35
- def draw
36
+ def setup_data
36
37
  expand_canvas_for_vertical_legend
37
-
38
38
  super
39
+ end
39
40
 
41
+ def draw_graph
42
+ super
40
43
  draw_vertical_legend
41
44
  end
42
45
  end
@@ -3,6 +3,7 @@
3
3
  module Gruff
4
4
  module Mini
5
5
  # A module to handle the small legend.
6
+ # @private
6
7
  module Legend
7
8
  attr_accessor :hide_mini_legend, :legend_position
8
9
 
@@ -30,18 +31,20 @@ module Gruff
30
31
  @rows = [@rows, legend_height].max
31
32
  @columns += calculate_legend_width + @left_margin
32
33
  else
33
- @rows += store.length * calculate_caps_height(scale_fontsize(@legend_font_size)) * 1.7
34
+ font = @legend_font.dup
35
+ font.size = scale_fontsize(font.size)
36
+ @rows += store.length * calculate_caps_height(font) * 1.7
34
37
  end
35
38
 
36
- Gruff::Renderer.setup(@columns, @rows, @font, @scale, @theme_options)
39
+ @renderer = Gruff::Renderer.new(@columns, @rows, @scale, @theme_options)
37
40
  end
38
41
 
39
42
  def calculate_line_height
40
- calculate_caps_height(@legend_font_size) * 1.7
43
+ calculate_caps_height(@legend_font) * 1.7
41
44
  end
42
45
 
43
46
  def calculate_legend_width
44
- width = @legend_labels.map { |label| calculate_width(@legend_font_size, label) }.max
47
+ width = @legend_labels.map { |label| calculate_width(@legend_font, label) }.max
45
48
  scale_fontsize(width + 40 * 1.7)
46
49
  end
47
50
 
@@ -67,12 +70,12 @@ module Gruff
67
70
  @legend_labels.each_with_index do |legend_label, index|
68
71
  # Draw label
69
72
  label = truncate_legend_label(legend_label)
70
- text_renderer = Gruff::Renderer::Text.new(label, font: @font, size: @legend_font_size, color: @font_color)
73
+ text_renderer = Gruff::Renderer::Text.new(renderer, label, font: @legend_font)
71
74
  x_offset = current_x_offset + (legend_square_width * 1.7)
72
75
  text_renderer.add_to_render_queue(@raw_columns, 1.0, x_offset, current_y_offset, Magick::WestGravity)
73
76
 
74
77
  # Now draw box with color of this dataset
75
- rect_renderer = Gruff::Renderer::Rectangle.new(color: store.data[index].color)
78
+ rect_renderer = Gruff::Renderer::Rectangle.new(renderer, color: store.data[index].color)
76
79
  rect_renderer.render(current_x_offset,
77
80
  current_y_offset - legend_square_width / 2.0,
78
81
  current_x_offset + legend_square_width,
@@ -90,9 +93,10 @@ module Gruff
90
93
  def truncate_legend_label(label)
91
94
  truncated_label = label.to_s
92
95
 
93
- font_size = scale_fontsize(@legend_font_size)
96
+ font = @legend_font.dup
97
+ font.size = scale_fontsize(font.size)
94
98
  max_width = @columns - @legend_left_margin - @right_margin
95
- while calculate_width(font_size, truncated_label) > max_width && truncated_label.length > 1
99
+ while calculate_width(font, truncated_label) > max_width && truncated_label.length > 1
96
100
  truncated_label = truncated_label[0..truncated_label.length - 2]
97
101
  end
98
102
  truncated_label + (truncated_label.length < label.to_s.length ? '...' : '')