gruff 0.15.0-java → 0.16.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: e1c88e4164e9a9900a250668c3cfcaea50dbca718f1cb6f3a9a34e97829a88cc
4
- data.tar.gz: e3fe64fdaef26e276756c0101173ba8a61c8c628d9b5318ea78bbb01a8232958
3
+ metadata.gz: 03a1c8455536dad68e5d325a51416807d32595aee6e4be75ef214c1b00e0df06
4
+ data.tar.gz: fa90b50b714c8464f6b82260f3ec9598edb57cf4b03ffcb8b451083e9bd1a307
5
5
  SHA512:
6
- metadata.gz: cde5be79069863980f8235108c1b16457295ff0743615a85eb73246ead279de1de8742d832a3c48ececf430de61454edff0340fd4f57d2b5f3216aac4eac2cc1
7
- data.tar.gz: 62c09da6e860e0ae555a9d27dccae050e4cc817b3cf1be0918f5a303f824d7524b5bab1a6e40b69fb1c5b42f5ed72732b1aa9473cb3778574c2593b9248fabb5
6
+ metadata.gz: 180bb66623c99daf3b89febea4059ed0d1f655b5fdee1da046e78174d0ea2efdf26e3fbc1de8bc18765cf9ab5cbe8bc52cb22fd01deeb25c377210340506bcfb
7
+ data.tar.gz: 05e9d6c86ee5ccee8bafc37fe1843f041f2a91f82aa7bbfb77c11fd05c9d64b2192d4b56dfaff0bc3f5d5db925e13ba057179843e0265873d2e1c7659582235d
@@ -8,7 +8,7 @@ on:
8
8
 
9
9
  jobs:
10
10
  lint:
11
- runs-on: ubuntu-18.04
11
+ runs-on: ubuntu-20.04
12
12
  timeout-minutes: 20
13
13
  name: Lint
14
14
  steps:
@@ -28,26 +28,39 @@ jobs:
28
28
  run: bundle exec rubocop
29
29
 
30
30
  test-ruby:
31
- runs-on: ubuntu-18.04
31
+ runs-on: ubuntu-20.04
32
32
  timeout-minutes: 20
33
33
  strategy:
34
34
  matrix:
35
35
  ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1']
36
+ imagemagick-version:
37
+ - { full: 7.1.0-31, major-minor: '7.0' }
36
38
  name: Ruby ${{ matrix.ruby-version }}
37
39
  steps:
38
40
  - uses: actions/checkout@v3
41
+ - name: Cache ImageMagick
42
+ uses: actions/cache@v3
43
+ with:
44
+ path: ./build-ImageMagick
45
+ key: v1-linux-imagemagick-${{ matrix.imagemagick-version.full }}
46
+ restore-keys: |
47
+ v1-linux-imagemagick-${{ matrix.imagemagick-version.full }}
48
+ - name: Install ImageMagick ${{ matrix.imagemagick-version.full }}
49
+ run: |
50
+ export IMAGEMAGICK_VERSION=${{ matrix.imagemagick-version.full }}
51
+ ./before_install_linux.sh
39
52
  - name: Set up Ruby
40
53
  uses: ruby/setup-ruby@master
41
54
  with:
42
55
  ruby-version: ${{ matrix.ruby-version }}
43
- bundler-cache: true
56
+ bundler-cache: false
44
57
  - name: Install dependencies
45
58
  run: bundle install --path=vendor/bundle --jobs 4 --retry 3
46
59
  - name: Run tests
47
60
  run: bundle exec rake
48
61
 
49
62
  test-jruby:
50
- runs-on: ubuntu-18.04
63
+ runs-on: ubuntu-20.04
51
64
  timeout-minutes: 20
52
65
  strategy:
53
66
  matrix:
data/.rubocop.yml CHANGED
@@ -21,9 +21,6 @@ Gemspec/RequiredRubyVersion:
21
21
  Layout/AccessModifierIndentation:
22
22
  EnforcedStyle: outdent
23
23
 
24
- Layout/ClassStructure:
25
- Enabled: false
26
-
27
24
  Layout/FirstMethodArgumentLineBreak:
28
25
  Enabled: false
29
26
 
@@ -42,9 +39,6 @@ Layout/RedundantLineBreak:
42
39
  Layout/SingleLineBlockChain:
43
40
  Enabled: false
44
41
 
45
- Lint/AmbiguousOperatorPrecedence:
46
- Enabled: false
47
-
48
42
  Lint/ConstantResolution:
49
43
  Enabled: false
50
44
 
