gruff 0.16.0 → 0.17.0
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 +5 -2
- data/.gitignore +1 -0
- data/.rubocop.yml +0 -6
- data/CHANGELOG.md +19 -0
- data/gruff.gemspec +2 -3
- data/lib/gruff/area.rb +2 -0
- data/lib/gruff/bar.rb +26 -23
- data/lib/gruff/base.rb +198 -81
- data/lib/gruff/bezier.rb +2 -0
- data/lib/gruff/box_plot.rb +7 -1
- data/lib/gruff/candlestick.rb +21 -13
- data/lib/gruff/dot.rb +4 -5
- data/lib/gruff/helper/bar_conversion.rb +1 -5
- data/lib/gruff/helper/bar_mixin.rb +25 -0
- data/lib/gruff/helper/bar_value_label.rb +0 -22
- data/lib/gruff/helper/stacked_mixin.rb +16 -0
- data/lib/gruff/histogram.rb +8 -4
- data/lib/gruff/line.rb +2 -5
- data/lib/gruff/mini/legend.rb +9 -9
- data/lib/gruff/net.rb +16 -11
- data/lib/gruff/pie.rb +6 -1
- data/lib/gruff/renderer/dot.rb +25 -14
- data/lib/gruff/renderer/renderer.rb +0 -4
- data/lib/gruff/renderer/text.rb +7 -1
- data/lib/gruff/scatter.rb +20 -18
- data/lib/gruff/side_bar.rb +28 -23
- data/lib/gruff/side_stacked_bar.rb +36 -41
- data/lib/gruff/spider.rb +7 -2
- data/lib/gruff/stacked_area.rb +7 -2
- data/lib/gruff/stacked_bar.rb +46 -38
- data/lib/gruff/version.rb +1 -1
- data/lib/gruff.rb +0 -3
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f16153da348397448dc35f4d6435860b53040b14b0a7cbc3ca84bcaf9dd68b90
|
4
|
+
data.tar.gz: 68efd965f5b00403281ff46cc377fae9503b3b4290f49b66e6ceb424d24b4d27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2436acee944766653a6497854eb89493fc67f940d846e7299bdf92e2a31c8f7e267f508dad3b8593d596d31a277702983a58b7a2282b00395c33c152c657407
|
7
|
+
data.tar.gz: 7d75accebb94e9ae9362ae487265de84b7bbd6b6b90087c3ce5bd0f0e573d51d270f74bd04f3451d64aedba189fc09d5ef69b3a8c14785cb1b7d2c24b8581cc5
|
data/.github/workflows/ci.yml
CHANGED
@@ -6,6 +6,9 @@ on:
|
|
6
6
|
pull_request:
|
7
7
|
branches: [ master ]
|
8
8
|
|
9
|
+
permissions:
|
10
|
+
contents: read
|
11
|
+
|
9
12
|
jobs:
|
10
13
|
lint:
|
11
14
|
runs-on: ubuntu-20.04
|
@@ -23,7 +26,7 @@ jobs:
|
|
23
26
|
- name: Install dependencies
|
24
27
|
run: bundle install --path=vendor/bundle --jobs 4 --retry 3
|
25
28
|
- name: RuboCop Problem Matchers
|
26
|
-
uses: r7kamura/rubocop-problem-matchers-action@v1
|
29
|
+
uses: r7kamura/rubocop-problem-matchers-action@v1
|
27
30
|
- name: Run tests
|
28
31
|
run: bundle exec rubocop
|
29
32
|
|
@@ -34,7 +37,7 @@ jobs:
|
|
34
37
|
matrix:
|
35
38
|
ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1']
|
36
39
|
imagemagick-version:
|
37
|
-
- { full: 7.1.0-
|
40
|
+
- { full: 7.1.0-35, major-minor: '7.0' }
|
38
41
|
name: Ruby ${{ matrix.ruby-version }}
|
39
42
|
steps:
|
40
43
|
- uses: actions/checkout@v3
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -48,9 +48,6 @@ Lint/FloatComparison:
|
|
48
48
|
Lint/NumberConversion:
|
49
49
|
Enabled: false
|
50
50
|
|
51
|
-
Naming/MemoizedInstanceVariableName:
|
52
|
-
Enabled: false
|
53
|
-
|
54
51
|
Naming/MethodParameterName:
|
55
52
|
Enabled: false
|
56
53
|
|
@@ -122,6 +119,3 @@ Style/StructInheritance:
|
|
122
119
|
|
123
120
|
Performance/ChainArrayAllocation:
|
124
121
|
Enabled: false
|
125
|
-
|
126
|
-
Performance/StringReplacement:
|
127
|
-
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.17.0
|
4
|
+
- Add Gruff::Base#label_rotation= method to rotate bottom label (#599)
|
5
|
+
- Mark #label_stagger_height= as deprecated (#598)
|
6
|
+
- Fixed truncation of long legends in mini graph (#597)
|
7
|
+
- Fix error when input empty data in Gruff::Bezier (#596)
|
8
|
+
- Fix error when input empty data in Gruff::StackedArea (#595)
|
9
|
+
- Fix error when input empty data in Gruff::BoxPlot (#594)
|
10
|
+
- Fix error when input empty data in Gruff::Spider (#593)
|
11
|
+
- Fix error when input empty data in Gruff::Histogram (#592)
|
12
|
+
- Fix error when input empty data in Gruff::Area (#591)
|
13
|
+
- Stop adjusting the square radius in Gruff::Line (#589)
|
14
|
+
- Add diamond dot stype in Gruff::Line (#588)
|
15
|
+
- Allow title to be set as an array (#587)
|
16
|
+
- Allow labels to be set as an array corresponding to the data values (#586)
|
17
|
+
- Fixed a bug that breaks the colors in the theme when using the add_color method (#583)
|
18
|
+
- Ensure to raise an exception if use sort feature in Candlestick
|
19
|
+
- Fix column_count in BoxPlot/Candlestick (#581)
|
20
|
+
- Fix left/right graph margin (#579)
|
21
|
+
|
3
22
|
## 0.16.0
|
4
23
|
- Add Candlestick (#575)
|
5
24
|
- Add BoxPlot (#574)
|
data/gruff.gemspec
CHANGED
@@ -16,7 +16,6 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.require_paths = %w[lib]
|
17
17
|
s.summary = 'Beautiful graphs for one or multiple datasets.'
|
18
18
|
s.license = 'MIT'
|
19
|
-
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
20
19
|
s.executables = s.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
21
20
|
s.specification_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
22
21
|
|
@@ -25,7 +24,7 @@ Gem::Specification.new do |s|
|
|
25
24
|
s.add_dependency 'rmagick4j'
|
26
25
|
else
|
27
26
|
s.add_dependency 'rmagick', '>= 4.2'
|
28
|
-
s.add_development_dependency 'rubocop', '~> 1.
|
27
|
+
s.add_development_dependency 'rubocop', '~> 1.28.2'
|
29
28
|
s.add_development_dependency 'rubocop-performance', '~> 1.13.3'
|
30
29
|
s.add_development_dependency 'rubocop-rake', '~> 0.6.0'
|
31
30
|
end
|
@@ -35,7 +34,7 @@ Gem::Specification.new do |s|
|
|
35
34
|
s.add_development_dependency 'rake'
|
36
35
|
s.add_development_dependency 'minitest-reporters'
|
37
36
|
s.add_development_dependency 'simplecov'
|
38
|
-
s.add_development_dependency 'yard', '~> 0.9.
|
37
|
+
s.add_development_dependency 'yard', '~> 0.9.28'
|
39
38
|
|
40
39
|
s.metadata['rubygems_mfa_required'] = 'true'
|
41
40
|
end
|
data/lib/gruff/area.rb
CHANGED
data/lib/gruff/bar.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'helper/bar_mixin'
|
4
|
+
|
3
5
|
#
|
4
6
|
# Gruff::Bar provide a bar graph that presents categorical data
|
5
7
|
# with rectangular bars.
|
@@ -16,6 +18,8 @@
|
|
16
18
|
# g.write('bar.png')
|
17
19
|
#
|
18
20
|
class Gruff::Bar < Gruff::Base
|
21
|
+
include BarMixin
|
22
|
+
|
19
23
|
# Spacing factor applied between bars.
|
20
24
|
attr_writer :bar_spacing
|
21
25
|
|
@@ -86,8 +90,6 @@ private
|
|
86
90
|
return if @hide_line_markers
|
87
91
|
|
88
92
|
if @show_labels_for_bar_values
|
89
|
-
proc_text_metrics = ->(text) { text_metrics(@marker_font, text) }
|
90
|
-
|
91
93
|
if maximum_value >= 0
|
92
94
|
_, metrics = Gruff::BarValueLabel.metrics(maximum_value, @label_formatting, proc_text_metrics)
|
93
95
|
@graph_top += metrics.height
|
@@ -112,36 +114,33 @@ private
|
|
112
114
|
minimum_value: minimum_value, maximum_value: maximum_value, spread: @spread
|
113
115
|
)
|
114
116
|
|
115
|
-
|
117
|
+
group_spacing = @group_spacing * @scale
|
118
|
+
group_left_x = @graph_left
|
116
119
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
# Use incremented x and scaled y
|
123
|
-
# x
|
124
|
-
left_x = @graph_left + (bar_width * (row_index + point_index + ((store.length - 1) * point_index))) + padding + group_spacing
|
120
|
+
normalized_group_bars.each_with_index do |group_bars, group_index|
|
121
|
+
right_x = 0
|
122
|
+
group_bars.each_with_index do |bar, index|
|
123
|
+
left_x = group_left_x + (bar_width * index) + padding
|
125
124
|
right_x = left_x + (bar_width * @bar_spacing)
|
126
|
-
# y
|
127
|
-
left_y, right_y = conversion.get_top_bottom_scaled(data_point)
|
128
|
-
|
129
|
-
# create new bar
|
130
|
-
rect_renderer = Gruff::Renderer::Rectangle.new(renderer, color: data_row.color)
|
131
|
-
rect_renderer.render(left_x, left_y - AXIS_MARGIN, right_x, right_y - AXIS_MARGIN)
|
132
125
|
|
133
|
-
|
134
|
-
|
126
|
+
top_y, bottom_y = conversion.get_top_bottom_scaled(bar.point)
|
127
|
+
if bar.point != 0
|
128
|
+
rect_renderer = Gruff::Renderer::Rectangle.new(renderer, color: bar.color)
|
129
|
+
rect_renderer.render(left_x, bottom_y - AXIS_MARGIN, right_x, top_y)
|
130
|
+
end
|
135
131
|
|
136
|
-
|
137
|
-
|
138
|
-
if @show_labels_for_bar_values
|
139
|
-
bar_value_label = Gruff::BarValueLabel::Bar.new([left_x, left_y, right_x, right_y], store.data[row_index].points[point_index])
|
132
|
+
if @show_labels_for_bar_values && bar.value
|
133
|
+
bar_value_label = Gruff::BarValueLabel::Bar.new([left_x, top_y, right_x, bottom_y], bar.value)
|
140
134
|
bar_value_label.prepare_rendering(@label_formatting, proc_text_metrics) do |x, y, text, _text_width, text_height|
|
141
135
|
draw_value_label(bar_width * @bar_spacing, text_height, x, y, text)
|
142
136
|
end
|
143
137
|
end
|
144
138
|
end
|
139
|
+
|
140
|
+
label_center = group_left_x + ((right_x - group_left_x) / 2.0)
|
141
|
+
draw_label(label_center, group_index)
|
142
|
+
|
143
|
+
group_left_x = right_x + padding + group_spacing
|
145
144
|
end
|
146
145
|
|
147
146
|
# Draw the last label if requested
|
@@ -151,4 +150,8 @@ private
|
|
151
150
|
def calculate_spacing
|
152
151
|
@scale * @group_spacing * (column_count - 1)
|
153
152
|
end
|
153
|
+
|
154
|
+
def proc_text_metrics
|
155
|
+
->(text) { text_metrics(@marker_font, text) }
|
156
|
+
end
|
154
157
|
end
|