gruff 0.23.0-java → 0.25.0-java

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: ccbe03d82324858d43ef208c29e5fe685df853100bdd7e2a5541b5b35e9cd82e
4
- data.tar.gz: 19578cbb0ca970e05c2a64a87fa9cee93398552b643dacaa2ad7ffa4737054b5
3
+ metadata.gz: 25e07b14aea532cd3028f414074893612a930266e45f8f9d92e89d5c8e385f8f
4
+ data.tar.gz: 82b241d691cd579fd654fef22d1571dbcb64168cc6b0243ff99048af7babdcf8
5
5
  SHA512:
6
- metadata.gz: f0681e1a7f9798f151de44df7af54508d9b8d4b98361357049550a3adc89bc65ffdb526c4a8576eed3f81249384e10a7e2dc97103d4afd04a0c9a80eec1001e5
7
- data.tar.gz: 3eba1ccf0e2ebab141946bc814dd6a6b638a4dd4da9641988dae36f0f3ec53b0529499ac5b1f2f78fa9387251d9a98f7cda9a8c00c5a3f481aecbe06965463a2
6
+ metadata.gz: f498d0d6c7703ae51b85335c77ce8f17f9e4e4cccfe86b7bab167612fd7c59a5c1fa3f06c24d366f93ca39a9d6393f12ec7aa430b5e249eadd6e0c4ce0b7f588
7
+ data.tar.gz: 23ee70685ba4c293104bd4f3c1a6a6e960e1fc6fa9200476d69dcc27f253c71b7d20d4acd859bfe8a5fb93db1aeb940eab006470bed3b955d184bdb47e1db53b
@@ -15,18 +15,18 @@ 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
- - name: Set up Ruby 2.6
21
+ - name: Set up Ruby 3.0
22
22
  uses: ruby/setup-ruby@master
23
23
  with:
24
- ruby-version: '2.6'
24
+ ruby-version: '3.0'
25
25
  bundler-cache: true
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.2.1
29
+ uses: r7kamura/rubocop-problem-matchers-action@v1
30
30
  - name: Run tests
31
31
  run: bundle exec rubocop
32
32
 
