gruff 0.16.0-java → 0.19.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.devcontainer/devcontainer.json +26 -0
- data/.github/workflows/ci.yml +9 -6
- data/.gitignore +1 -0
- data/.rubocop.yml +0 -6
- data/CHANGELOG.md +32 -0
- data/README.md +7 -3
- data/gruff.gemspec +2 -4
- data/lib/gruff/area.rb +3 -1
- data/lib/gruff/bar.rb +26 -24
- data/lib/gruff/base.rb +214 -93
- data/lib/gruff/bezier.rb +7 -8
- data/lib/gruff/{box_plot.rb → box.rb} +12 -6
- data/lib/gruff/bubble.rb +99 -0
- data/lib/gruff/candlestick.rb +22 -14
- data/lib/gruff/dot.rb +5 -6
- 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 -5
- data/lib/gruff/line.rb +47 -27
- data/lib/gruff/mini/bar.rb +1 -1
- data/lib/gruff/mini/legend.rb +13 -9
- data/lib/gruff/mini/pie.rb +2 -2
- data/lib/gruff/net.rb +26 -13
- data/lib/gruff/pie.rb +7 -2
- data/lib/gruff/renderer/bezier.rb +1 -1
- data/lib/gruff/renderer/circle.rb +5 -3
- data/lib/gruff/renderer/dash_line.rb +1 -1
- data/lib/gruff/renderer/dot.rb +26 -15
- data/lib/gruff/renderer/line.rb +1 -1
- data/lib/gruff/renderer/polygon.rb +1 -1
- data/lib/gruff/renderer/polyline.rb +4 -2
- data/lib/gruff/renderer/renderer.rb +0 -4
- data/lib/gruff/renderer/text.rb +7 -1
- data/lib/gruff/scatter.rb +52 -55
- data/lib/gruff/side_bar.rb +28 -24
- data/lib/gruff/side_stacked_bar.rb +36 -41
- data/lib/gruff/spider.rb +7 -2
- data/lib/gruff/stacked_area.rb +8 -3
- data/lib/gruff/stacked_bar.rb +48 -40
- data/lib/gruff/store/xy_data.rb +8 -9
- data/lib/gruff/store/xy_pointsizes_data.rb +60 -0
- data/lib/gruff/version.rb +1 -1
- data/lib/gruff.rb +3 -4
- metadata +9 -5
data/lib/gruff/stacked_bar.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'helper/stacked_mixin'
|
4
|
+
|
3
5
|
#
|
4
6
|
# Here's how to set up a Gruff::StackedBar.
|
5
7
|
#
|
@@ -42,6 +44,15 @@ private
|
|
42
44
|
@minimum_value = 0.0
|
43
45
|
end
|
44
46
|
|
47
|
+
def setup_drawing
|
48
|
+
# Labels will be centered over the left of the bar if
|
49
|
+
# there are more labels than columns. This is basically the same
|
50
|
+
# as where it would be for a line graph.
|
51
|
+
@center_labels_over_point = (@labels.keys.length > column_count)
|
52
|
+
|
53
|
+
super
|
54
|
+
end
|
55
|
+
|
45
56
|
def setup_data
|
46
57
|
calculate_maximum_by_stack
|
47
58
|
super
|
@@ -52,8 +63,6 @@ private
|
|
52
63
|
return if @hide_line_markers
|
53
64
|
|
54
65
|
if @show_labels_for_bar_values
|
55
|
-
proc_text_metrics = ->(text) { text_metrics(@marker_font, text) }
|
56
|
-
|
57
66
|
if maximum_value >= 0
|
58
67
|
_, metrics = Gruff::BarValueLabel.metrics(maximum_value, @label_formatting, proc_text_metrics)
|
59
68
|
@graph_top += metrics.height
|
@@ -69,46 +78,41 @@ private
|
|
69
78
|
#
|
70
79
|
# Columns sit stacked.
|
71
80
|
bar_width = @graph_width / column_count
|
72
|
-
padding = (bar_width * (1 - @bar_spacing)) / 2
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
rect_renderer.render(left_x, left_y, right_x, right_y)
|
98
|
-
|
99
|
-
# Calculate center based on bar_width and current row
|
100
|
-
label_center = left_x + (bar_width * @bar_spacing / 2.0)
|
101
|
-
draw_label(label_center, point_index)
|
102
|
-
|
103
|
-
bar_value_label = Gruff::BarValueLabel::Bar.new([left_x, left_y, right_x, right_y], store.data[row_index].points[point_index])
|
104
|
-
stack_bar_value_labels.add(bar_value_label, point_index)
|
81
|
+
padding = (bar_width * (1 - @bar_spacing)) / 2.0
|
82
|
+
|
83
|
+
# Setup the BarConversion Object
|
84
|
+
conversion = Gruff::BarConversion.new(
|
85
|
+
top: @graph_top, bottom: @graph_bottom,
|
86
|
+
minimum_value: minimum_value, maximum_value: maximum_value, spread: @spread
|
87
|
+
)
|
88
|
+
|
89
|
+
normalized_stacked_bars.each_with_index do |stacked_bars, stacked_index|
|
90
|
+
total = 0
|
91
|
+
left_x = @graph_left + (bar_width * stacked_index) + padding
|
92
|
+
right_x = left_x + (bar_width * @bar_spacing)
|
93
|
+
|
94
|
+
top_y = 0
|
95
|
+
stacked_bars.each do |bar|
|
96
|
+
next if bar.point == 0
|
97
|
+
|
98
|
+
bottom_y, = conversion.get_top_bottom_scaled(total)
|
99
|
+
bottom_y -= @segment_spacing
|
100
|
+
top_y, = conversion.get_top_bottom_scaled(total + bar.point)
|
101
|
+
|
102
|
+
rect_renderer = Gruff::Renderer::Rectangle.new(renderer, color: bar.color)
|
103
|
+
rect_renderer.render(left_x, bottom_y, right_x, top_y)
|
104
|
+
|
105
|
+
total += bar.point
|
105
106
|
end
|
106
|
-
end
|
107
107
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
108
|
+
label_center = left_x + (bar_width * @bar_spacing / 2.0)
|
109
|
+
draw_label(label_center, stacked_index)
|
110
|
+
|
111
|
+
if @show_labels_for_bar_values
|
112
|
+
bar_value_label = Gruff::BarValueLabel::Bar.new([left_x, top_y, right_x, @graph_bottom], stacked_bars.sum(&:value))
|
113
|
+
bar_value_label.prepare_rendering(@label_formatting, proc_text_metrics) do |x, y, text, _text_width, text_height|
|
114
|
+
draw_value_label(bar_width * @bar_spacing, text_height, x, y, text)
|
115
|
+
end
|
112
116
|
end
|
113
117
|
end
|
114
118
|
end
|
@@ -124,4 +128,8 @@ private
|
|
124
128
|
def hide_bottom_label_area?
|
125
129
|
hide_labels? && @x_axis_label.nil? && @legend_at_bottom == false
|
126
130
|
end
|
131
|
+
|
132
|
+
def proc_text_metrics
|
133
|
+
->(text) { text_metrics(@marker_font, text) }
|
134
|
+
end
|
127
135
|
end
|
data/lib/gruff/store/xy_data.rb
CHANGED
@@ -3,18 +3,17 @@
|
|
3
3
|
module Gruff
|
4
4
|
class Store
|
5
5
|
# @private
|
6
|
-
class XYData < Struct.new(:label, :
|
7
|
-
def initialize(label, y_points, color
|
8
|
-
|
9
|
-
|
6
|
+
class XYData < Struct.new(:label, :x_points, :y_points, :color)
|
7
|
+
def initialize(label, x_points, y_points, color)
|
8
|
+
y_points = Array(y_points)
|
9
|
+
x_points = x_points ? Array(x_points) : Array.new(y_points.length)
|
10
|
+
raise ArgumentError, 'x_points.length != y_points.length!' if x_points.length != y_points.length
|
11
|
+
|
12
|
+
super(label.to_s, x_points, y_points, color)
|
10
13
|
end
|
11
14
|
|
12
15
|
alias points y_points
|
13
16
|
|
14
|
-
def x_points
|
15
|
-
self[:x_points] || Array.new(y_points.length)
|
16
|
-
end
|
17
|
-
|
18
17
|
def coordinates
|
19
18
|
x_points.zip(y_points)
|
20
19
|
end
|
@@ -53,7 +52,7 @@ module Gruff
|
|
53
52
|
y.nil? ? nil : (y.to_f - minimum_y.to_f) / spread_y
|
54
53
|
end
|
55
54
|
|
56
|
-
self.class.new(label, norm_y_points, color
|
55
|
+
self.class.new(label, norm_x_points, norm_y_points, color)
|
57
56
|
end
|
58
57
|
end
|
59
58
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gruff
|
4
|
+
class Store
|
5
|
+
# @private
|
6
|
+
class XYPointsizeData < Struct.new(:label, :x_points, :y_points, :point_sizes, :color)
|
7
|
+
def initialize(label, x_points, y_points, point_sizes, color)
|
8
|
+
y_points = Array(y_points)
|
9
|
+
x_points = x_points ? Array(x_points) : Array.new(y_points.length)
|
10
|
+
raise ArgumentError, 'x_points.length != y_points.length!' if x_points.length != y_points.length
|
11
|
+
raise ArgumentError, 'x_points.length != point_sizes.length!' if x_points.length != point_sizes.length
|
12
|
+
|
13
|
+
super(label.to_s, x_points, y_points, point_sizes, color)
|
14
|
+
end
|
15
|
+
|
16
|
+
alias points y_points
|
17
|
+
|
18
|
+
def coordinate_and_pointsizes
|
19
|
+
x_points.zip(y_points, point_sizes)
|
20
|
+
end
|
21
|
+
|
22
|
+
def empty?
|
23
|
+
y_points.empty?
|
24
|
+
end
|
25
|
+
|
26
|
+
def columns
|
27
|
+
y_points.length
|
28
|
+
end
|
29
|
+
|
30
|
+
def min
|
31
|
+
y_points.compact.min
|
32
|
+
end
|
33
|
+
alias min_y min
|
34
|
+
|
35
|
+
def max
|
36
|
+
y_points.compact.max
|
37
|
+
end
|
38
|
+
alias max_y max
|
39
|
+
|
40
|
+
def min_x
|
41
|
+
x_points.compact.min
|
42
|
+
end
|
43
|
+
|
44
|
+
def max_x
|
45
|
+
x_points.compact.max
|
46
|
+
end
|
47
|
+
|
48
|
+
def normalize(minimum_x:, minimum_y:, spread_x:, spread_y:)
|
49
|
+
norm_x_points = x_points.map do |x|
|
50
|
+
x.nil? ? nil : (x.to_f - minimum_x.to_f) / spread_x
|
51
|
+
end
|
52
|
+
norm_y_points = y_points.map do |y|
|
53
|
+
y.nil? ? nil : (y.to_f - minimum_y.to_f) / spread_y
|
54
|
+
end
|
55
|
+
|
56
|
+
self.class.new(label, norm_x_points, norm_y_points, point_sizes, color)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/gruff/version.rb
CHANGED
data/lib/gruff.rb
CHANGED
@@ -21,15 +21,13 @@ module Gruff
|
|
21
21
|
|
22
22
|
autoload :BarConversion, Gruff.libpath('helper/bar_conversion')
|
23
23
|
autoload :BarValueLabel, Gruff.libpath('helper/bar_value_label')
|
24
|
-
class Base
|
25
|
-
autoload :StackedMixin, Gruff.libpath('helper/stacked_mixin')
|
26
|
-
end
|
27
24
|
|
28
25
|
autoload :AccumulatorBar, Gruff.libpath('accumulator_bar')
|
29
26
|
autoload :Area, Gruff.libpath('area')
|
30
27
|
autoload :Bar, Gruff.libpath('bar')
|
31
28
|
autoload :Bezier, Gruff.libpath('bezier')
|
32
|
-
autoload :
|
29
|
+
autoload :Box, Gruff.libpath('box')
|
30
|
+
autoload :Bubble, Gruff.libpath('bubble')
|
33
31
|
autoload :Bullet, Gruff.libpath('bullet')
|
34
32
|
autoload :Candlestick, Gruff.libpath('candlestick')
|
35
33
|
autoload :Dot, Gruff.libpath('dot')
|
@@ -63,6 +61,7 @@ module Gruff
|
|
63
61
|
class Store
|
64
62
|
autoload :BasicData, Gruff.libpath('store/basic_data')
|
65
63
|
autoload :XYData, Gruff.libpath('store/xy_data')
|
64
|
+
autoload :XYPointsizeData, Gruff.libpath('store/xy_pointsizes_data')
|
66
65
|
end
|
67
66
|
|
68
67
|
module Mini
|
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.
|
4
|
+
version: 0.19.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: 2022-
|
12
|
+
date: 2022-08-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,7 +86,7 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.9.
|
89
|
+
version: 0.9.28
|
90
90
|
name: yard
|
91
91
|
prerelease: false
|
92
92
|
type: :development
|
@@ -94,7 +94,7 @@ dependencies:
|
|
94
94
|
requirements:
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: 0.9.
|
97
|
+
version: 0.9.28
|
98
98
|
description: Beautiful graphs for one or multiple datasets. Can be used on websites
|
99
99
|
or in documents.
|
100
100
|
email: boss@topfunky.com
|
@@ -102,6 +102,7 @@ executables: []
|
|
102
102
|
extensions: []
|
103
103
|
extra_rdoc_files: []
|
104
104
|
files:
|
105
|
+
- ".devcontainer/devcontainer.json"
|
105
106
|
- ".editorconfig"
|
106
107
|
- ".github/ISSUE_TEMPLATE.md"
|
107
108
|
- ".github/workflows/ci.yml"
|
@@ -123,12 +124,14 @@ files:
|
|
123
124
|
- lib/gruff/bar.rb
|
124
125
|
- lib/gruff/base.rb
|
125
126
|
- lib/gruff/bezier.rb
|
126
|
-
- lib/gruff/
|
127
|
+
- lib/gruff/box.rb
|
128
|
+
- lib/gruff/bubble.rb
|
127
129
|
- lib/gruff/bullet.rb
|
128
130
|
- lib/gruff/candlestick.rb
|
129
131
|
- lib/gruff/dot.rb
|
130
132
|
- lib/gruff/font.rb
|
131
133
|
- lib/gruff/helper/bar_conversion.rb
|
134
|
+
- lib/gruff/helper/bar_mixin.rb
|
132
135
|
- lib/gruff/helper/bar_value_label.rb
|
133
136
|
- lib/gruff/helper/stacked_mixin.rb
|
134
137
|
- lib/gruff/histogram.rb
|
@@ -161,6 +164,7 @@ files:
|
|
161
164
|
- lib/gruff/store/basic_data.rb
|
162
165
|
- lib/gruff/store/store.rb
|
163
166
|
- lib/gruff/store/xy_data.rb
|
167
|
+
- lib/gruff/store/xy_pointsizes_data.rb
|
164
168
|
- lib/gruff/themes.rb
|
165
169
|
- lib/gruff/version.rb
|
166
170
|
- rails_generators/gruff/gruff_generator.rb
|