gruff 0.22.0 → 0.24.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94b068b7869b405ca194785d34d320aba16ff0cff793982571039498590b31e8
4
- data.tar.gz: 1e423203482f8b02d5a678f48237c627f39d09b3bbe7921b758284caf2a3f978
3
+ metadata.gz: e8ff88f3f42e4e18cbada5384d6bc3ddad3c19c216bd3bd11787d45625559780
4
+ data.tar.gz: 199aa40584af1ece67f4aa2f1b9ff12c80d1591d664c529e2e41de393925307a
5
5
  SHA512:
6
- metadata.gz: 30e1d06427a70bb4dd5c551f7154a34825f3800890f96fb56649e0b95f0eb0d8539c636535f292217b6730c0ff27652246d7444a20d60aa49c4ef50ca2eca59b
7
- data.tar.gz: 03af63b9451e5e7f62ed7260026cf6e968694f82f43d50f6eb0efd7dbf03b112d3ea6a00deb63b0b20248321f847ad1bb3c5bccd0148e337ae755526bc85ccc7
6
+ metadata.gz: c87fa241d9f6130689d54145ad78ce2d8520d0c0eaebd256c4df3428325eda2765287621287e12f596f474b4912f0c036772366a707e6a4d584544a3bc9d77f1
7
+ data.tar.gz: 404de18f0980fb59ed3afe9db6fac75e56903ecbc532604cceb879c3666396c8d86c7206941829757c70d725738109126d151eb90b120ae96d555347538b2831
@@ -15,7 +15,7 @@ jobs:
15
15
  timeout-minutes: 20
16
16
  name: Lint
17
17
  steps:
18
- - uses: actions/checkout@v3
18
+ - uses: actions/checkout@v4
19
19
  with:
20
20
  ref: ${{ github.event.pull_request.head.sha }}
21
21
  - name: Set up Ruby 2.6
@@ -35,14 +35,14 @@ jobs:
35
35
  timeout-minutes: 20
36
36
  strategy:
37
37
  matrix:
38
- ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2']
38
+ ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2', '3.3']
39
39
  imagemagick-version:
40
- - { full: 7.1.0-55, major-minor: '7.1' }
40
+ - { full: 7.1.1-15, major-minor: '7.1' }
41
41
  name: Ruby ${{ matrix.ruby-version }}
42
42
  steps:
43
- - uses: actions/checkout@v3
43
+ - uses: actions/checkout@v4
44
44
  - name: Cache ImageMagick
45
- uses: actions/cache@v3
45
+ uses: actions/cache@v4
46
46
  with:
47
47
  path: ./build-ImageMagick
48
48
  key: v1-linux-imagemagick-${{ matrix.imagemagick-version.full }}
@@ -67,10 +67,10 @@ jobs:
67
67
  timeout-minutes: 20
68
68
  strategy:
69
69
  matrix:
70
- ruby-version: ['9.3.10.0', '9.4.2.0']
70
+ ruby-version: ['9.3.10.0', '9.4.3.0']
71
71
  name: JRuby ${{ matrix.ruby-version }}
72
72
  steps:
73
- - uses: actions/checkout@v3
73
+ - uses: actions/checkout@v4
74
74
  - name: Set up Ruby
75
75
  uses: ruby/setup-ruby@master
76
76
  with:
