gruff 0.15.0 → 0.16.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 +17 -4
- data/.rubocop.yml +0 -6
- data/CHANGELOG.md +26 -0
- data/README.md +10 -3
- data/gruff.gemspec +1 -1
- data/lib/gruff/accumulator_bar.rb +1 -1
- data/lib/gruff/area.rb +4 -4
- data/lib/gruff/bar.rb +28 -9
- data/lib/gruff/base.rb +109 -118
- data/lib/gruff/bezier.rb +2 -2
- data/lib/gruff/box_plot.rb +174 -0
- data/lib/gruff/bullet.rb +5 -5
- data/lib/gruff/candlestick.rb +112 -0
- data/lib/gruff/dot.rb +10 -10
- data/lib/gruff/font.rb +3 -0
- data/lib/gruff/helper/bar_conversion.rb +5 -5
- data/lib/gruff/helper/bar_value_label.rb +27 -24
- data/lib/gruff/helper/stacked_mixin.rb +3 -1
- data/lib/gruff/histogram.rb +1 -1
- data/lib/gruff/line.rb +48 -42
- data/lib/gruff/mini/legend.rb +4 -4
- data/lib/gruff/net.rb +7 -7
- data/lib/gruff/patch/string.rb +1 -0
- data/lib/gruff/pie.rb +20 -11
- data/lib/gruff/renderer/dash_line.rb +3 -2
- data/lib/gruff/renderer/dot.rb +3 -1
- data/lib/gruff/renderer/line.rb +1 -3
- data/lib/gruff/renderer/rectangle.rb +6 -2
- data/lib/gruff/scatter.rb +52 -46
- data/lib/gruff/side_bar.rb +43 -14
- data/lib/gruff/side_stacked_bar.rb +20 -27
- data/lib/gruff/spider.rb +46 -13
- data/lib/gruff/stacked_area.rb +11 -6
- data/lib/gruff/stacked_bar.rb +36 -14
- data/lib/gruff/version.rb +1 -1
- data/lib/gruff.rb +9 -9
- metadata +4 -4
- data/lib/gruff/scene.rb +0 -208
- data/lib/gruff/store/custom_data.rb +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53adc2df58a382381368665252e0e5862ea81ebd4d513e051058aa5369d379a9
|
4
|
+
data.tar.gz: a63a2c06b2f2f936a8ee663463248faab871cab07ba0b58c84febff858b3c08b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa57dd19908889380ac8ca2ad4cf3d71da6349370ad90e6c318a01aa79fafd1db9c09f5118a4c1034aaad026596d5b42e4a5837e69ea360909c2b16e054c9fa3
|
7
|
+
data.tar.gz: 2334380acbf92ebbcfc2c090912e79955c5d28f6de4fb714f2d30de4a4b2b922fd661068641a4057ba94bba90359bd1a45fd0902da941e246df93bf80e9a0601
|
data/.github/workflows/ci.yml
CHANGED
@@ -8,7 +8,7 @@ on:
|
|
8
8
|
|
9
9
|
jobs:
|
10
10
|
lint:
|
11
|
-
runs-on: ubuntu-
|
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-
|
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:
|
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-
|
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.
|
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)
|
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
|
-
|
81
|
-
|
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)
|
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,
|
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
|