gruff 0.19.0-java → 0.21.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +5 -5
- data/.rubocop.yml +17 -1
- data/CHANGELOG.md +9 -0
- data/gruff.gemspec +4 -3
- data/lib/gruff/bar.rb +1 -1
- data/lib/gruff/base.rb +12 -9
- data/lib/gruff/box.rb +4 -4
- data/lib/gruff/candlestick.rb +3 -3
- data/lib/gruff/mini/bar.rb +19 -24
- data/lib/gruff/mini/legend.rb +93 -105
- data/lib/gruff/mini/pie.rb +18 -23
- data/lib/gruff/mini/side_bar.rb +18 -23
- data/lib/gruff/patch/rmagick.rb +2 -2
- data/lib/gruff/version.rb +1 -1
- data/lib/gruff.rb +3 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d569a4cf8b46975563f111d9c2715da9d77da0216b5fa38d6f6be33f1ff8255c
|
4
|
+
data.tar.gz: b362cc9b3ebf58503cbc898a73e69ce927a559637ebc8cb89977f02221c60211
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46afebf1af13fc4b11ed067dcda1556050827c477a4dddf306d2530e264b65bb9e1dc85cc8c28295e810b4a27b38bf682a9a7e803e75720f57a5eb1a374eba25
|
7
|
+
data.tar.gz: 5b6b6e86e9616405b296a2c931a93c276fb773ed24963705c5e078f992eca0bd1074abdad4ee5f42aa1f88513ede0b4c9ce157a17f207a2ae7648dca61e6ef67
|
data/.github/workflows/ci.yml
CHANGED
@@ -18,10 +18,10 @@ jobs:
|
|
18
18
|
- uses: actions/checkout@v3
|
19
19
|
with:
|
20
20
|
ref: ${{ github.event.pull_request.head.sha }}
|
21
|
-
- name: Set up Ruby 2.
|
21
|
+
- name: Set up Ruby 2.6
|
22
22
|
uses: ruby/setup-ruby@master
|
23
23
|
with:
|
24
|
-
ruby-version: '2.
|
24
|
+
ruby-version: '2.6'
|
25
25
|
bundler-cache: true
|
26
26
|
- name: Install dependencies
|
27
27
|
run: bundle install --path=vendor/bundle --jobs 4 --retry 3
|
@@ -35,9 +35,9 @@ jobs:
|
|
35
35
|
timeout-minutes: 20
|
36
36
|
strategy:
|
37
37
|
matrix:
|
38
|
-
ruby-version: ['2.
|
38
|
+
ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2']
|
39
39
|
imagemagick-version:
|
40
|
-
- { full: 7.1.0-
|
40
|
+
- { full: 7.1.0-55, major-minor: '7.1' }
|
41
41
|
name: Ruby ${{ matrix.ruby-version }}
|
42
42
|
steps:
|
43
43
|
- uses: actions/checkout@v3
|
@@ -67,7 +67,7 @@ jobs:
|
|
67
67
|
timeout-minutes: 20
|
68
68
|
strategy:
|
69
69
|
matrix:
|
70
|
-
ruby-version: ['9.
|
70
|
+
ruby-version: ['9.3.10.0', '9.4.2.0']
|
71
71
|
name: JRuby ${{ matrix.ruby-version }}
|
72
72
|
steps:
|
73
73
|
- uses: actions/checkout@v3
|
data/.rubocop.yml
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require:
|
2
|
+
- rubocop-minitest
|
2
3
|
- rubocop-performance
|
3
4
|
- rubocop-rake
|
4
5
|
|
5
6
|
AllCops:
|
6
7
|
EnabledByDefault: true
|
7
|
-
TargetRubyVersion: 2.
|
8
|
+
TargetRubyVersion: 2.6
|
8
9
|
Exclude:
|
9
10
|
- 'vendor/bundle/**/*'
|
10
11
|
- 'rails_generators/gruff/**/*'
|
@@ -12,6 +13,12 @@ AllCops:
|
|
12
13
|
Metrics:
|
13
14
|
Enabled: false
|
14
15
|
|
16
|
+
Gemspec/DependencyVersion:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Gemspec/DevelopmentDependencies:
|
20
|
+
Enabled: false
|
21
|
+
|
15
22
|
Gemspec/OrderedDependencies:
|
16
23
|
Enabled: false
|
17
24
|
|
@@ -21,6 +28,9 @@ Gemspec/RequiredRubyVersion:
|
|
21
28
|
Layout/AccessModifierIndentation:
|
22
29
|
EnforcedStyle: outdent
|
23
30
|
|
31
|
+
Layout/ClassStructure:
|
32
|
+
Enabled: false
|
33
|
+
|
24
34
|
Layout/FirstMethodArgumentLineBreak:
|
25
35
|
Enabled: false
|
26
36
|
|
@@ -111,11 +121,17 @@ Style/OptionHash:
|
|
111
121
|
Style/RedundantBegin:
|
112
122
|
Enabled: false
|
113
123
|
|
124
|
+
Style/RequireOrder:
|
125
|
+
Enabled: false
|
126
|
+
|
114
127
|
Style/SingleLineBlockParams:
|
115
128
|
Enabled: false
|
116
129
|
|
117
130
|
Style/StructInheritance:
|
118
131
|
Enabled: false
|
119
132
|
|
133
|
+
Style/YodaExpression:
|
134
|
+
Enabled: false
|
135
|
+
|
120
136
|
Performance/ChainArrayAllocation:
|
121
137
|
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.21.0
|
4
|
+
- Fix legend color with empty label (#615)
|
5
|
+
|
6
|
+
## 0.20.0
|
7
|
+
- Fix legend position when blank labels present (#614)
|
8
|
+
- Fixed NoMethodError (undefined method `format=` for Gruff::Line (#612)
|
9
|
+
- Drop Ruby 2.5 support (#611)
|
10
|
+
- Fix deprecation warning for Base#to_blob (#610)
|
11
|
+
|
3
12
|
## 0.19.0
|
4
13
|
- Draw the graph starting from zero point by default (#609)
|
5
14
|
- Improve joints in Gruff::Net using polyline method (#608)
|
data/gruff.gemspec
CHANGED
@@ -23,12 +23,13 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_dependency 'rmagick4j'
|
24
24
|
else
|
25
25
|
s.add_dependency 'rmagick', '>= 4.2'
|
26
|
-
s.add_development_dependency 'rubocop', '~> 1.
|
27
|
-
s.add_development_dependency 'rubocop-
|
26
|
+
s.add_development_dependency 'rubocop', '~> 1.50.2'
|
27
|
+
s.add_development_dependency 'rubocop-minitest', '~> 0.30.0'
|
28
|
+
s.add_development_dependency 'rubocop-performance', '~> 1.17.1'
|
28
29
|
s.add_development_dependency 'rubocop-rake', '~> 0.6.0'
|
29
30
|
end
|
30
31
|
s.add_dependency 'histogram'
|
31
|
-
s.required_ruby_version = '>= 2.
|
32
|
+
s.required_ruby_version = '>= 2.6.0'
|
32
33
|
|
33
34
|
s.add_development_dependency 'rake'
|
34
35
|
s.add_development_dependency 'minitest-reporters'
|
data/lib/gruff/bar.rb
CHANGED
@@ -48,7 +48,7 @@ class Gruff::Bar < Gruff::Base
|
|
48
48
|
#
|
49
49
|
# Default value is +0.9+.
|
50
50
|
def spacing_factor=(space_percent)
|
51
|
-
raise ArgumentError, 'spacing_factor must be between 0.00 and 1.00'
|
51
|
+
raise ArgumentError, 'spacing_factor must be between 0.00 and 1.00' if (space_percent < 0) || (space_percent > 1)
|
52
52
|
|
53
53
|
@spacing_factor = (1 - space_percent)
|
54
54
|
end
|
data/lib/gruff/base.rb
CHANGED
@@ -218,7 +218,7 @@ module Gruff
|
|
218
218
|
# g.labels = ['2005', nil, nil, '2006', nil, nil, '2007', nil, nil, '2008'] # same labels for columns
|
219
219
|
def labels=(labels)
|
220
220
|
if labels.is_a?(Array)
|
221
|
-
labels = labels.each_with_index.
|
221
|
+
labels = labels.each_with_index.with_object({}) do |(label, index), hash|
|
222
222
|
hash[index] = label
|
223
223
|
end
|
224
224
|
end
|
@@ -522,9 +522,8 @@ module Gruff
|
|
522
522
|
# @deprecated Please use +to_image.to_blob+ instead.
|
523
523
|
def to_blob(image_format = 'PNG')
|
524
524
|
warn '#to_blob is deprecated. Please use `to_image.to_blob` instead'
|
525
|
-
to_image.
|
526
|
-
|
527
|
-
end
|
525
|
+
to_image.format = image_format
|
526
|
+
to_image.to_blob
|
528
527
|
end
|
529
528
|
|
530
529
|
# Draw a graph.
|
@@ -822,7 +821,7 @@ module Gruff
|
|
822
821
|
end
|
823
822
|
|
824
823
|
def clip_value_if_greater_than(value, max_value)
|
825
|
-
value
|
824
|
+
[value, max_value].min
|
826
825
|
end
|
827
826
|
|
828
827
|
def significant(i)
|
@@ -908,7 +907,7 @@ module Gruff
|
|
908
907
|
bottom_label_width = extra_left_room_for_long_label
|
909
908
|
|
910
909
|
margin = line_number_width + y_axis_label_width
|
911
|
-
@left_margin +
|
910
|
+
@left_margin + [margin, bottom_label_width].max
|
912
911
|
end
|
913
912
|
|
914
913
|
def setup_right_margin
|
@@ -1037,8 +1036,12 @@ module Gruff
|
|
1037
1036
|
label_widths = [[]]
|
1038
1037
|
label_lines = [[]]
|
1039
1038
|
legend_labels.each do |label|
|
1040
|
-
|
1041
|
-
|
1039
|
+
if label.empty?
|
1040
|
+
label_width = 0.0
|
1041
|
+
else
|
1042
|
+
width = calculate_width(@legend_font, label)
|
1043
|
+
label_width = width + (legend_square_width * 2.7)
|
1044
|
+
end
|
1042
1045
|
label_widths.last.push label_width
|
1043
1046
|
label_lines.last.push label
|
1044
1047
|
|
@@ -1130,7 +1133,7 @@ module Gruff
|
|
1130
1133
|
-(width / 2.0)
|
1131
1134
|
end
|
1132
1135
|
end
|
1133
|
-
y_offset = (height / 2.0)
|
1136
|
+
y_offset = [(height / 2.0), margin].max
|
1134
1137
|
|
1135
1138
|
[x_offset, y_offset]
|
1136
1139
|
end
|
data/lib/gruff/box.rb
CHANGED
@@ -23,7 +23,7 @@ class Gruff::Box < Gruff::Base
|
|
23
23
|
#
|
24
24
|
# Default value is +0.8+.
|
25
25
|
def spacing_factor=(space_percent)
|
26
|
-
raise ArgumentError, 'spacing_factor must be between 0.00 and 1.00'
|
26
|
+
raise ArgumentError, 'spacing_factor must be between 0.00 and 1.00' if (space_percent < 0) || (space_percent > 1)
|
27
27
|
|
28
28
|
@spacing_factor = (1 - space_percent)
|
29
29
|
end
|
@@ -134,7 +134,7 @@ private
|
|
134
134
|
end
|
135
135
|
|
136
136
|
def median
|
137
|
-
if points.
|
137
|
+
if points.empty?
|
138
138
|
0
|
139
139
|
elsif points.size.odd?
|
140
140
|
points[points.size / 2]
|
@@ -144,7 +144,7 @@ private
|
|
144
144
|
end
|
145
145
|
|
146
146
|
def first_quartile
|
147
|
-
if points.
|
147
|
+
if points.empty?
|
148
148
|
0
|
149
149
|
elsif points.size.odd?
|
150
150
|
points[points.size / 4]
|
@@ -154,7 +154,7 @@ private
|
|
154
154
|
end
|
155
155
|
|
156
156
|
def third_quartile
|
157
|
-
if points.
|
157
|
+
if points.empty?
|
158
158
|
0
|
159
159
|
elsif points.size.odd?
|
160
160
|
points[(points.size * 3) / 4]
|
data/lib/gruff/candlestick.rb
CHANGED
@@ -33,7 +33,7 @@ class Gruff::Candlestick < Gruff::Base
|
|
33
33
|
#
|
34
34
|
# Default value is +0.9+.
|
35
35
|
def spacing_factor=(space_percent)
|
36
|
-
raise ArgumentError, 'spacing_factor must be between 0.00 and 1.00'
|
36
|
+
raise ArgumentError, 'spacing_factor must be between 0.00 and 1.00' if (space_percent < 0) || (space_percent > 1)
|
37
37
|
|
38
38
|
@spacing_factor = (1 - space_percent)
|
39
39
|
end
|
@@ -90,10 +90,10 @@ private
|
|
90
90
|
Gruff::Renderer::Rectangle.new(renderer, color: color, opacity: @fill_opacity, width: @stroke_width).render(left_x, open_y, right_x, close_y)
|
91
91
|
|
92
92
|
low_y, = conversion.get_top_bottom_scaled(candlestick.low)
|
93
|
-
y = open_y
|
93
|
+
y = [open_y, close_y].max
|
94
94
|
Gruff::Renderer::Line.new(renderer, color: color, width: @stroke_width).render(center_x, low_y, center_x, y)
|
95
95
|
high_y, = conversion.get_top_bottom_scaled(candlestick.high)
|
96
|
-
y = open_y
|
96
|
+
y = [open_y, close_y].min
|
97
97
|
Gruff::Renderer::Line.new(renderer, color: color, width: @stroke_width).render(center_x, y, center_x, high_y)
|
98
98
|
end
|
99
99
|
end
|
data/lib/gruff/mini/bar.rb
CHANGED
@@ -12,36 +12,31 @@
|
|
12
12
|
# g.data :Science, [2, 15, 8, 11]
|
13
13
|
# g.write('mini_bar.png')
|
14
14
|
#
|
15
|
-
|
16
|
-
|
17
|
-
# A class for drawing a small bar graph.
|
18
|
-
class Bar < Gruff::Bar
|
19
|
-
private
|
15
|
+
class Gruff::Mini::Bar < Gruff::Bar
|
16
|
+
private
|
20
17
|
|
21
|
-
|
18
|
+
include Gruff::Mini::Legend
|
22
19
|
|
23
|
-
|
24
|
-
|
20
|
+
def initialize_attributes
|
21
|
+
super
|
25
22
|
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
@hide_legend = true
|
24
|
+
@hide_title = true
|
25
|
+
@hide_line_numbers = true
|
29
26
|
|
30
|
-
|
31
|
-
|
27
|
+
@marker_font.size = 50.0
|
28
|
+
@legend_font.size = 50.0
|
32
29
|
|
33
|
-
|
34
|
-
|
30
|
+
@minimum_value = 0.0
|
31
|
+
end
|
35
32
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
def setup_data
|
34
|
+
expand_canvas_for_vertical_legend
|
35
|
+
super
|
36
|
+
end
|
40
37
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
38
|
+
def draw_graph
|
39
|
+
super
|
40
|
+
draw_vertical_legend
|
46
41
|
end
|
47
42
|
end
|
data/lib/gruff/mini/legend.rb
CHANGED
@@ -1,110 +1,98 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
when :right
|
63
|
-
current_x_offset = @original_columns + @left_margin
|
64
|
-
current_y_offset = @top_margin + legend_top_margin
|
65
|
-
else
|
66
|
-
current_x_offset = @legend_left_margin
|
67
|
-
current_y_offset = @original_rows + legend_top_margin
|
68
|
-
end
|
69
|
-
|
70
|
-
@legend_labels.each_with_index do |legend_label, index|
|
71
|
-
# Draw label
|
72
|
-
x_offset = current_x_offset + (legend_square_width * 1.7)
|
73
|
-
label = truncate_legend_label(legend_label, x_offset)
|
74
|
-
text_renderer = Gruff::Renderer::Text.new(renderer, label, font: @legend_font)
|
75
|
-
text_renderer.add_to_render_queue(@raw_columns, 1.0, x_offset, current_y_offset, Magick::WestGravity)
|
76
|
-
|
77
|
-
# Now draw box with color of this dataset
|
78
|
-
rect_renderer = Gruff::Renderer::Rectangle.new(renderer, color: store.data[index].color)
|
79
|
-
rect_renderer.render(current_x_offset,
|
80
|
-
current_y_offset - (legend_square_width / 2.0),
|
81
|
-
current_x_offset + legend_square_width,
|
82
|
-
current_y_offset + (legend_square_width / 2.0))
|
83
|
-
|
84
|
-
current_y_offset += calculate_line_height
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
##
|
89
|
-
# Shorten long labels so they will fit on the canvas.
|
90
|
-
#
|
91
|
-
# Department of Hu...
|
92
|
-
|
93
|
-
def truncate_legend_label(label, x_offset)
|
94
|
-
truncated_label = label.to_s
|
95
|
-
|
96
|
-
font = @legend_font.dup
|
97
|
-
font.size = scale(font.size)
|
98
|
-
max_width = @columns - scale(x_offset) - @right_margin
|
99
|
-
while calculate_width(font, "#{truncated_label}...") > max_width && truncated_label.length > 1
|
100
|
-
truncated_label = truncated_label[0..truncated_label.length - 2]
|
101
|
-
end
|
102
|
-
truncated_label + (truncated_label.length < label.to_s.length ? '...' : '')
|
103
|
-
end
|
104
|
-
|
105
|
-
def scale(value)
|
106
|
-
value * @scale
|
107
|
-
end
|
3
|
+
# A module to handle the small legend.
|
4
|
+
# @private
|
5
|
+
module Gruff::Mini::Legend
|
6
|
+
attr_accessor :hide_mini_legend, :legend_position
|
7
|
+
|
8
|
+
def initialize(*)
|
9
|
+
@hide_mini_legend = false
|
10
|
+
@legend_position = nil
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
# The canvas needs to be bigger so we can put the legend beneath it.
|
15
|
+
def expand_canvas_for_vertical_legend
|
16
|
+
return if @hide_mini_legend
|
17
|
+
|
18
|
+
@legend_labels = store.data.map(&:label)
|
19
|
+
|
20
|
+
legend_height = scale((store.length * calculate_line_height) + @top_margin + @bottom_margin)
|
21
|
+
|
22
|
+
@original_rows = @raw_rows
|
23
|
+
@original_columns = @raw_columns
|
24
|
+
|
25
|
+
case @legend_position
|
26
|
+
when :right
|
27
|
+
@rows = [@rows, legend_height].max
|
28
|
+
@columns += calculate_legend_width + @left_margin
|
29
|
+
else
|
30
|
+
font = @legend_font.dup
|
31
|
+
font.size = scale(font.size)
|
32
|
+
@rows += store.length * calculate_caps_height(font) * 1.7
|
33
|
+
end
|
34
|
+
|
35
|
+
@renderer = Gruff::Renderer.new(@columns, @rows, @scale, @theme_options)
|
36
|
+
end
|
37
|
+
|
38
|
+
def calculate_line_height
|
39
|
+
calculate_caps_height(@legend_font) * 1.7
|
40
|
+
end
|
41
|
+
|
42
|
+
def calculate_legend_width
|
43
|
+
width = @legend_labels.map { |label| calculate_width(@legend_font, label) }.max
|
44
|
+
scale(width + (40 * 1.7))
|
45
|
+
end
|
46
|
+
|
47
|
+
# Draw the legend beneath the existing graph.
|
48
|
+
def draw_vertical_legend
|
49
|
+
return if @hide_mini_legend
|
50
|
+
|
51
|
+
legend_square_width = 40.0 # small square with color of this item
|
52
|
+
@legend_left_margin = 100.0
|
53
|
+
legend_top_margin = 40.0
|
54
|
+
|
55
|
+
case @legend_position
|
56
|
+
when :right
|
57
|
+
current_x_offset = @original_columns + @left_margin
|
58
|
+
current_y_offset = @top_margin + legend_top_margin
|
59
|
+
else
|
60
|
+
current_x_offset = @legend_left_margin
|
61
|
+
current_y_offset = @original_rows + legend_top_margin
|
108
62
|
end
|
63
|
+
|
64
|
+
@legend_labels.each_with_index do |legend_label, index|
|
65
|
+
# Draw label
|
66
|
+
x_offset = current_x_offset + (legend_square_width * 1.7)
|
67
|
+
label = truncate_legend_label(legend_label, x_offset)
|
68
|
+
text_renderer = Gruff::Renderer::Text.new(renderer, label, font: @legend_font)
|
69
|
+
text_renderer.add_to_render_queue(@raw_columns, 1.0, x_offset, current_y_offset, Magick::WestGravity)
|
70
|
+
|
71
|
+
# Now draw box with color of this dataset
|
72
|
+
rect_renderer = Gruff::Renderer::Rectangle.new(renderer, color: store.data[index].color)
|
73
|
+
rect_renderer.render(current_x_offset,
|
74
|
+
current_y_offset - (legend_square_width / 2.0),
|
75
|
+
current_x_offset + legend_square_width,
|
76
|
+
current_y_offset + (legend_square_width / 2.0))
|
77
|
+
|
78
|
+
current_y_offset += calculate_line_height
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Shorten long labels so they will fit on the canvas.
|
83
|
+
def truncate_legend_label(label, x_offset)
|
84
|
+
truncated_label = label.to_s
|
85
|
+
|
86
|
+
font = @legend_font.dup
|
87
|
+
font.size = scale(font.size)
|
88
|
+
max_width = @columns - scale(x_offset) - @right_margin
|
89
|
+
while calculate_width(font, "#{truncated_label}...") > max_width && truncated_label.length > 1
|
90
|
+
truncated_label = truncated_label[0..truncated_label.length - 2]
|
91
|
+
end
|
92
|
+
truncated_label + (truncated_label.length < label.to_s.length ? '...' : '')
|
93
|
+
end
|
94
|
+
|
95
|
+
def scale(value)
|
96
|
+
value * @scale
|
109
97
|
end
|
110
98
|
end
|
data/lib/gruff/mini/pie.rb
CHANGED
@@ -11,34 +11,29 @@
|
|
11
11
|
# g.data 'Hamburgers', 50
|
12
12
|
# g.write("mini_pie_keynote.png")
|
13
13
|
#
|
14
|
-
|
15
|
-
|
16
|
-
# A class for drawing a small pie graph.
|
17
|
-
class Pie < Gruff::Pie
|
18
|
-
private
|
14
|
+
class Gruff::Mini::Pie < Gruff::Pie
|
15
|
+
private
|
19
16
|
|
20
|
-
|
17
|
+
include Gruff::Mini::Legend
|
21
18
|
|
22
|
-
|
23
|
-
|
19
|
+
def initialize_attributes
|
20
|
+
super
|
24
21
|
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
@hide_legend = true
|
23
|
+
@hide_title = true
|
24
|
+
@hide_line_numbers = true
|
28
25
|
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
@marker_font.size = 50.0
|
27
|
+
@legend_font.size = 50.0
|
28
|
+
end
|
32
29
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
30
|
+
def setup_data
|
31
|
+
expand_canvas_for_vertical_legend
|
32
|
+
super
|
33
|
+
end
|
37
34
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
42
|
-
end
|
35
|
+
def draw_graph
|
36
|
+
super
|
37
|
+
draw_vertical_legend
|
43
38
|
end
|
44
39
|
end
|
data/lib/gruff/mini/side_bar.rb
CHANGED
@@ -19,33 +19,28 @@
|
|
19
19
|
# g.data :Science, [2, 15, 8, 11]
|
20
20
|
# g.write('mini_sidebar.png')
|
21
21
|
#
|
22
|
-
|
23
|
-
|
24
|
-
# A class for drawing a small side bar graph.
|
25
|
-
class SideBar < Gruff::SideBar
|
26
|
-
private
|
22
|
+
class Gruff::Mini::SideBar < Gruff::SideBar
|
23
|
+
private
|
27
24
|
|
28
|
-
|
25
|
+
include Gruff::Mini::Legend
|
29
26
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
27
|
+
def initialize_attributes
|
28
|
+
super
|
29
|
+
@hide_legend = true
|
30
|
+
@hide_title = true
|
31
|
+
@hide_line_numbers = true
|
35
32
|
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
@marker_font.size = 50.0
|
34
|
+
@legend_font.size = 50.0
|
35
|
+
end
|
39
36
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
37
|
+
def setup_data
|
38
|
+
expand_canvas_for_vertical_legend
|
39
|
+
super
|
40
|
+
end
|
44
41
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
49
|
-
end
|
42
|
+
def draw_graph
|
43
|
+
super
|
44
|
+
draw_vertical_legend
|
50
45
|
end
|
51
46
|
end
|
data/lib/gruff/patch/rmagick.rb
CHANGED
@@ -7,8 +7,8 @@ module Magick
|
|
7
7
|
refine Draw do
|
8
8
|
# Additional method to scale annotation text since Draw.scale doesn't.
|
9
9
|
def annotate_scaled(img, width, height, x, y, text, scale)
|
10
|
-
scaled_width = (width * scale)
|
11
|
-
scaled_height = (height * scale)
|
10
|
+
scaled_width = [(width * scale), 1].max
|
11
|
+
scaled_height = [(height * scale), 1].max
|
12
12
|
|
13
13
|
annotate(img,
|
14
14
|
scaled_width, scaled_height,
|
data/lib/gruff/version.rb
CHANGED
data/lib/gruff.rb
CHANGED
@@ -45,6 +45,7 @@ module Gruff
|
|
45
45
|
autoload :Layer, Gruff.libpath('scene')
|
46
46
|
autoload :Themes, Gruff.libpath('themes')
|
47
47
|
|
48
|
+
# @private
|
48
49
|
class Renderer
|
49
50
|
autoload :Bezier, Gruff.libpath('renderer/bezier')
|
50
51
|
autoload :Circle, Gruff.libpath('renderer/circle')
|
@@ -58,12 +59,14 @@ module Gruff
|
|
58
59
|
autoload :Text, Gruff.libpath('renderer/text')
|
59
60
|
end
|
60
61
|
|
62
|
+
# @private
|
61
63
|
class Store
|
62
64
|
autoload :BasicData, Gruff.libpath('store/basic_data')
|
63
65
|
autoload :XYData, Gruff.libpath('store/xy_data')
|
64
66
|
autoload :XYPointsizeData, Gruff.libpath('store/xy_pointsizes_data')
|
65
67
|
end
|
66
68
|
|
69
|
+
# A module for small graphs
|
67
70
|
module Mini
|
68
71
|
autoload :Bar, Gruff.libpath('mini/bar')
|
69
72
|
autoload :Legend, Gruff.libpath('mini/legend')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gruff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.21.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Geoffrey Grosenbach
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-06-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -183,14 +183,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
183
183
|
requirements:
|
184
184
|
- - ">="
|
185
185
|
- !ruby/object:Gem::Version
|
186
|
-
version: 2.
|
186
|
+
version: 2.6.0
|
187
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
188
|
requirements:
|
189
189
|
- - ">="
|
190
190
|
- !ruby/object:Gem::Version
|
191
191
|
version: '0'
|
192
192
|
requirements: []
|
193
|
-
rubygems_version: 3.
|
193
|
+
rubygems_version: 3.3.25
|
194
194
|
signing_key:
|
195
195
|
specification_version: 4
|
196
196
|
summary: Beautiful graphs for one or multiple datasets.
|