data/CHANGELOG.md CHANGED
@@ -1,9 +1,18 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.24.0
4
+ - Add the way to make background transparent (#631)
5
+ - Adjust line number position on side graph (#624)
6
+ - Add hide_labels attribute in Gruff::Dot (#623)
7
+ - Fix where SideBar's labels were sometimes missing by incorrect left margin
8
+
9
+ ## 0.23.0
10
+ - Update dependent RMagick version to 5.3.0 or later (#622)
11
+
3
12
  ## 0.22.0
4
- Fix Gruff::Bar and Gruff::SideBar in order to draw positive and negative mixed graph (#620)
5
- Allow to override label margin value (#618)
6
- Accept image format in Base#to_image in order to fix `no decode delegate for this image format` error (#619)
13
+ - Fix Gruff::Bar and Gruff::SideBar in order to draw positive and negative mixed graph (#620)
14
+ - Allow to override label margin value (#618)
15
+ - Accept image format in Base#to_image in order to fix `no decode delegate for this image format` error (#619)
7
16
 
8
17
  ## 0.21.0
9
18
  - Fix legend color with empty label (#615)
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', '>= 4.2'
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/base.rb CHANGED
@@ -367,6 +367,14 @@ module Gruff
367
367
  @colors = color_list
368
368
  end
369
369
 
370
+ # Set whether to make background transparent.
371
+ #
372
+ # @param value [Boolean] Specify whether to make background transparent.
373
+ #
374
+ def transparent_background=(value)
375
+ @renderer.transparent_background(@columns, @rows) if value
376
+ end
377
+
370
378
  # You can set a theme manually. Assign a hash to this method before you
371
379
  # send your data.
372
380
  #
@@ -378,7 +386,13 @@ module Gruff
378
386
  # background_direction: :top_bottom
379
387
  # }
380
388
  #
381
- # +background_image: 'squirrel.png'+ is also possible.
389
+ # +background_colors+
390
+ # - Array<String> format value - background has gradation. (ex. +background_colors: ['black', 'grey']+)
391
+ # - String value - background has solid color. (ex. +background_colors: 'orange'+)
392
+ # - nil - background has transparent. (ex. +background_colors: nil+)
393
+ #
394
+ # +background_image+:
395
+ # - Specify the path to image file when it draw the image as background.
382
396
  #
383
397
  # +background_direction+ accepts one of following parameters.
384
398
  # - +:top_bottom+
@@ -400,7 +414,7 @@ module Gruff
400
414
  marker_color: 'white',
401
415
  marker_shadow_color: nil,
402
416
  font_color: 'black',
403
- background_colors: nil,
417
+ background_colors: 'gray',
404
418
  background_image: nil
405
419
  }
406
420
  @theme_options = defaults.merge options
@@ -894,14 +908,14 @@ module Gruff
894
908
  def setup_left_margin
895
909
  return @left_margin if hide_left_label_area?
896
910
 
897
- text = begin
911
+ longest_left_label_width = begin
898
912
  if @has_left_labels
899
- @labels.values.reduce('') { |value, memo| value.to_s.length > memo.to_s.length ? value : memo }
913
+ @labels.values.map { |value| calculate_width(@marker_font, truncate_label_text(value.to_s)) }.max || 0
900
914
  else
901
- y_axis_label(maximum_value, @increment)
915
+ label = y_axis_label(maximum_value, @increment)
916
+ calculate_width(@marker_font, truncate_label_text(label))
902
917
  end
903
918
  end
904
- longest_left_label_width = calculate_width(@marker_font, truncate_label_text(text))
905
919
 
906
920
  line_number_width = begin
907
921
  if !@has_left_labels && (@hide_line_markers || @hide_line_numbers)
data/lib/gruff/dot.rb CHANGED
@@ -14,6 +14,9 @@
14
14
  # g.write('dot.png')
15
15
  #
16
16
  class Gruff::Dot < Gruff::Base
17
+ # Prevent drawing of column labels below a stacked bar graph. Default is +false+.
18
+ attr_writer :hide_labels
19
+
17
20
  def initialize(*)
18
21
  super
19
22
  @has_left_labels = true
@@ -22,6 +25,23 @@ class Gruff::Dot < Gruff::Base
22
25
 
23
26
  private
24
27
 
28
+ def initialize_attributes
29
+ super
30
+ @hide_labels = false
31
+ end
32
+
33
+ def hide_labels?
34
+ @hide_labels
35
+ end
36
+
37
+ def hide_left_label_area?
38
+ hide_labels? && @y_axis_label.nil?
39
+ end
40
+
41
+ def hide_bottom_label_area?
42
+ @hide_line_markers && @x_axis_label.nil? && @legend_at_bottom == false
43
+ end
44
+
25
45
  def draw_graph
26
46
  # Setup spacing.
27
47
  #
@@ -58,8 +78,9 @@ private
58
78
 
59
79
  unless @hide_line_numbers
60
80
  label = y_axis_label(marker_label, @increment)
81
+ y = @graph_bottom + @label_margin + (labels_caps_height / 2.0) + 5 # 5px offset for tick_mark_mode
61
82
  text_renderer = Gruff::Renderer::Text.new(renderer, label, font: @marker_font)
62
- text_renderer.add_to_render_queue(0, 0, x, @graph_bottom + (@label_margin * 1.5), Magick::CenterGravity)
83
+ text_renderer.add_to_render_queue(0, 0, x, y, Magick::CenterGravity)
63
84
  end
64
85
  end
65
86
  end
@@ -24,13 +24,15 @@ module Gruff
24
24
  end
25
25
 
26
26
  def background(columns, rows, scale, theme_options)
27
+ return image_background(scale, *theme_options[:background_image]) if theme_options[:background_image]
28
+
27
29
  case theme_options[:background_colors]
28
30
  when Array
29
31
  gradated_background(columns, rows, *theme_options[:background_colors][0..1], theme_options[:background_direction])
30
32
  when String
31
33
  solid_background(columns, rows, theme_options[:background_colors])
32
34
  else
33
- image_background(scale, *theme_options[:background_image])
35
+ transparent_background(columns, rows)
34
36
  end
35
37
  end
36
38
 
@@ -159,8 +159,9 @@ private
159
159
  diff = index - number_of_lines
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
+ y = @graph_bottom + @label_margin + (labels_caps_height / 2.0)
162
163
  text_renderer = Gruff::Renderer::Text.new(renderer, label, font: @marker_font)
163
- text_renderer.add_to_render_queue(0, 0, x, @graph_bottom + @label_margin, Magick::CenterGravity)
164
+ text_renderer.add_to_render_queue(0, 0, x, y, Magick::CenterGravity)
164
165
  end
165
166
  end
166
167
  end
data/lib/gruff/spider.rb CHANGED
@@ -24,10 +24,6 @@ class Gruff::Spider < Gruff::Base
24
24
  @max_value = max_value
25
25
  end
26
26
 
27
- def transparent_background=(value)
28
- renderer.transparent_background(@columns, @rows) if value
29
- end
30
-
31
27
  def hide_text=(value)
32
28
  @hide_title = @hide_text = value
33
29
  end
data/lib/gruff/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gruff
4
- VERSION = '0.22.0'
4
+ VERSION = '0.24.0'
5
5
  end
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.22.0
4
+ version: 0.24.0
5
5
  platform: ruby
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-06-17 00:00:00.000000000 Z
12
+ date: 2024-03-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rmagick
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '4.2'
20
+ version: '5.3'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '4.2'
27
+ version: '5.3'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rubocop
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -246,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
246
246
  - !ruby/object:Gem::Version
247
247
  version: '0'
248
248
  requirements: []
249
- rubygems_version: 3.4.10
249
+ rubygems_version: 3.5.3
250
250
  signing_key:
251
251
  specification_version: 4
252
252
  summary: Beautiful graphs for one or multiple datasets.