data/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.16.0
4
+ - Add Candlestick (#575)
5
+ - Add BoxPlot (#574)
6
+ - Raise exception if less data set was given in Gruff::Spider (#573)
7
+ - Adjust default label offset value in Gruff::Pie
8
+ - Remove has_left_labels from attribute (#571)
9
+ - Remove center_labels_over_point from attribute (#570)
10
+ - Adjust legend label / box position
11
+ - Fix right margin when truncate the label
12
+ - Adjust axis label position
13
+ - Adjust left label margin
14
+ - Fix axis label position with hide_line_markers
15
+ - Fix margin of value label in Bar/StackedBar (#568)
16
+ - Fix label position in Gruff::Spider (#567)
17
+ - Fix axis label position with legend_at_bottom
18
+ - Fix axis label position with hide_line_markers
19
+ - Refactor: Remove instance variable usage
20
+ - Remove Gruff::Scene (#566)
21
+ - Fix exception with zero value in StackBar (#565)
22
+ - Fix segment spacing in SideStackedBar (#564)
23
+ - Fix margin of value label in SideBar/SideStackedBar (#563)
24
+ - Raise exception if negative values were given in stacked graph (#562)
25
+ - Fix centering in value label position (#561)
26
+ - Fix duck typing support in Gruff::Histogram (#560)
27
+ - Fix start drawing position to top in Pie and enabled sort option by default (#559)
28
+
3
29
  ## 0.15.0
4
30
  - Fix SideStackedBar which bars overlap on the coordinate axes if data contains 0 (#558)
5
31
  - Lazy loading library to reduce memory usage (#556)
data/README.md CHANGED
@@ -126,6 +126,13 @@ In progress!
126
126
 
127
127
  ![Histogram chart](https://raw.github.com/topfunky/gruff/master/test/expected/histogram.png)
128
128
 
129
+ ### Box plot
130
+
131
+ ![Box plot](https://raw.github.com/topfunky/gruff/master/test/expected/box_plot.png)
132
+
133
+ ### Candlestick
134
+
135
+ ![Candlestick](https://raw.github.com/topfunky/gruff/master/test/expected/candlestick.png)
129
136
 
130
137
  ## Documentation
131
138
 
@@ -133,7 +140,7 @@ http://www.rubydoc.info/github/topfunky/gruff/frames
133
140
 
134
141
  ## Supported Ruby Versions
135
142
 
136
- - Ruby 2.4 or later
143
+ - Ruby 2.5 or later
137
144
  - JRuby 9.2.x or later
138
145
 
139
146
  ## Development
@@ -149,13 +156,13 @@ $ ./docker-launch.sh
149
156
 
150
157
  3. Run tests
151
158
  ```sh
152
- $ rake
159
+ $ bundle exec rake
153
160
  ```
154
161
 
155
162
  If you have made changes that involve updating the expected image, you need to update the image with the following command after running tests.
156
163
 
157
164
  ```sh
158
- $ rake test:image:update
165
+ $ bundle exec rake test:image:update
159
166
  ```
160
167
 
161
168
  ## Contributing
data/gruff.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.authors = ['Geoffrey Grosenbach', 'Uwe Kubosch']
12
12
  s.description = 'Beautiful graphs for one or multiple datasets. Can be used on websites or in documents.'
13
13
  s.email = 'boss@topfunky.com'
14
- s.files = `git ls-files`.split.grep_v(/^test|^docker|^Rakefile/i)
14
+ s.files = `git ls-files`.split.grep_v(/^test|^docker|^before_install_linux.sh|^Rakefile/i)
15
15
  s.homepage = 'https://github.com/topfunky/gruff'
16
16
  s.require_paths = %w[lib]
17
17
  s.summary = 'Beautiful graphs for one or multiple datasets.'
@@ -19,7 +19,7 @@ private
19
19
  def setup_data
20
20
  raise(Gruff::IncorrectNumberOfDatasetsException) unless store.length == 1
21
21
 
22
- accum_array = store.data.first.points[0..-2].reduce([0]) { |a, v| a << a.last + v }
22
+ accum_array = store.data.first.points[0..-2].reduce([0]) { |a, v| a << (a.last + v) }
23
23
  data 'Accumulator', accum_array
24
24
  set_colors
25
25
  store.reverse!
data/lib/gruff/area.rb CHANGED
@@ -30,7 +30,7 @@ private
30
30
  end
31
31
 
32
32
  def draw_graph
33
- x_increment = @graph_width / (column_count - 1).to_f
33
+ x_increment = @graph_width / (column_count - 1)
34
34
 
35
35
  store.norm_data.each do |data_row|
36
36
  poly_points = []
@@ -38,7 +38,7 @@ private
38
38
  data_row.points.each_with_index do |data_point, index|
39
39
  # Use incremented x and scaled y
40
40
  new_x = @graph_left + (x_increment * index)
41
- new_y = @graph_top + (@graph_height - data_point * @graph_height)
41
+ new_y = @graph_top + (@graph_height - (data_point * @graph_height))
42
42
 
43
43
  poly_points << new_x
44
44
  poly_points << new_y
@@ -48,9 +48,9 @@ private
48
48
 
49
49
  # Add closing points, draw polygon
50
50
  poly_points << @graph_right
51
- poly_points << @graph_bottom - 1
51
+ poly_points << (@graph_bottom - 1)
52
52
  poly_points << @graph_left
53
- poly_points << @graph_bottom - 1
53
+ poly_points << (@graph_bottom - 1)
54
54
 
55
55
  Gruff::Renderer::Polygon.new(renderer, color: data_row.color, width: @stroke_width, opacity: @fill_opacity).render(poly_points)
56
56
  end
data/lib/gruff/bar.rb CHANGED
@@ -33,6 +33,10 @@ class Gruff::Bar < Gruff::Base
33
33
  # Prevent drawing of column labels below a bar graph. Default is +false+.
34
34
  attr_writer :hide_labels
35
35
 
36
+ # Value to avoid completely overwriting the coordinate axis
37
+ AXIS_MARGIN = 0.5
38
+ private_constant :AXIS_MARGIN
39
+
36
40
  # Can be used to adjust the spaces between the bars.
37
41
  # Accepts values between 0.00 and 1.00 where 0.00 means no spacing at all
38
42
  # and 1 means that each bars' width is nearly 0 (so each bar is a simple
@@ -70,15 +74,28 @@ private
70
74
  end
71
75
 
72
76
  def hide_left_label_area?
73
- @hide_line_markers
77
+ @hide_line_markers && @y_axis_label.nil?
74
78
  end
75
79
 
76
80
  def hide_bottom_label_area?
77
- hide_labels?
81
+ hide_labels? && @x_axis_label.nil? && @legend_at_bottom == false
78
82
  end
79
83
 
80
- # Value to avoid completely overwriting the coordinate axis
81
- AXIS_MARGIN = 0.5
84
+ def setup_graph_measurements
85
+ super
86
+ return if @hide_line_markers
87
+
88
+ if @show_labels_for_bar_values
89
+ proc_text_metrics = ->(text) { text_metrics(@marker_font, text) }
90
+
91
+ if maximum_value >= 0
92
+ _, metrics = Gruff::BarValueLabel.metrics(maximum_value, @label_formatting, proc_text_metrics)
93
+ @graph_top += metrics.height
94
+ end
95
+
96
+ @graph_height = @graph_bottom - @graph_top
97
+ end
98
+ end
82
99
 
83
100
  def draw_graph
84
101
  # Setup spacing.
@@ -86,8 +103,8 @@ private
86
103
  # Columns sit side-by-side.
87
104
  @bar_spacing ||= @spacing_factor # space between the bars
88
105
 
89
- bar_width = (@graph_width - calculate_spacing) / (column_count * store.length).to_f
90
- padding = (bar_width * (1 - @bar_spacing)) / 2
106
+ bar_width = (@graph_width - calculate_spacing) / (column_count * store.length)
107
+ padding = (bar_width * (1 - @bar_spacing)) / 2.0
91
108
 
92
109
  # Setup the BarConversion Object
93
110
  conversion = Gruff::BarConversion.new(
@@ -95,6 +112,8 @@ private
95
112
  minimum_value: minimum_value, maximum_value: maximum_value, spread: @spread
96
113
  )
97
114
 
115
+ proc_text_metrics = ->(text) { text_metrics(@marker_font, text) }
116
+
98
117
  # iterate over all normalised data
99
118
  store.norm_data.each_with_index do |data_row, row_index|
100
119
  data_row.points.each_with_index do |data_point, point_index|
@@ -103,7 +122,7 @@ private
103
122
  # Use incremented x and scaled y
104
123
  # x
105
124
  left_x = @graph_left + (bar_width * (row_index + point_index + ((store.length - 1) * point_index))) + padding + group_spacing
106
- right_x = left_x + bar_width * @bar_spacing
125
+ right_x = left_x + (bar_width * @bar_spacing)
107
126
  # y
108
127
  left_y, right_y = conversion.get_top_bottom_scaled(data_point)
109
128
 
@@ -118,8 +137,8 @@ private
118
137
  draw_label(label_center, point_index)
119
138
  if @show_labels_for_bar_values
120
139
  bar_value_label = Gruff::BarValueLabel::Bar.new([left_x, left_y, right_x, right_y], store.data[row_index].points[point_index])
121
- bar_value_label.prepare_rendering(@label_formatting, bar_width) do |x, y, text|
122
- draw_value_label(x, y, text)
140
+ bar_value_label.prepare_rendering(@label_formatting, proc_text_metrics) do |x, y, text, _text_width, text_height|
141
+ draw_value_label(bar_width * @bar_spacing, text_height, x, y, text)
123
142
  end
124
143
  end
125
144
  end