gruff 0.10.0-java → 0.13.0-java
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 +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +24 -4
- data/.rubocop_todo.yml +94 -42
- data/.travis.yml +3 -6
- data/CHANGELOG.md +35 -0
- data/README.md +10 -1
- data/assets/fonts/LICENSE.txt +202 -0
- data/assets/fonts/Roboto-Bold.ttf +0 -0
- data/assets/fonts/Roboto-Regular.ttf +0 -0
- data/gruff.gemspec +8 -3
- data/lib/gruff.rb +8 -3
- data/lib/gruff/accumulator_bar.rb +0 -2
- data/lib/gruff/area.rb +2 -6
- data/lib/gruff/bar.rb +35 -35
- data/lib/gruff/base.rb +295 -188
- data/lib/gruff/bezier.rb +0 -4
- data/lib/gruff/bullet.rb +12 -14
- data/lib/gruff/dot.rb +8 -33
- data/lib/gruff/helper/bar_conversion.rb +34 -19
- data/lib/gruff/helper/bar_value_label.rb +68 -0
- data/lib/gruff/histogram.rb +25 -25
- data/lib/gruff/line.rb +29 -26
- data/lib/gruff/mini/bar.rb +1 -1
- data/lib/gruff/mini/legend.rb +9 -4
- data/lib/gruff/mini/pie.rb +1 -2
- data/lib/gruff/mini/side_bar.rb +1 -2
- data/lib/gruff/net.rb +19 -20
- data/lib/gruff/patch/rmagick.rb +22 -24
- data/lib/gruff/patch/string.rb +7 -4
- data/lib/gruff/photo_bar.rb +12 -16
- data/lib/gruff/pie.rb +19 -30
- data/lib/gruff/renderer/bezier.rb +4 -3
- data/lib/gruff/renderer/circle.rb +4 -3
- data/lib/gruff/renderer/dash_line.rb +4 -3
- data/lib/gruff/renderer/dot.rb +4 -3
- data/lib/gruff/renderer/ellipse.rb +4 -3
- data/lib/gruff/renderer/line.rb +14 -5
- data/lib/gruff/renderer/polygon.rb +5 -4
- data/lib/gruff/renderer/polyline.rb +4 -3
- data/lib/gruff/renderer/rectangle.rb +3 -2
- data/lib/gruff/renderer/renderer.rb +31 -38
- data/lib/gruff/renderer/text.rb +39 -9
- data/lib/gruff/scatter.rb +30 -44
- data/lib/gruff/scene.rb +0 -1
- data/lib/gruff/side_bar.rb +60 -45
- data/lib/gruff/side_stacked_bar.rb +30 -19
- data/lib/gruff/spider.rb +18 -17
- data/lib/gruff/stacked_area.rb +8 -7
- data/lib/gruff/stacked_bar.rb +28 -18
- data/lib/gruff/store/{base_data.rb → basic_data.rb} +9 -7
- data/lib/gruff/store/custom_data.rb +8 -6
- data/lib/gruff/store/store.rb +6 -5
- data/lib/gruff/store/xy_data.rb +10 -7
- data/lib/gruff/version.rb +1 -1
- metadata +36 -9
- data/Rakefile +0 -23
- data/docker/Dockerfile +0 -14
- data/docker/build.sh +0 -4
- data/docker/launch.sh +0 -4
- data/lib/gruff/helper/bar_value_label_mixin.rb +0 -30
data/lib/gruff/mini/bar.rb
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
#
|
|
15
15
|
module Gruff
|
|
16
16
|
module Mini
|
|
17
|
+
# A class for drawing a small bar graph.
|
|
17
18
|
class Bar < Gruff::Bar
|
|
18
19
|
include Gruff::Mini::Legend
|
|
19
20
|
|
|
@@ -37,7 +38,6 @@ module Gruff
|
|
|
37
38
|
super
|
|
38
39
|
|
|
39
40
|
draw_vertical_legend
|
|
40
|
-
Gruff::Renderer.finish
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
end
|
data/lib/gruff/mini/legend.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Gruff
|
|
4
4
|
module Mini
|
|
5
|
+
# A module to handle the small legend.
|
|
5
6
|
module Legend
|
|
6
7
|
attr_accessor :hide_mini_legend, :legend_position
|
|
7
8
|
|
|
@@ -25,7 +26,7 @@ module Gruff
|
|
|
25
26
|
@original_columns = @raw_columns
|
|
26
27
|
|
|
27
28
|
case @legend_position
|
|
28
|
-
when :right
|
|
29
|
+
when :right
|
|
29
30
|
@rows = [@rows, legend_height].max
|
|
30
31
|
@columns += calculate_legend_width + @left_margin
|
|
31
32
|
else
|
|
@@ -55,7 +56,7 @@ module Gruff
|
|
|
55
56
|
legend_top_margin = 40.0
|
|
56
57
|
|
|
57
58
|
case @legend_position
|
|
58
|
-
when :right
|
|
59
|
+
when :right
|
|
59
60
|
current_x_offset = @original_columns + @left_margin
|
|
60
61
|
current_y_offset = @top_margin + legend_top_margin
|
|
61
62
|
else
|
|
@@ -67,7 +68,8 @@ module Gruff
|
|
|
67
68
|
# Draw label
|
|
68
69
|
label = truncate_legend_label(legend_label)
|
|
69
70
|
text_renderer = Gruff::Renderer::Text.new(label, font: @font, size: @legend_font_size, color: @font_color)
|
|
70
|
-
|
|
71
|
+
x_offset = current_x_offset + (legend_square_width * 1.7)
|
|
72
|
+
text_renderer.add_to_render_queue(@raw_columns, 1.0, x_offset, current_y_offset, Magick::WestGravity)
|
|
71
73
|
|
|
72
74
|
# Now draw box with color of this dataset
|
|
73
75
|
rect_renderer = Gruff::Renderer::Rectangle.new(color: store.data[index].color)
|
|
@@ -87,7 +89,10 @@ module Gruff
|
|
|
87
89
|
|
|
88
90
|
def truncate_legend_label(label)
|
|
89
91
|
truncated_label = label.to_s
|
|
90
|
-
|
|
92
|
+
|
|
93
|
+
font_size = scale_fontsize(@legend_font_size)
|
|
94
|
+
max_width = @columns - @legend_left_margin - @right_margin
|
|
95
|
+
while calculate_width(font_size, truncated_label) > max_width && truncated_label.length > 1
|
|
91
96
|
truncated_label = truncated_label[0..truncated_label.length - 2]
|
|
92
97
|
end
|
|
93
98
|
truncated_label + (truncated_label.length < label.to_s.length ? '...' : '')
|
data/lib/gruff/mini/pie.rb
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
#
|
|
14
14
|
module Gruff
|
|
15
15
|
module Mini
|
|
16
|
+
# A class for drawing a small pie graph.
|
|
16
17
|
class Pie < Gruff::Pie
|
|
17
18
|
include Gruff::Mini::Legend
|
|
18
19
|
|
|
@@ -34,8 +35,6 @@ module Gruff
|
|
|
34
35
|
super
|
|
35
36
|
|
|
36
37
|
draw_vertical_legend
|
|
37
|
-
|
|
38
|
-
Gruff::Renderer.finish
|
|
39
38
|
end
|
|
40
39
|
end
|
|
41
40
|
end
|
data/lib/gruff/mini/side_bar.rb
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
#
|
|
22
22
|
module Gruff
|
|
23
23
|
module Mini
|
|
24
|
+
# A class for drawing a small side bar graph.
|
|
24
25
|
class SideBar < Gruff::SideBar
|
|
25
26
|
include Gruff::Mini::Legend
|
|
26
27
|
|
|
@@ -41,8 +42,6 @@ module Gruff
|
|
|
41
42
|
super
|
|
42
43
|
|
|
43
44
|
draw_vertical_legend
|
|
44
|
-
|
|
45
|
-
Gruff::Renderer.finish
|
|
46
45
|
end
|
|
47
46
|
end
|
|
48
47
|
end
|
data/lib/gruff/net.rb
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'gruff/base'
|
|
4
|
-
|
|
5
3
|
# See also the Spider graph.
|
|
6
4
|
#
|
|
7
5
|
# Here's how to make a Gruff::Net.
|
|
@@ -25,17 +23,19 @@ require 'gruff/base'
|
|
|
25
23
|
# g.write("net.png")
|
|
26
24
|
#
|
|
27
25
|
class Gruff::Net < Gruff::Base
|
|
28
|
-
# Hide parts of the graph to fit more
|
|
29
|
-
|
|
26
|
+
# Hide parts of the graph to fit more data points, or for a different appearance.
|
|
27
|
+
attr_writer :hide_dots
|
|
30
28
|
|
|
31
29
|
# Dimensions of lines and dots; calculated based on dataset size if left unspecified.
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
attr_writer :line_width
|
|
31
|
+
attr_writer :dot_radius
|
|
34
32
|
|
|
35
33
|
def initialize_ivars
|
|
36
34
|
super
|
|
37
35
|
|
|
38
36
|
@hide_dots = false
|
|
37
|
+
@line_width = nil
|
|
38
|
+
@dot_radius = nil
|
|
39
39
|
@hide_line_numbers = true
|
|
40
40
|
@sorted_drawing = true
|
|
41
41
|
end
|
|
@@ -46,9 +46,6 @@ class Gruff::Net < Gruff::Base
|
|
|
46
46
|
|
|
47
47
|
return unless data_given?
|
|
48
48
|
|
|
49
|
-
stroke_width = line_width || clip_value_if_greater_than(@columns / (store.norm_data.first.points.size * 4), 5.0)
|
|
50
|
-
circle_radius = dot_radius || clip_value_if_greater_than(@columns / (store.norm_data.first.points.size * 2.5), 5.0)
|
|
51
|
-
|
|
52
49
|
store.norm_data.each do |data_row|
|
|
53
50
|
data_row.points.each_with_index do |data_point, index|
|
|
54
51
|
next if data_point.nil?
|
|
@@ -65,13 +62,14 @@ class Gruff::Net < Gruff::Base
|
|
|
65
62
|
end_x = @center_x + Math.sin(next_rad_pos) * next_point_distance
|
|
66
63
|
end_y = @center_y - Math.cos(next_rad_pos) * next_point_distance
|
|
67
64
|
|
|
68
|
-
Gruff::Renderer::Line.new(color: data_row.color, width: stroke_width).render(start_x, start_y, end_x, end_y)
|
|
65
|
+
Gruff::Renderer::Line.new(color: data_row.color, width: @stroke_width).render(start_x, start_y, end_x, end_y)
|
|
69
66
|
|
|
70
|
-
|
|
67
|
+
unless @hide_dots
|
|
68
|
+
circle_renderer = Gruff::Renderer::Circle.new(color: data_row.color, width: @stroke_width)
|
|
69
|
+
circle_renderer.render(start_x, start_y, start_x - @circle_radius, start_y)
|
|
70
|
+
end
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
|
-
|
|
74
|
-
Gruff::Renderer.finish
|
|
75
73
|
end
|
|
76
74
|
|
|
77
75
|
private
|
|
@@ -80,8 +78,10 @@ private
|
|
|
80
78
|
super
|
|
81
79
|
|
|
82
80
|
@radius = @graph_height / 2.0
|
|
81
|
+
@circle_radius = @dot_radius || clip_value_if_greater_than(@columns / (store.norm_data.first.points.size * 2.5), 5.0)
|
|
82
|
+
@stroke_width = @line_width || clip_value_if_greater_than(@columns / (store.norm_data.first.points.size * 4), 5.0)
|
|
83
83
|
@center_x = @graph_left + (@graph_width / 2.0)
|
|
84
|
-
@center_y = @graph_top + (@graph_height / 2.0)
|
|
84
|
+
@center_y = @graph_top + (@graph_height / 2.0) + 10
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
# the lines connecting in the center, with the first line vertical
|
|
@@ -95,20 +95,19 @@ private
|
|
|
95
95
|
Gruff::Renderer::Line.new(color: @marker_color)
|
|
96
96
|
.render(@center_x, @center_y, @center_x + Math.sin(rad_pos) * @radius, @center_y - Math.cos(rad_pos) * @radius)
|
|
97
97
|
|
|
98
|
-
marker_label = labels[index] ? labels[index].to_s : '000'
|
|
99
|
-
draw_label(@center_x, @center_y, rad_pos * 360 / (2 * Math::PI), @radius, marker_label)
|
|
98
|
+
marker_label = @labels[index] ? @labels[index].to_s : '000'
|
|
99
|
+
draw_label(@center_x, @center_y, rad_pos * 360 / (2 * Math::PI), @radius + @circle_radius, marker_label)
|
|
100
100
|
end
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
def draw_label(center_x, center_y, angle, radius, amount)
|
|
104
|
-
r_offset = 1.1
|
|
105
104
|
x_offset = center_x # + 15 # The label points need to be tweaked slightly
|
|
106
105
|
y_offset = center_y # + 0 # This one doesn't though
|
|
107
|
-
x = x_offset + (radius
|
|
108
|
-
y = y_offset - (radius
|
|
106
|
+
x = x_offset + (radius + LABEL_MARGIN) * Math.sin(deg2rad(angle))
|
|
107
|
+
y = y_offset - (radius + LABEL_MARGIN) * Math.cos(deg2rad(angle))
|
|
109
108
|
|
|
110
109
|
# Draw label
|
|
111
110
|
text_renderer = Gruff::Renderer::Text.new(amount, font: @font, size: 20, color: @marker_color, weight: Magick::BoldWeight)
|
|
112
|
-
text_renderer.
|
|
111
|
+
text_renderer.add_to_render_queue(0, 0, x, y, Magick::CenterGravity)
|
|
113
112
|
end
|
|
114
113
|
end
|
data/lib/gruff/patch/rmagick.rb
CHANGED
|
@@ -1,33 +1,31 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# @private
|
|
3
4
|
module Magick
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
# @private
|
|
6
|
+
module GruffAnnotate
|
|
7
|
+
refine Draw do
|
|
8
|
+
# Additional method to scale annotation text since Draw.scale doesn't.
|
|
9
|
+
def annotate_scaled(img, width, height, x, y, text, scale)
|
|
10
|
+
scaled_width = (width * scale) >= 1 ? (width * scale) : 1
|
|
11
|
+
scaled_height = (height * scale) >= 1 ? (height * scale) : 1
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
13
|
+
annotate(img,
|
|
14
|
+
scaled_width, scaled_height,
|
|
15
|
+
x * scale, y * scale,
|
|
16
|
+
text.gsub('%', '%%'))
|
|
17
|
+
end
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
if defined? JRUBY_VERSION
|
|
20
|
+
# FIXME(uwe): We should NOT need to implement this method.
|
|
21
|
+
# Remove this method as soon as RMagick4J Issue #16 is fixed.
|
|
22
|
+
# https://github.com/Serabe/RMagick4J/issues/16
|
|
23
|
+
def fill=(fill)
|
|
24
|
+
fill = { white: '#FFFFFF' }[fill.to_sym] || fill
|
|
25
|
+
@draw.fill = Magick4J.ColorDatabase.query_default(fill)
|
|
26
|
+
self
|
|
27
|
+
end
|
|
29
28
|
end
|
|
30
|
-
# EMXIF
|
|
31
29
|
end
|
|
32
30
|
end
|
|
33
31
|
end
|
data/lib/gruff/patch/string.rb
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# @private
|
|
4
|
+
module String::GruffCommify
|
|
4
5
|
THOUSAND_SEPARATOR = ','
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
refine String do
|
|
8
|
+
#Taken from http://codesnippets.joyent.com/posts/show/330
|
|
9
|
+
def commify(delimiter = THOUSAND_SEPARATOR)
|
|
10
|
+
gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{delimiter}")
|
|
11
|
+
end
|
|
9
12
|
end
|
|
10
13
|
end
|
data/lib/gruff/photo_bar.rb
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'gruff/base'
|
|
4
|
-
|
|
5
3
|
# EXPERIMENTAL!
|
|
6
4
|
#
|
|
7
5
|
# Doesn't work yet.
|
|
8
6
|
#
|
|
9
7
|
class Gruff::PhotoBar < Gruff::Base
|
|
10
|
-
# TODO
|
|
11
|
-
#
|
|
12
|
-
# define base and cap in yml
|
|
13
|
-
# allow for image directory to be located elsewhere
|
|
14
|
-
# more exact measurements for bar heights (go all the way to the bottom of the graph)
|
|
15
|
-
# option to tile images instead of use a single image
|
|
16
|
-
# drop base label a few px lower so photo bar graphs can have a base dropping over the lower marker line
|
|
17
|
-
#
|
|
8
|
+
# TODO
|
|
9
|
+
#
|
|
10
|
+
# define base and cap in yml
|
|
11
|
+
# allow for image directory to be located elsewhere
|
|
12
|
+
# more exact measurements for bar heights (go all the way to the bottom of the graph)
|
|
13
|
+
# option to tile images instead of use a single image
|
|
14
|
+
# drop base label a few px lower so photo bar graphs can have a base dropping over the lower marker line
|
|
15
|
+
#
|
|
18
16
|
|
|
19
17
|
# The name of a pre-packaged photo-based theme.
|
|
20
18
|
attr_reader :theme
|
|
21
19
|
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
20
|
+
# def initialize(target_width=800)
|
|
21
|
+
# super
|
|
22
|
+
# init_photo_bar_graphics()
|
|
23
|
+
# end
|
|
26
24
|
|
|
27
25
|
def draw
|
|
28
26
|
super
|
|
@@ -70,8 +68,6 @@ class Gruff::PhotoBar < Gruff::Base
|
|
|
70
68
|
draw_label(label_center, point_index)
|
|
71
69
|
end
|
|
72
70
|
end
|
|
73
|
-
|
|
74
|
-
Gruff::Renderer.finish
|
|
75
71
|
end
|
|
76
72
|
|
|
77
73
|
# Return the chosen theme or the default
|
data/lib/gruff/pie.rb
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'gruff/base'
|
|
4
|
-
|
|
5
3
|
#
|
|
6
4
|
# Here's how to make a Gruff::Pie.
|
|
7
5
|
#
|
|
@@ -29,35 +27,28 @@ class Gruff::Pie < Gruff::Base
|
|
|
29
27
|
attr_writer :text_offset_percentage
|
|
30
28
|
|
|
31
29
|
## Use values instead of percentages.
|
|
32
|
-
|
|
30
|
+
attr_writer :show_values_as_labels
|
|
31
|
+
|
|
32
|
+
def initialize_store
|
|
33
|
+
@store = Gruff::Store.new(Gruff::Store::CustomData)
|
|
34
|
+
end
|
|
35
|
+
private :initialize_store
|
|
33
36
|
|
|
34
37
|
def initialize_ivars
|
|
35
38
|
super
|
|
36
|
-
|
|
39
|
+
@zero_degree = 0.0
|
|
40
|
+
@hide_labels_less_than = 0.0
|
|
41
|
+
@text_offset_percentage = DEFAULT_TEXT_OFFSET_PERCENTAGE
|
|
37
42
|
@show_values_as_labels = false
|
|
38
|
-
|
|
39
|
-
@store = Gruff::Store.new(Gruff::Store::CustomData)
|
|
40
43
|
end
|
|
41
44
|
private :initialize_ivars
|
|
42
45
|
|
|
43
|
-
def zero_degree
|
|
44
|
-
@zero_degree ||= 0.0
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def hide_labels_less_than
|
|
48
|
-
@hide_labels_less_than ||= 0.0
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def text_offset_percentage
|
|
52
|
-
@text_offset_percentage ||= DEFAULT_TEXT_OFFSET_PERCENTAGE
|
|
53
|
-
end
|
|
54
|
-
|
|
55
46
|
def options
|
|
56
47
|
{
|
|
57
|
-
zero_degree: zero_degree,
|
|
58
|
-
hide_labels_less_than: hide_labels_less_than,
|
|
59
|
-
text_offset_percentage: text_offset_percentage,
|
|
60
|
-
show_values_as_labels: show_values_as_labels
|
|
48
|
+
zero_degree: @zero_degree,
|
|
49
|
+
hide_labels_less_than: @hide_labels_less_than,
|
|
50
|
+
text_offset_percentage: @text_offset_percentage,
|
|
51
|
+
show_values_as_labels: @show_values_as_labels
|
|
61
52
|
}
|
|
62
53
|
end
|
|
63
54
|
|
|
@@ -76,8 +67,6 @@ class Gruff::Pie < Gruff::Base
|
|
|
76
67
|
update_chart_degrees_with slice.degrees
|
|
77
68
|
end
|
|
78
69
|
end
|
|
79
|
-
|
|
80
|
-
Gruff::Renderer.finish
|
|
81
70
|
end
|
|
82
71
|
|
|
83
72
|
private
|
|
@@ -88,7 +77,7 @@ private
|
|
|
88
77
|
|
|
89
78
|
slices.sort_by(&:value) if @sort
|
|
90
79
|
|
|
91
|
-
total = slices.
|
|
80
|
+
total = slices.sum(&:value).to_f
|
|
92
81
|
slices.each { |slice| slice.total = total }
|
|
93
82
|
end
|
|
94
83
|
end
|
|
@@ -110,7 +99,7 @@ private
|
|
|
110
99
|
# Spatial Value-Related Methods
|
|
111
100
|
|
|
112
101
|
def chart_degrees
|
|
113
|
-
@chart_degrees ||= zero_degree
|
|
102
|
+
@chart_degrees ||= @zero_degree
|
|
114
103
|
end
|
|
115
104
|
|
|
116
105
|
attr_reader :graph_height
|
|
@@ -146,17 +135,17 @@ private
|
|
|
146
135
|
end
|
|
147
136
|
|
|
148
137
|
def radius_offset
|
|
149
|
-
radius + (radius * text_offset_percentage) + distance_from_center
|
|
138
|
+
radius + (radius * @text_offset_percentage) + distance_from_center
|
|
150
139
|
end
|
|
151
140
|
|
|
152
141
|
def ellipse_factor
|
|
153
|
-
radius_offset * text_offset_percentage
|
|
142
|
+
radius_offset * @text_offset_percentage
|
|
154
143
|
end
|
|
155
144
|
|
|
156
145
|
# Label-Related Methods
|
|
157
146
|
|
|
158
147
|
def process_label_for(slice)
|
|
159
|
-
if slice.percentage >= hide_labels_less_than
|
|
148
|
+
if slice.percentage >= @hide_labels_less_than
|
|
160
149
|
x, y = label_coordinates_for slice
|
|
161
150
|
|
|
162
151
|
draw_label(x, y, slice.label)
|
|
@@ -181,7 +170,7 @@ private
|
|
|
181
170
|
|
|
182
171
|
def draw_label(x, y, value)
|
|
183
172
|
text_renderer = Gruff::Renderer::Text.new(value, font: @font, size: @marker_font_size, color: @font_color, weight: Magick::BoldWeight)
|
|
184
|
-
text_renderer.
|
|
173
|
+
text_renderer.add_to_render_queue(0, 0, x, y, Magick::CenterGravity)
|
|
185
174
|
end
|
|
186
175
|
|
|
187
176
|
# Helper Classes
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Gruff
|
|
4
|
+
# @private
|
|
4
5
|
class Renderer::Bezier
|
|
5
|
-
def initialize(
|
|
6
|
-
@color =
|
|
7
|
-
@width =
|
|
6
|
+
def initialize(color:, width: 1.0)
|
|
7
|
+
@color = color
|
|
8
|
+
@width = width
|
|
8
9
|
end
|
|
9
10
|
|
|
10
11
|
def render(points)
|