gruff 0.18.0 → 0.19.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: 1b7a28fa80f8c598a927ce29242c2014a38cc21b1fc1fc43a80285239b448176
4
- data.tar.gz: 13a94cca6581eebccafd48de9d48daa1acd4c085989cd996a6054fd63bfa8f8a
3
+ metadata.gz: f2f6636a49ad24d67ee6768f20edc4e1143debd5629c09578d94e876d6597438
4
+ data.tar.gz: 42b5270bb3d229e74a5be1951c6b3b653a6e7a1e9048e8119547ba8317c2a22d
5
5
  SHA512:
6
- metadata.gz: 165988fc75b87fcd15f789ee9b178cbbe4ddc32cd0090f62cdcd36041806223b65c59406cd855038e0881ffb0b260df146aec74de7caff5ee0fc32df01447268
7
- data.tar.gz: c5dcff59b2f8ab733fc99bafee1472ab0c014fbb106bec26fca167880b585cc9e61a6cc00b4e08aa02d39a2fe92d2291a7363a13ed16673a06898edcd15fb081
6
+ metadata.gz: e91c1727af0b81f8ee30caa3b2c04573932bcf6a2571750194d7fe50b92a6c93bc9ca5c44713b188968967911b60b510b0152cfe51446e9388dd52193fcc8db4
7
+ data.tar.gz: 9d67bdab5440eee69d770df5f4f1ccb8d1e53e2f163af4312237a90d67fd0fe7f8dfea7bd97b373828c957ccfeca09edc853c35c8bf1bfd789e8b9dd3e2bc05d
@@ -0,0 +1,26 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2
+ // https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/docker-existing-dockerfile
3
+ {
4
+ "name": "Existing Dockerfile",
5
+
6
+ // Sets the run context to one level up instead of the .devcontainer folder.
7
+ "context": "..",
8
+
9
+ // Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
10
+ "dockerFile": "../Dockerfile"
11
+
12
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
13
+ // "forwardPorts": [],
14
+
15
+ // Uncomment the next line to run commands after the container is created - for example installing curl.
16
+ // "postCreateCommand": "apt-get update && apt-get install -y curl",
17
+
18
+ // Uncomment when using a ptrace-based debugger like C++, Go, and Rust
19
+ // "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
20
+
21
+ // Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
22
+ // "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
23
+
24
+ // Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
25
+ // "remoteUser": "vscode"
26
+ }
@@ -11,7 +11,7 @@ permissions:
11
11
 
12
12
  jobs:
13
13
  lint:
14
- runs-on: ubuntu-20.04
14
+ runs-on: ubuntu-22.04
15
15
  timeout-minutes: 20
16
16
  name: Lint
17
17
  steps:
@@ -31,13 +31,13 @@ jobs:
31
31
  run: bundle exec rubocop
32
32
 
33
33
  test-ruby:
34
- runs-on: ubuntu-20.04
34
+ runs-on: ubuntu-22.04
35
35
  timeout-minutes: 20
36
36
  strategy:
37
37
  matrix:
38
38
  ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1']
39
39
  imagemagick-version:
40
- - { full: 7.1.0-39, major-minor: '7.0' }
40
+ - { full: 7.1.0-45, major-minor: '7.0' }
41
41
  name: Ruby ${{ matrix.ruby-version }}
42
42
  steps:
43
43
  - uses: actions/checkout@v3
@@ -63,11 +63,11 @@ jobs:
63
63
  run: bundle exec rake
64
64
 
65
65
  test-jruby:
66
- runs-on: ubuntu-20.04
66
+ runs-on: ubuntu-22.04
67
67
  timeout-minutes: 20
68
68
  strategy:
69
69
  matrix:
70
- ruby-version: ['9.2.20.1', '9.3.4.0']
70
+ ruby-version: ['9.2.21.0', '9.3.7.0']
71
71
  name: JRuby ${{ matrix.ruby-version }}
72
72
  steps:
73
73
  - uses: actions/checkout@v3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.19.0