@@ -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: ['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-29, 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.4.6.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/.rubocop.yml CHANGED
@@ -5,7 +5,7 @@ require:
5
5
 
6
6
  AllCops:
7
7
  EnabledByDefault: true
8
- TargetRubyVersion: 2.6
8
+ TargetRubyVersion: 3.0
9
9
  Exclude:
10
10
  - 'vendor/bundle/**/*'
11
11
  - 'rails_generators/gruff/**/*'
@@ -13,13 +13,13 @@ AllCops:
13
13
  Metrics:
14
14
  Enabled: false
15
15
 
16
- Gemspec/DependencyVersion:
16
+ Bundler/GemComment:
17
17
  Enabled: false
18
18
 
19
- Gemspec/DevelopmentDependencies:
19
+ Bundler/GemVersion:
20
20
  Enabled: false
21
21
 
22
- Gemspec/OrderedDependencies:
22
+ Gemspec/DependencyVersion:
23
23
  Enabled: false
24
24
 
25
25
  Gemspec/RequiredRubyVersion:
@@ -67,6 +67,9 @@ Naming/VariableNumber:
67
67
  Style/AccessorGrouping:
68
68
  Enabled: false
69
69
 
70
+ Style/ArrayFirstLast:
71
+ Enabled: false
72
+
70
73
  Style/ClassAndModuleChildren:
71
74
  Enabled: false
72
75
 
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.25.0
4
+ - Add bigdecimal gem as dependency for Ruby 3.4
5
+ - Update dependent RMagick version to 5.5.0 or later
6
+ - Drop Ruby 2.6 and 2.7 support (#632)
7
+
8
+ ## 0.24.0
9
+ - Add the way to make background transparent (#631)
10
+ - Adjust line number position on side graph (#624)
11
+ - Add hide_labels attribute in Gruff::Dot (#623)
12
+ - Fix where SideBar's labels were sometimes missing by incorrect left margin
13
+
3
14
  ## 0.23.0
4
15
  - Update dependent RMagick version to 5.3.0 or later (#622)
5
16
 
data/Gemfile CHANGED
@@ -4,3 +4,15 @@ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in gruff.gemspec
6
6
  gemspec
7
+
8
+ unless defined? JRUBY_VERSION
9
+ gem 'rubocop', '~> 1.63.4'
10
+ gem 'rubocop-minitest', '~> 0.35.0'
11
+ gem 'rubocop-performance', '~> 1.21'
12
+ gem 'rubocop-rake', '~> 0.6.0'
13
+ end
14
+
15
+ gem 'minitest-reporters'
16
+ gem 'rake'
17
+ gem 'simplecov'
18
+ gem 'yard', '~> 0.9.28'
data/gruff.gemspec CHANGED
@@ -22,19 +22,13 @@ Gem::Specification.new do |s|
22
22
  s.platform = 'java'
23
23
  s.add_dependency 'rmagick4j'
24
24
  else
25
- s.add_dependency 'rmagick', '>= 5.3'
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'
29
- s.add_development_dependency 'rubocop-rake', '~> 0.6.0'
25
+ s.add_dependency 'rmagick', '>= 5.5'
30
26
  end
27
+ s.add_dependency 'bigdecimal', '>= 3.0'
31
28
  s.add_dependency 'histogram'
32
- s.required_ruby_version = '>= 2.6.0'
33
-
34
- s.add_development_dependency 'rake'
35
- s.add_development_dependency 'minitest-reporters'
36
- s.add_development_dependency 'simplecov'
37
- s.add_development_dependency 'yard', '~> 0.9.28'
29
+ s.required_ruby_version = '>= 3.0.0'
38
30
 
31
+ s.metadata['bug_tracker_uri'] = 'https://github.com/topfunky/gruff/issues'
32
+ s.metadata['changelog_uri'] = 'https://github.com/topfunky/gruff/blob/master/CHANGELOG.md'
39
33
  s.metadata['rubygems_mfa_required'] = 'true'
40
34
  end
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
data/lib/gruff/line.rb CHANGED
@@ -53,7 +53,7 @@ class Gruff::Line < Gruff::Base
53
53
  if args.empty? || (!args.first.is_a?(Numeric) && !args.first.is_a?(String))
54
54
  super()
55
55
  else
56
- super args.shift
56
+ super(args.shift)
57
57
  end
58
58
  end
59
59
 
@@ -308,7 +308,7 @@ private
308
308
  if x_data.nil?
309
309
  draw_label(new_x, index)
310
310
  else
311
- @labels.each do |label_pos, _|
311
+ @labels.each_key do |label_pos|
312
312
  draw_label(@graph_left + (((label_pos - @minimum_x_value) * @graph_width) / (@maximum_x_value - @minimum_x_value)), label_pos)
313
313
  end
314
314
  end
@@ -5,7 +5,7 @@ module Gruff
5
5
  class Renderer::Dot
6
6
  def initialize(renderer, style, color:, width: 1.0, opacity: 1.0)
7
7
  @renderer = renderer
8
- @style = style
8
+ @style = style.to_sym
9
9
  @color = color
10
10
  @width = width
11
11
  @opacity = opacity
@@ -17,7 +17,7 @@ module Gruff
17
17
  @renderer.draw.stroke(@color)
18
18
  @renderer.draw.fill_opacity(@opacity)
19
19
  @renderer.draw.fill(@color)
20
- case @style.to_sym
20
+ case @style
21
21
  when :square
22
22
  square(new_x, new_y, radius)
23
23
  when :diamond
@@ -28,6 +28,8 @@ module Gruff
28
28
  @renderer.draw.pop
29
29
  end
30
30
 
31
+ private
32
+
31
33
  def circle(new_x, new_y, radius)
32
34
  @renderer.draw.circle(new_x, new_y, new_x - radius, new_y)
33
35
  end
@@ -13,7 +13,7 @@ module Gruff
13
13
  def render(upper_left_x, upper_left_y, lower_right_x, lower_right_y)
14
14
  @renderer.draw.push
15
15
  @renderer.draw.stroke_width(@width)
16
- @renderer.draw.stroke(@color) if @width > 1.0
16
+ @renderer.draw.stroke(@color) if @color && @width > 1.0
17
17
  @renderer.draw.fill_opacity(@opacity)
18
18
  @renderer.draw.fill(@color) if @color
19
19
  @renderer.draw.rectangle(upper_left_x, upper_left_y, lower_right_x, lower_right_y)
@@ -23,19 +23,32 @@ module Gruff
23
23
  end
24
24
  end
25
25
 
26
+ def transparent_background(columns, rows)
27
+ @image = render_transparent_background(columns, rows)
28
+ end
29
+
30
+ private
31
+
26
32
  def background(columns, rows, scale, theme_options)
33
+ return image_background(scale, *theme_options[:background_image]) if theme_options[:background_image]
34
+
27
35
  case theme_options[:background_colors]
28
36
  when Array
29
37
  gradated_background(columns, rows, *theme_options[:background_colors][0..1], theme_options[:background_direction])
30
38
  when String
31
39
  solid_background(columns, rows, theme_options[:background_colors])
32
40
  else
33
- image_background(scale, *theme_options[:background_image])
41
+ transparent_background(columns, rows)
34
42
  end
35
43
  end
36
44
 
37
- def transparent_background(columns, rows)
38
- @image = render_transparent_background(columns, rows)
45
+ # Use with a theme to use an image (800x600 original) background.
46
+ def image_background(scale, image_path)
47
+ image = Magick::Image.read(image_path)
48
+ if scale != 1.0
49
+ image[0].resize!(scale) # TODO: Resize with new scale (crop if necessary for wide graph)
50
+ end
51
+ image[0]
39
52
  end
40
53
 
41
54
  # Make a new image at the current size with a solid +color+.
@@ -80,17 +93,6 @@ module Gruff
80
93
  end
81
94
  end
82
95
 
83
- private
84
-
85
- # Use with a theme to use an image (800x600 original) background.
86
- def image_background(scale, image_path)
87
- image = Magick::Image.read(image_path)
88
- if scale != 1.0
89
- image[0].resize!(scale) # TODO: Resize with new scale (crop if necessary for wide graph)
90
- end
91
- image[0]
92
- end
93
-
94
96
  # Use with a theme to make a transparent background
95
97
  def render_transparent_background(columns, rows)
96
98
  Magick::Image.new(columns, rows) do |img|
@@ -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
@@ -35,21 +35,21 @@ module Gruff
35
35
  end
36
36
 
37
37
  def min
38
- @min ||= @data.map(&:min).compact.min
38
+ @min ||= @data.filter_map(&:min).min
39
39
  end
40
40
  alias min_y min
41
41
 
42
42
  def max
43
- @max ||= @data.map(&:max).compact.max
43
+ @max ||= @data.filter_map(&:max).max
44
44
  end
45
45
  alias max_y max
46
46
 
47
47
  def min_x
48
- @min_x ||= @data.map(&:min_x).compact.min
48
+ @min_x ||= @data.filter_map(&:min_x).min
49
49
  end
50
50
 
51
51
  def max_x
52
- @max_x ||= @data.map(&:max_x).compact.max
52
+ @max_x ||= @data.filter_map(&:max_x).max
53
53
  end
54
54
 
55
55
  def sort_data!
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.23.0'
4
+ VERSION = '0.25.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.23.0
4
+ version: 0.25.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-07-19 00:00:00.000000000 Z
12
+ date: 2024-05-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement
@@ -18,22 +18,8 @@ dependencies:
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  name: rmagick4j
21
- prerelease: false
22
21
  type: :runtime
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- version: '0'
28
- - !ruby/object:Gem::Dependency
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- name: histogram
35
22
  prerelease: false
36
- type: :runtime
37
23
  version_requirements: !ruby/object:Gem::Requirement
38
24
  requirements:
39
25
  - - ">="
@@ -44,57 +30,29 @@ dependencies:
44
30
  requirements:
45
31
  - - ">="
46
32
  - !ruby/object:Gem::Version
47
- version: '0'
48
- name: rake
49
- prerelease: false
50
- type: :development
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: '0'
56
- - !ruby/object:Gem::Dependency
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- name: minitest-reporters
33
+ version: '3.0'
34
+ name: bigdecimal
35
+ type: :runtime
63
36
  prerelease: false
64
- type: :development
65
37
  version_requirements: !ruby/object:Gem::Requirement
66
38
  requirements:
67
39
  - - ">="
68
40
  - !ruby/object:Gem::Version
69
- version: '0'
41
+ version: '3.0'
70
42
  - !ruby/object:Gem::Dependency
71
43
  requirement: !ruby/object:Gem::Requirement
72
44
  requirements:
73
45
  - - ">="
74
46
  - !ruby/object:Gem::Version
75
47
  version: '0'
76
- name: simplecov
48
+ name: histogram
49
+ type: :runtime
77
50
  prerelease: false
78
- type: :development
79
51
  version_requirements: !ruby/object:Gem::Requirement
80
52
  requirements:
81
53
  - - ">="
82
54
  - !ruby/object:Gem::Version
83
55
  version: '0'
84
- - !ruby/object:Gem::Dependency
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 0.9.28
90
- name: yard
91
- prerelease: false
92
- type: :development
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - "~>"
96
- - !ruby/object:Gem::Version
97
- version: 0.9.28
98
56
  description: Beautiful graphs for one or multiple datasets. Can be used on websites
99
57
  or in documents.
100
58
  email: boss@topfunky.com
@@ -174,6 +132,8 @@ homepage: https://github.com/topfunky/gruff
174
132
  licenses:
175
133
  - MIT
176
134
  metadata:
135
+ bug_tracker_uri: https://github.com/topfunky/gruff/issues
136
+ changelog_uri: https://github.com/topfunky/gruff/blob/master/CHANGELOG.md
177
137
  rubygems_mfa_required: 'true'
178
138
  post_install_message:
179
139
  rdoc_options: []
@@ -183,14 +143,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
183
143
  requirements:
184
144
  - - ">="
185
145
  - !ruby/object:Gem::Version
186
- version: 2.6.0
146
+ version: 3.0.0
187
147
  required_rubygems_version: !ruby/object:Gem::Requirement
188
148
  requirements:
189
149
  - - ">="
190
150
  - !ruby/object:Gem::Version
191
151
  version: '0'
192
152
  requirements: []
193
- rubygems_version: 3.3.25
153
+ rubygems_version: 3.3.26
194
154
  signing_key:
195
155
  specification_version: 4
196
156
  summary: Beautiful graphs for one or multiple datasets.