gruff 0.21.0-java → 0.23.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 +1 -1
- data/CHANGELOG.md +8 -0
- data/README.md +2 -2
- data/gruff.gemspec +1 -1
- data/lib/gruff/bar.rb +1 -1
- data/lib/gruff/base.rb +21 -13
- data/lib/gruff/dot.rb +2 -2
- data/lib/gruff/net.rb +2 -2
- data/lib/gruff/scatter.rb +1 -1
- data/lib/gruff/side_bar.rb +4 -4
- data/lib/gruff/spider.rb +5 -5
- data/lib/gruff/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccbe03d82324858d43ef208c29e5fe685df853100bdd7e2a5541b5b35e9cd82e
|
4
|
+
data.tar.gz: 19578cbb0ca970e05c2a64a87fa9cee93398552b643dacaa2ad7ffa4737054b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0681e1a7f9798f151de44df7af54508d9b8d4b98361357049550a3adc89bc65ffdb526c4a8576eed3f81249384e10a7e2dc97103d4afd04a0c9a80eec1001e5
|
7
|
+
data.tar.gz: 3eba1ccf0e2ebab141946bc814dd6a6b638a4dd4da9641988dae36f0f3ec53b0529499ac5b1f2f78fa9387251d9a98f7cda9a8c00c5a3f481aecbe06965463a2
|
data/.github/workflows/ci.yml
CHANGED
@@ -26,7 +26,7 @@ jobs:
|
|
26
26
|
- name: Install dependencies
|
27
27
|
run: bundle install --path=vendor/bundle --jobs 4 --retry 3
|
28
28
|
- name: RuboCop Problem Matchers
|
29
|
-
uses: r7kamura/rubocop-problem-matchers-action@v1
|
29
|
+
uses: r7kamura/rubocop-problem-matchers-action@v1.2.1
|
30
30
|
- name: Run tests
|
31
31
|
run: bundle exec rubocop
|
32
32
|
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.23.0
|
4
|
+
- Update dependent RMagick version to 5.3.0 or later (#622)
|
5
|
+
|
6
|
+
## 0.22.0
|
7
|
+
- Fix Gruff::Bar and Gruff::SideBar in order to draw positive and negative mixed graph (#620)
|
8
|
+
- Allow to override label margin value (#618)
|
9
|
+
- Accept image format in Base#to_image in order to fix `no decode delegate for this image format` error (#619)
|
10
|
+
|
3
11
|
## 0.21.0
|
4
12
|
- Fix legend color with empty label (#615)
|
5
13
|
|
data/README.md
CHANGED
data/gruff.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.platform = 'java'
|
23
23
|
s.add_dependency 'rmagick4j'
|
24
24
|
else
|
25
|
-
s.add_dependency 'rmagick', '>=
|
25
|
+
s.add_dependency 'rmagick', '>= 5.3'
|
26
26
|
s.add_development_dependency 'rubocop', '~> 1.50.2'
|
27
27
|
s.add_development_dependency 'rubocop-minitest', '~> 0.30.0'
|
28
28
|
s.add_development_dependency 'rubocop-performance', '~> 1.17.1'
|
data/lib/gruff/bar.rb
CHANGED
@@ -123,7 +123,7 @@ private
|
|
123
123
|
right_x = left_x + (bar_width * @bar_spacing)
|
124
124
|
|
125
125
|
top_y, bottom_y = conversion.get_top_bottom_scaled(bar.point)
|
126
|
-
if
|
126
|
+
if top_y != bottom_y
|
127
127
|
rect_renderer = Gruff::Renderer::Rectangle.new(renderer, color: bar.color)
|
128
128
|
rect_renderer.render(left_x, bottom_y - AXIS_MARGIN, right_x, top_y)
|
129
129
|
end
|
data/lib/gruff/base.rb
CHANGED
@@ -27,6 +27,9 @@ module Gruff
|
|
27
27
|
|
28
28
|
DEFAULT_TARGET_WIDTH = 800.0
|
29
29
|
|
30
|
+
# Blank space between graph and labels. Default is +15+.
|
31
|
+
attr_writer :label_margin
|
32
|
+
|
30
33
|
# Blank space above the graph. Default is +20+.
|
31
34
|
attr_writer :top_margin
|
32
35
|
|
@@ -180,6 +183,7 @@ module Gruff
|
|
180
183
|
@marker_font = Gruff::Font.new(size: 21.0)
|
181
184
|
@legend_font = Gruff::Font.new(size: 20.0)
|
182
185
|
|
186
|
+
@label_margin = LABEL_MARGIN
|
183
187
|
@top_margin = @bottom_margin = @left_margin = @right_margin = DEFAULT_MARGIN
|
184
188
|
@legend_margin = LEGEND_MARGIN
|
185
189
|
@title_margin = TITLE_MARGIN
|
@@ -497,6 +501,8 @@ module Gruff
|
|
497
501
|
# Return a rendered graph image.
|
498
502
|
# This can use RMagick's methods to adjust the image before saving.
|
499
503
|
#
|
504
|
+
# @param format [String] The output image format.
|
505
|
+
#
|
500
506
|
# @return [Magick::Image] The rendered image.
|
501
507
|
#
|
502
508
|
# @example
|
@@ -507,22 +513,24 @@ module Gruff
|
|
507
513
|
# image = image.resize(400, 300).quantize(128, Magick::RGBColorspace)
|
508
514
|
# image.write('test.png')
|
509
515
|
#
|
510
|
-
def to_image
|
516
|
+
def to_image(format = 'PNG')
|
511
517
|
@to_image ||= begin
|
512
518
|
draw
|
513
519
|
renderer.finish
|
514
|
-
renderer.image
|
520
|
+
image = renderer.image
|
521
|
+
image.format = format
|
522
|
+
image
|
515
523
|
end
|
516
524
|
end
|
517
525
|
|
518
526
|
# Return the graph as a rendered binary blob.
|
519
527
|
#
|
520
|
-
# @param
|
528
|
+
# @param format [String] The image format of binary blob.
|
521
529
|
#
|
522
530
|
# @deprecated Please use +to_image.to_blob+ instead.
|
523
|
-
def to_blob(
|
531
|
+
def to_blob(format = 'PNG')
|
524
532
|
warn '#to_blob is deprecated. Please use `to_image.to_blob` instead'
|
525
|
-
to_image.format =
|
533
|
+
to_image.format = format
|
526
534
|
to_image.to_blob
|
527
535
|
end
|
528
536
|
|
@@ -646,7 +654,7 @@ module Gruff
|
|
646
654
|
# X Axis
|
647
655
|
# Centered vertically and horizontally by setting the
|
648
656
|
# height to 1.0 and the width to the width of the graph.
|
649
|
-
x_axis_label_y_coordinate = @graph_bottom + (
|
657
|
+
x_axis_label_y_coordinate = @graph_bottom + (@label_margin * 2) + labels_caps_height
|
650
658
|
|
651
659
|
text_renderer = Gruff::Renderer::Text.new(renderer, @x_axis_label, font: @marker_font)
|
652
660
|
text_renderer.add_to_render_queue(@raw_columns, 1.0, 0.0, x_axis_label_y_coordinate)
|
@@ -674,7 +682,7 @@ module Gruff
|
|
674
682
|
marker_label = (BigDecimal(index.to_s) * BigDecimal(@increment.to_s)) + BigDecimal(minimum_value.to_s)
|
675
683
|
label = y_axis_label(marker_label, @increment)
|
676
684
|
text_renderer = Gruff::Renderer::Text.new(renderer, label, font: @marker_font)
|
677
|
-
text_renderer.add_to_render_queue(@graph_left -
|
685
|
+
text_renderer.add_to_render_queue(@graph_left - @label_margin, 1.0, 0.0, y, Magick::EastGravity)
|
678
686
|
end
|
679
687
|
end
|
680
688
|
end
|
@@ -715,7 +723,7 @@ module Gruff
|
|
715
723
|
|
716
724
|
current_y_offset = begin
|
717
725
|
if @legend_at_bottom
|
718
|
-
@graph_bottom + @legend_margin + labels_caps_height +
|
726
|
+
@graph_bottom + @legend_margin + labels_caps_height + @label_margin + (@x_axis_label ? (@label_margin * 2) + marker_caps_height : 0)
|
719
727
|
else
|
720
728
|
hide_title? ? @top_margin + @title_margin : @top_margin + @title_margin + title_caps_height
|
721
729
|
end
|
@@ -771,7 +779,7 @@ module Gruff
|
|
771
779
|
draw_unique_label(index) do
|
772
780
|
if x >= @graph_left && x <= @graph_right
|
773
781
|
y = @graph_bottom
|
774
|
-
x_offset, y_offset = calculate_label_offset(@marker_font, @labels[index],
|
782
|
+
x_offset, y_offset = calculate_label_offset(@marker_font, @labels[index], @label_margin, @label_rotation)
|
775
783
|
|
776
784
|
draw_label_at(1.0, 1.0, x + x_offset, y + y_offset, @labels[index], gravity: gravity, rotation: @label_rotation)
|
777
785
|
yield if block
|
@@ -899,10 +907,10 @@ module Gruff
|
|
899
907
|
if !@has_left_labels && (@hide_line_markers || @hide_line_numbers)
|
900
908
|
0.0
|
901
909
|
else
|
902
|
-
longest_left_label_width +
|
910
|
+
longest_left_label_width + @label_margin
|
903
911
|
end
|
904
912
|
end
|
905
|
-
y_axis_label_width = @y_axis_label.nil? ? 0.0 : marker_caps_height + (
|
913
|
+
y_axis_label_width = @y_axis_label.nil? ? 0.0 : marker_caps_height + (@label_margin * 2)
|
906
914
|
|
907
915
|
bottom_label_width = extra_left_room_for_long_label
|
908
916
|
|
@@ -962,10 +970,10 @@ module Gruff
|
|
962
970
|
end
|
963
971
|
|
964
972
|
def setup_bottom_margin
|
965
|
-
graph_bottom_margin = hide_bottom_label_area? ? @bottom_margin : @bottom_margin + labels_caps_height +
|
973
|
+
graph_bottom_margin = hide_bottom_label_area? ? @bottom_margin : @bottom_margin + labels_caps_height + @label_margin
|
966
974
|
graph_bottom_margin += (calculate_legend_height + @legend_margin) if @legend_at_bottom
|
967
975
|
|
968
|
-
x_axis_label_height = @x_axis_label.nil? ? 0.0 : marker_caps_height + (
|
976
|
+
x_axis_label_height = @x_axis_label.nil? ? 0.0 : marker_caps_height + (@label_margin * 2)
|
969
977
|
@raw_rows - graph_bottom_margin - x_axis_label_height
|
970
978
|
end
|
971
979
|
|
data/lib/gruff/dot.rb
CHANGED
@@ -59,7 +59,7 @@ private
|
|
59
59
|
unless @hide_line_numbers
|
60
60
|
label = y_axis_label(marker_label, @increment)
|
61
61
|
text_renderer = Gruff::Renderer::Text.new(renderer, label, font: @marker_font)
|
62
|
-
text_renderer.add_to_render_queue(0, 0, x, @graph_bottom + (
|
62
|
+
text_renderer.add_to_render_queue(0, 0, x, @graph_bottom + (@label_margin * 1.5), Magick::CenterGravity)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -69,7 +69,7 @@ private
|
|
69
69
|
|
70
70
|
def draw_label(y_offset, index)
|
71
71
|
draw_unique_label(index) do
|
72
|
-
draw_label_at(@graph_left -
|
72
|
+
draw_label_at(@graph_left - @label_margin, 1.0, 0.0, y_offset, @labels[index], gravity: Magick::EastGravity)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
data/lib/gruff/net.rb
CHANGED
@@ -112,8 +112,8 @@ private
|
|
112
112
|
def draw_label(center_x, center_y, angle, radius, amount)
|
113
113
|
x_offset = center_x # + 15 # The label points need to be tweaked slightly
|
114
114
|
y_offset = center_y # + 0 # This one doesn't though
|
115
|
-
x = x_offset + ((radius +
|
116
|
-
y = y_offset - ((radius +
|
115
|
+
x = x_offset + ((radius + @label_margin) * Math.sin(deg2rad(angle)))
|
116
|
+
y = y_offset - ((radius + @label_margin) * Math.cos(deg2rad(angle)))
|
117
117
|
|
118
118
|
draw_label_at(1.0, 1.0, x, y, amount, gravity: Magick::CenterGravity)
|
119
119
|
end
|
data/lib/gruff/scatter.rb
CHANGED
@@ -188,7 +188,7 @@ private
|
|
188
188
|
label = x_axis_label(marker_label, x_increment)
|
189
189
|
x = @graph_left + (increment_x_scaled * index)
|
190
190
|
y = @graph_bottom
|
191
|
-
x_offset, y_offset = calculate_label_offset(@marker_font, label,
|
191
|
+
x_offset, y_offset = calculate_label_offset(@marker_font, label, @label_margin, @label_rotation)
|
192
192
|
|
193
193
|
draw_label_at(1.0, 1.0, x + x_offset, y + y_offset, label, rotation: @label_rotation)
|
194
194
|
end
|
data/lib/gruff/side_bar.rb
CHANGED
@@ -90,7 +90,7 @@ private
|
|
90
90
|
|
91
91
|
if minimum_value < 0
|
92
92
|
_, metrics = Gruff::BarValueLabel.metrics(minimum_value, @label_formatting, proc_text_metrics)
|
93
|
-
width = metrics.width +
|
93
|
+
width = metrics.width + @label_margin
|
94
94
|
@graph_left += width - @graph_left if width > @graph_left
|
95
95
|
end
|
96
96
|
|
@@ -120,7 +120,7 @@ private
|
|
120
120
|
right_y = left_y + (bar_width * @bar_spacing)
|
121
121
|
|
122
122
|
bottom_x, top_x = conversion.get_top_bottom_scaled(bar.point).sort
|
123
|
-
if
|
123
|
+
if bottom_x != top_x
|
124
124
|
rect_renderer = Gruff::Renderer::Rectangle.new(renderer, color: bar.color)
|
125
125
|
rect_renderer.render(bottom_x + AXIS_MARGIN, left_y, top_x, right_y)
|
126
126
|
end
|
@@ -160,7 +160,7 @@ private
|
|
160
160
|
marker_label = (BigDecimal(diff.abs.to_s) * BigDecimal(increment.to_s)) + BigDecimal(minimum_value.to_s)
|
161
161
|
label = x_axis_label(marker_label, @increment)
|
162
162
|
text_renderer = Gruff::Renderer::Text.new(renderer, label, font: @marker_font)
|
163
|
-
text_renderer.add_to_render_queue(0, 0, x, @graph_bottom +
|
163
|
+
text_renderer.add_to_render_queue(0, 0, x, @graph_bottom + @label_margin, Magick::CenterGravity)
|
164
164
|
end
|
165
165
|
end
|
166
166
|
end
|
@@ -170,7 +170,7 @@ private
|
|
170
170
|
|
171
171
|
def draw_label(y_offset, index)
|
172
172
|
draw_unique_label(index) do
|
173
|
-
draw_label_at(@graph_left -
|
173
|
+
draw_label_at(@graph_left - @label_margin, 1.0, 0.0, y_offset, @labels[index], gravity: Magick::EastGravity)
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
data/lib/gruff/spider.rb
CHANGED
@@ -54,10 +54,10 @@ private
|
|
54
54
|
def setup_graph_measurements
|
55
55
|
super
|
56
56
|
|
57
|
-
@graph_left +=
|
58
|
-
@graph_top +=
|
59
|
-
@graph_right -=
|
60
|
-
@graph_bottom -=
|
57
|
+
@graph_left += @label_margin
|
58
|
+
@graph_top += @label_margin
|
59
|
+
@graph_right -= @label_margin
|
60
|
+
@graph_bottom -= @label_margin
|
61
61
|
|
62
62
|
@graph_width = @graph_right - @graph_left
|
63
63
|
@graph_height = @graph_bottom - @graph_top
|
@@ -94,7 +94,7 @@ private
|
|
94
94
|
degree = rad2deg(angle)
|
95
95
|
metrics = text_metrics(@marker_font, amount)
|
96
96
|
|
97
|
-
r_offset =
|
97
|
+
r_offset = @label_margin # The distance out from the center of the pie to get point
|
98
98
|
x_offset = center_x # The label points need to be tweaked slightly
|
99
99
|
|
100
100
|
x_offset -= begin
|
data/lib/gruff/version.rb
CHANGED
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.23.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: 2023-
|
12
|
+
date: 2023-07-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|