4
+ - Draw the graph starting from zero point by default (#609)
5
+ - Improve joints in Gruff::Net using polyline method (#608)
6
+ - Improve joints in Gruff::Line using polyline method (#607)
7
+ - Adjust default font size in Gruff::Mini::{Bar, Pie}
8
+
3
9
  ## 0.18.0
4
10
  - Add Gruff::Bubble (#604)
5
11
  - Rename Gruff::BoxPlot to Gruff::Box (#603)
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Gruff Graphs
2
2
 
3
- [![Build Status](https://travis-ci.org/topfunky/gruff.svg?branch=master)](https://travis-ci.org/topfunky/gruff)
3
+ [![CI](https://github.com/topfunky/gruff/actions/workflows/ci.yml/badge.svg)](https://github.com/topfunky/gruff/actions/workflows/ci.yml)
4
4
  [![Gem Version](https://badge.fury.io/rb/gruff.svg)](https://badge.fury.io/rb/gruff)
5
5
 
6
6
  A library for making beautiful graphs.
data/gruff.gemspec CHANGED
@@ -17,7 +17,6 @@ Gem::Specification.new do |s|
17
17
  s.summary = 'Beautiful graphs for one or multiple datasets.'
18
18
  s.license = 'MIT'
19
19
  s.executables = s.files.grep(%r{^bin/}).map { |f| File.basename(f) }
20
- s.specification_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
21
20
 
22
21
  if defined? JRUBY_VERSION
23
22
  s.platform = 'java'
data/lib/gruff/base.rb CHANGED
@@ -469,7 +469,8 @@ module Gruff
469
469
  #
470
470
  # Set it after you have given all your data to the graph object.
471
471
  def minimum_value
472
- (@minimum_value || store.min).to_f
472
+ min = [0.0, store.min.to_f].min
473
+ (@minimum_value || min).to_f
473
474
  end
474
475
  attr_writer :minimum_value
475
476
 
data/lib/gruff/bezier.rb CHANGED
@@ -24,6 +24,9 @@ private
24
24
  def draw_graph
25
25
  x_increment = (@graph_width / (column_count - 1)).to_f
26
26
 
27
+ renderer_class = RUBY_PLATFORM == 'java' ? Gruff::Renderer::Polyline : Gruff::Renderer::Bezier
28
+ stroke_width = clip_value_if_greater_than(@columns / (store.norm_data.first[1].size * 4.0), 5.0)
29
+
27
30
  store.norm_data.each do |data_row|
28
31
  next if data_row[1].empty?
29
32
 
@@ -45,13 +48,7 @@ private
45
48
  draw_label(new_x, index)
46
49
  end
47
50
 
48
- stroke_width = clip_value_if_greater_than(@columns / (store.norm_data.first[1].size * 4), 5.0)
49
-
50
- if RUBY_PLATFORM == 'java'
51
- Gruff::Renderer::Polyline.new(renderer, color: data_row.color, width: stroke_width).render(poly_points)
52
- else
53
- Gruff::Renderer::Bezier.new(renderer, color: data_row.color, width: stroke_width).render(poly_points)
54
- end
51
+ renderer_class.new(renderer, color: data_row.color, width: stroke_width).render(poly_points)
55
52
  end
56
53
  end
57
54
  end
data/lib/gruff/dot.rb CHANGED
@@ -29,7 +29,7 @@ private
29
29
 
30
30
  items_width = @graph_height / column_count
31
31
  item_width = items_width * spacing_factor / store.length
32
- padding = (items_width * (1 - spacing_factor)) / 2
32
+ padding = (items_width * (1 - spacing_factor)) / 2.0
33
33
 
34
34
  store.norm_data.each_with_index do |data_row, row_index|
35
35
  data_row.points.each_with_index do |data_point, point_index|
data/lib/gruff/line.rb CHANGED
@@ -208,12 +208,15 @@ private
208
208
  draw_vertical_reference_line(curr_reference_line) if curr_reference_line.key?(:index)
209
209
  end
210
210
 
211
- store.norm_data.each do |data_row|
212
- prev_x = prev_y = nil
211
+ stroke_width = @line_width || clip_value_if_greater_than(@columns / (store.norm_data.first.y_points.size * 4.0), 5.0)
212
+ circle_radius = @dot_radius || clip_value_if_greater_than(@columns / (store.norm_data.first.y_points.size * 2.5), 5.0)
213
213
 
214
- one_point = contains_one_point_only?(data_row)
214
+ store.norm_data.each do |data_row|
215
+ poly_points_group = [[]]
215
216
 
216
217
  data_row.coordinates.each_with_index do |(x_data, y_data), index|
218
+ poly_points = poly_points_group.last
219
+
217
220
  new_x = begin
218
221
  if x_data.nil?
219
222
  # use the old method: equally spaced points along the x-axis
@@ -224,28 +227,27 @@ private
224
227
  end
225
228
  draw_label_for_x_data(x_data, new_x, index)
226
229
 
227
- unless y_data # we can't draw a line for a null data point, we can still label the axis though
228
- prev_x = prev_y = nil
230
+ unless y_data
231
+ # we can't draw a line for a null data point, we can still label the axis though.
232
+ # Split the polygonal line into separate groups of points for polyline.
233
+ poly_points_group << []
229
234
  next
230
235
  end
231
236
 
232
237
  new_y = @graph_top + (@graph_height - (y_data * @graph_height))
233
238
 
234
- # Reset each time to avoid thin-line errors
235
- stroke_width = @line_width || clip_value_if_greater_than(@columns / (store.norm_data.first.y_points.size * 4), 5.0)
236
- circle_radius = @dot_radius || clip_value_if_greater_than(@columns / (store.norm_data.first.y_points.size * 2.5), 5.0)
239
+ poly_points << new_x
240
+ poly_points << new_y
237
241
 
238
- if !@hide_lines && prev_x && prev_y
239
- Gruff::Renderer::Line.new(renderer, color: data_row.color, width: stroke_width)
240
- .render(prev_x, prev_y, new_x, new_y)
241
- end
242
-
243
- if one_point || !@hide_dots
242
+ if contains_one_point_only?(data_row) || !@hide_dots
244
243
  Gruff::Renderer::Dot.new(renderer, @dot_style, color: data_row.color, width: stroke_width).render(new_x, new_y, circle_radius)
245
244
  end
245
+ end
246
246
 
247
- prev_x = new_x
248
- prev_y = new_y
247
+ unless @hide_lines
248
+ poly_points_group.each do |poly_points|
249
+ Gruff::Renderer::Polyline.new(renderer, color: data_row.color, width: stroke_width).render(poly_points) unless poly_points.empty?
250
+ end
249
251
  end
250
252
  end
251
253
  end
@@ -28,7 +28,7 @@ module Gruff
28
28
  @hide_line_numbers = true
29
29
 
30
30
  @marker_font.size = 50.0
31
- @legend_font.size = 60.0
31
+ @legend_font.size = 50.0
32
32
 
33
33
  @minimum_value = 0.0
34
34
  end
@@ -26,8 +26,8 @@ module Gruff
26
26
  @hide_title = true
27
27
  @hide_line_numbers = true
28
28
 
29
- @marker_font.size = 60.0
30
- @legend_font.size = 60.0
29
+ @marker_font.size = 50.0
30
+ @legend_font.size = 50.0
31
31
  end
32
32
 
33
33
  def setup_data
data/lib/gruff/net.rb CHANGED
@@ -60,6 +60,8 @@ private
60
60
 
61
61
  def draw_graph
62
62
  store.norm_data.each do |data_row|
63
+ poly_points = []
64
+
63
65
  data_row.points.each_with_index do |data_point, index|
64
66
  next if data_point.nil?
65
67
 
@@ -67,6 +69,10 @@ private
67
69
  point_distance = data_point * @radius
68
70
  start_x = @center_x + (Math.sin(rad_pos) * point_distance)
69
71
  start_y = @center_y - (Math.cos(rad_pos) * point_distance)
72
+ if poly_points.empty?
73
+ poly_points << start_x
74
+ poly_points << start_y
75
+ end
70
76
 
71
77
  next_index = index + 1 < data_row.points.length ? index + 1 : 0
72
78
 
@@ -74,14 +80,16 @@ private
74
80
  next_point_distance = data_row.points[next_index] * @radius
75
81
  end_x = @center_x + (Math.sin(next_rad_pos) * next_point_distance)
76
82
  end_y = @center_y - (Math.cos(next_rad_pos) * next_point_distance)
77
-
78
- Gruff::Renderer::Line.new(renderer, color: data_row.color, width: @stroke_width).render(start_x, start_y, end_x, end_y)
83
+ poly_points << end_x
84
+ poly_points << end_y
79
85
 
80
86
  unless @hide_dots
81
87
  circle_renderer = Gruff::Renderer::Circle.new(renderer, color: data_row.color, width: @stroke_width)
82
88
  circle_renderer.render(start_x, start_y, start_x - @circle_radius, start_y)
83
89
  end
84
90
  end
91
+
92
+ Gruff::Renderer::Polyline.new(renderer, color: data_row.color, width: @stroke_width).render(poly_points) unless poly_points.empty?
85
93
  end
86
94
  end
87
95
 
@@ -11,8 +11,8 @@ module Gruff
11
11
 
12
12
  def render(points)
13
13
  @renderer.draw.push
14
- @renderer.draw.stroke(@color)
15
14
  @renderer.draw.stroke_width(@width)
15
+ @renderer.draw.stroke(@color)
16
16
  @renderer.draw.fill_opacity(0.0)
17
17
  @renderer.draw.bezier(*points)
18
18
  @renderer.draw.pop
@@ -12,10 +12,10 @@ module Gruff
12
12
 
13
13
  def render(origin_x, origin_y, perim_x, perim_y)
14
14
  @renderer.draw.push
15
- @renderer.draw.fill(@color)
16
- @renderer.draw.fill_opacity(@opacity)
17
- @renderer.draw.stroke(@color)
18
15
  @renderer.draw.stroke_width(@width)
16
+ @renderer.draw.stroke(@color)
17
+ @renderer.draw.fill_opacity(@opacity)
18
+ @renderer.draw.fill(@color)
19
19
  @renderer.draw.circle(origin_x, origin_y, perim_x, perim_y)
20
20
  @renderer.draw.pop
21
21
  end
@@ -13,9 +13,9 @@ module Gruff
13
13
  def render(start_x, start_y, end_x, end_y)
14
14
  @renderer.draw.push
15
15
  @renderer.draw.stroke_color(@color)
16
- @renderer.draw.fill_opacity(0.0)
17
16
  @renderer.draw.stroke_dasharray(*@dasharray)
18
17
  @renderer.draw.stroke_width(@width)
18
+ @renderer.draw.fill_opacity(0.0)
19
19
  @renderer.draw.line(start_x, start_y, end_x, end_y)
20
20
  @renderer.draw.pop
21
21
  end
@@ -15,8 +15,8 @@ module Gruff
15
15
  @renderer.draw.push
16
16
  @renderer.draw.stroke_width(@width)
17
17
  @renderer.draw.stroke(@color)
18
- @renderer.draw.fill(@color)
19
18
  @renderer.draw.fill_opacity(@opacity)
19
+ @renderer.draw.fill(@color)
20
20
  case @style.to_sym
21
21
  when :square
22
22
  square(new_x, new_y, radius)
@@ -30,9 +30,9 @@ module Gruff
30
30
  end
31
31
 
32
32
  @renderer.draw.push
33
+ @renderer.draw.stroke_width(@width) if @width
33
34
  @renderer.draw.stroke(color)
34
35
  @renderer.draw.fill(color)
35
- @renderer.draw.stroke_width(@width) if @width
36
36
  @renderer.draw.line(start_x, start_y, end_x, end_y)
37
37
  @renderer.draw.pop
38
38
  end
@@ -14,8 +14,8 @@ module Gruff
14
14
  @renderer.draw.push
15
15
  @renderer.draw.stroke_width(@width)
16
16
  @renderer.draw.stroke(@color)
17
- @renderer.draw.fill(@color)
18
17
  @renderer.draw.fill_opacity(@opacity)
18
+ @renderer.draw.fill(@color)
19
19
  @renderer.draw.polygon(*points)
20
20
  @renderer.draw.pop
21
21
  end
@@ -3,17 +3,19 @@
3
3
  module Gruff
4
4
  # @private
5
5
  class Renderer::Polyline
6
- def initialize(renderer, color:, width:)
6
+ def initialize(renderer, color:, width: 1.0, linejoin: 'bevel')
7
7
  @renderer = renderer
8
8
  @color = color
9
9
  @width = width
10
+ @linejoin = linejoin
10
11
  end
11
12
 
12
13
  def render(points)
13
14
  @renderer.draw.push
15
+ @renderer.draw.stroke_linejoin(@linejoin)
16
+ @renderer.draw.stroke_width(@width)
14
17
  @renderer.draw.stroke(@color)
15
18
  @renderer.draw.fill('transparent')
16
- @renderer.draw.stroke_width(@width)
17
19
  @renderer.draw.polyline(*points)
18
20
  @renderer.draw.pop
19
21
  end
data/lib/gruff/scatter.rb CHANGED
@@ -142,6 +142,9 @@ private
142
142
  end
143
143
 
144
144
  def draw_graph
145
+ stroke_width = @stroke_width || clip_value_if_greater_than(@columns / (store.norm_data.first[1].size * 4.0), 5.0)
146
+ circle_radius = @circle_radius || clip_value_if_greater_than(@columns / (store.norm_data.first[1].size * 2.5), 5.0)
147
+
145
148
  store.norm_data.each do |data_row|
146
149
  data_row.coordinates.each do |x_value, y_value|
147
150
  next if y_value.nil? || x_value.nil?
@@ -149,9 +152,6 @@ private
149
152
  new_x = @graph_left + (x_value * @graph_width)
150
153
  new_y = @graph_bottom - (y_value * @graph_height)
151
154
 
152
- # Reset each time to avoid thin-line errors
153
- stroke_width = @stroke_width || clip_value_if_greater_than(@columns / (store.norm_data.first[1].size * 4.0), 5.0)
154
- circle_radius = @circle_radius || clip_value_if_greater_than(@columns / (store.norm_data.first[1].size * 2.5), 5.0)
155
155
  Gruff::Renderer::Circle.new(renderer, color: data_row.color, width: stroke_width).render(new_x, new_y, new_x - circle_radius, new_y)
156
156
  end
157
157
  end
@@ -78,7 +78,7 @@ private
78
78
  #
79
79
  # Columns sit stacked.
80
80
  bar_width = @graph_width / column_count
81
- padding = (bar_width * (1 - @bar_spacing)) / 2
81
+ padding = (bar_width * (1 - @bar_spacing)) / 2.0
82
82
 
83
83
  # Setup the BarConversion Object
84
84
  conversion = Gruff::BarConversion.new(
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.18.0'
4
+ VERSION = '0.19.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.18.0
4
+ version: 0.19.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: 2022-06-26 00:00:00.000000000 Z
12
+ date: 2022-08-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rmagick
@@ -144,6 +144,7 @@ executables: []
144
144
  extensions: []
145
145
  extra_rdoc_files: []
146
146
  files:
147
+ - ".devcontainer/devcontainer.json"
147
148
  - ".editorconfig"
148
149
  - ".github/ISSUE_TEMPLATE.md"
149
150
  - ".github/workflows/ci.yml"