gruff 0.8.0-java → 0.9.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE.md +18 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +93 -0
- data/.rubocop_todo.yml +23 -810
- data/.travis.yml +4 -4
- data/.yardopts +1 -0
- data/CHANGELOG.md +22 -0
- data/Gemfile +3 -1
- data/README.md +44 -21
- data/Rakefile +2 -206
- data/docker/Dockerfile +14 -0
- data/docker/build.sh +4 -0
- data/docker/launch.sh +4 -0
- data/gruff.gemspec +11 -8
- data/init.rb +2 -0
- data/lib/gruff.rb +23 -0
- data/lib/gruff/accumulator_bar.rb +6 -6
- data/lib/gruff/area.rb +13 -17
- data/lib/gruff/bar.rb +58 -41
- data/lib/gruff/base.rb +243 -566
- data/lib/gruff/bezier.rb +12 -14
- data/lib/gruff/bullet.rb +39 -57
- data/lib/gruff/dot.rb +25 -59
- data/lib/gruff/{bar_conversion.rb → helper/bar_conversion.rb} +13 -12
- data/lib/gruff/helper/bar_value_label_mixin.rb +30 -0
- data/lib/gruff/{stacked_mixin.rb → helper/stacked_mixin.rb} +7 -6
- data/lib/gruff/line.rb +95 -177
- data/lib/gruff/mini/bar.rb +6 -7
- data/lib/gruff/mini/legend.rb +16 -32
- data/lib/gruff/mini/pie.rb +6 -7
- data/lib/gruff/mini/side_bar.rb +4 -5
- data/lib/gruff/net.rb +37 -65
- data/lib/gruff/patch/rmagick.rb +33 -0
- data/lib/gruff/patch/string.rb +8 -0
- data/lib/gruff/photo_bar.rb +19 -19
- data/lib/gruff/pie.rb +22 -73
- data/lib/gruff/renderer/bezier.rb +21 -0
- data/lib/gruff/renderer/circle.rb +21 -0
- data/lib/gruff/renderer/dash_line.rb +22 -0
- data/lib/gruff/renderer/dot.rb +39 -0
- data/lib/gruff/renderer/ellipse.rb +21 -0
- data/lib/gruff/renderer/line.rb +34 -0
- data/lib/gruff/renderer/polygon.rb +23 -0
- data/lib/gruff/renderer/polyline.rb +21 -0
- data/lib/gruff/renderer/rectangle.rb +19 -0
- data/lib/gruff/renderer/renderer.rb +127 -0
- data/lib/gruff/renderer/text.rb +42 -0
- data/lib/gruff/scatter.rb +85 -156
- data/lib/gruff/scene.rb +22 -30
- data/lib/gruff/side_bar.rb +62 -58
- data/lib/gruff/side_stacked_bar.rb +47 -43
- data/lib/gruff/spider.rb +19 -36
- data/lib/gruff/stacked_area.rb +17 -21
- data/lib/gruff/stacked_bar.rb +50 -24
- data/lib/gruff/store/base_data.rb +34 -0
- data/lib/gruff/store/custom_data.rb +34 -0
- data/lib/gruff/store/store.rb +80 -0
- data/lib/gruff/store/xy_data.rb +55 -0
- data/lib/gruff/themes.rb +3 -3
- data/lib/gruff/version.rb +3 -1
- metadata +41 -30
- data/Manifest.txt +0 -81
- data/assets/bubble.png +0 -0
- data/assets/city_scene/background/0000.png +0 -0
- data/assets/city_scene/background/0600.png +0 -0
- data/assets/city_scene/background/2000.png +0 -0
- data/assets/city_scene/clouds/cloudy.png +0 -0
- data/assets/city_scene/clouds/partly_cloudy.png +0 -0
- data/assets/city_scene/clouds/stormy.png +0 -0
- data/assets/city_scene/grass/default.png +0 -0
- data/assets/city_scene/haze/true.png +0 -0
- data/assets/city_scene/number_sample/1.png +0 -0
- data/assets/city_scene/number_sample/2.png +0 -0
- data/assets/city_scene/number_sample/default.png +0 -0
- data/assets/city_scene/sky/0000.png +0 -0
- data/assets/city_scene/sky/0200.png +0 -0
- data/assets/city_scene/sky/0400.png +0 -0
- data/assets/city_scene/sky/0600.png +0 -0
- data/assets/city_scene/sky/0800.png +0 -0
- data/assets/city_scene/sky/1000.png +0 -0
- data/assets/city_scene/sky/1200.png +0 -0
- data/assets/city_scene/sky/1400.png +0 -0
- data/assets/city_scene/sky/1500.png +0 -0
- data/assets/city_scene/sky/1700.png +0 -0
- data/assets/city_scene/sky/2000.png +0 -0
- data/assets/pc306715.jpg +0 -0
- data/lib/gruff/deprecated.rb +0 -38
data/lib/gruff/side_bar.rb
CHANGED
@@ -1,45 +1,62 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
# Graph with individual horizontal bars instead of vertical bars.
|
3
|
+
require 'gruff/base'
|
5
4
|
|
5
|
+
# Graph with individual horizontal bars instead of vertical bars.
|
6
6
|
class Gruff::SideBar < Gruff::Base
|
7
|
-
|
8
|
-
# Spacing factor applied between bars
|
7
|
+
# Spacing factor applied between bars.
|
9
8
|
attr_accessor :bar_spacing
|
10
9
|
|
10
|
+
# Spacing factor applied between a group of bars belonging to the same label.
|
11
|
+
attr_accessor :group_spacing
|
12
|
+
|
13
|
+
# Set the number output format for labels using sprintf.
|
14
|
+
# Default is +"%.2f"+.
|
15
|
+
attr_accessor :label_formatting
|
16
|
+
|
17
|
+
# Output the values for the bars on a bar graph.
|
18
|
+
# Default is +false+.
|
19
|
+
attr_accessor :show_labels_for_bar_values
|
20
|
+
|
21
|
+
def initialize_ivars
|
22
|
+
super
|
23
|
+
@label_formatting = nil
|
24
|
+
@show_labels_for_bar_values = false
|
25
|
+
end
|
26
|
+
private :initialize_ivars
|
27
|
+
|
11
28
|
def draw
|
12
29
|
@has_left_labels = true
|
13
30
|
super
|
14
31
|
|
15
|
-
return unless
|
32
|
+
return unless data_given?
|
16
33
|
|
17
34
|
draw_bars
|
18
35
|
end
|
19
36
|
|
20
|
-
|
37
|
+
private
|
21
38
|
|
22
39
|
def draw_bars
|
23
40
|
# Setup spacing.
|
24
41
|
#
|
25
42
|
@bar_spacing ||= 0.9
|
43
|
+
@group_spacing ||= 10
|
26
44
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
padding = (@bar_width * (1 - @bar_spacing)) / 2
|
45
|
+
bars_width = (@graph_height - calculate_spacing) / column_count.to_f
|
46
|
+
bar_width = bars_width / store.length
|
47
|
+
height = Array.new(column_count, 0)
|
48
|
+
length = Array.new(column_count, @graph_left)
|
49
|
+
padding = (bar_width * (1 - @bar_spacing)) / 2
|
33
50
|
|
34
51
|
# if we're a side stacked bar then we don't need to draw ourself at all
|
35
52
|
# because sometimes (due to different heights/min/max) you can actually
|
36
53
|
# see both graphs and it looks like crap
|
37
|
-
return if
|
54
|
+
return if is_a?(Gruff::SideStackedBar)
|
38
55
|
|
39
|
-
|
40
|
-
|
56
|
+
store.norm_data.each_with_index do |data_row, row_index|
|
57
|
+
data_row.points.each_with_index do |data_point, point_index|
|
58
|
+
group_spacing = @group_spacing * @scale * point_index
|
41
59
|
|
42
|
-
data_row[DATA_VALUES_INDEX].each_with_index do |data_point, point_index|
|
43
60
|
# Using the original calcs from the stacked bar chart
|
44
61
|
# to get the difference between
|
45
62
|
# part of the bart chart we wish to stack.
|
@@ -48,67 +65,55 @@ protected
|
|
48
65
|
difference = temp2 - temp1
|
49
66
|
|
50
67
|
left_x = length[point_index] - 1
|
51
|
-
left_y = @graph_top + (
|
68
|
+
left_y = @graph_top + (bars_width * point_index) + (bar_width * row_index) + padding + group_spacing
|
52
69
|
right_x = left_x + difference
|
53
|
-
right_y = left_y +
|
70
|
+
right_y = left_y + bar_width * @bar_spacing
|
54
71
|
|
55
72
|
height[point_index] += (data_point * @graph_width)
|
56
73
|
|
57
|
-
|
74
|
+
rect_renderer = Gruff::Renderer::Rectangle.new(color: data_row.color)
|
75
|
+
rect_renderer.render(left_x, left_y, right_x, right_y)
|
58
76
|
|
59
77
|
# Calculate center based on bar_width and current row
|
60
78
|
|
61
79
|
if @use_data_label
|
62
|
-
label_center =
|
63
|
-
draw_label(label_center, row_index,
|
80
|
+
label_center = left_y + bar_width / 2
|
81
|
+
draw_label(label_center, row_index, store.norm_data[row_index].label)
|
64
82
|
else
|
65
|
-
label_center =
|
83
|
+
label_center = left_y + bars_width / 2
|
66
84
|
draw_label(label_center, point_index)
|
67
85
|
end
|
68
86
|
if @show_labels_for_bar_values
|
69
|
-
val = (@label_formatting || '%.2f') %
|
70
|
-
draw_value_label(right_x + 40,
|
87
|
+
val = (@label_formatting || '%.2f') % store.data[row_index].points[point_index]
|
88
|
+
draw_value_label(right_x + 40, right_y - bar_width / 2, val.commify, true)
|
71
89
|
end
|
72
90
|
end
|
73
91
|
end
|
74
92
|
|
75
|
-
|
93
|
+
Gruff::Renderer.finish
|
76
94
|
end
|
77
95
|
|
78
96
|
# Instead of base class version, draws vertical background lines and label
|
79
97
|
def draw_line_markers
|
80
98
|
return if @hide_line_markers
|
81
99
|
|
82
|
-
@d = @d.stroke_antialias false
|
83
|
-
|
84
100
|
# Draw horizontal line markers and annotate with numbers
|
85
|
-
@d = @d.stroke(@marker_color)
|
86
|
-
@d = @d.stroke_width 1
|
87
101
|
number_of_lines = @marker_count || 5
|
88
102
|
number_of_lines = 1 if number_of_lines == 0
|
89
103
|
|
90
|
-
# TODO Round maximum marker value to a round number like 100, 0.1, 0.5, etc.
|
104
|
+
# TODO: Round maximum marker value to a round number like 100, 0.1, 0.5, etc.
|
91
105
|
increment = significant(@spread.to_f / number_of_lines)
|
92
106
|
(0..number_of_lines).each do |index|
|
93
107
|
line_diff = (@graph_right - @graph_left) / number_of_lines
|
94
108
|
x = @graph_right - (line_diff * index) - 1
|
95
|
-
|
109
|
+
Gruff::Renderer::Line.new(color: @marker_color).render(x, @graph_bottom, x, @graph_top)
|
96
110
|
diff = index - number_of_lines
|
97
|
-
marker_label = diff.abs * increment +
|
111
|
+
marker_label = diff.abs * increment + minimum_value
|
98
112
|
|
99
113
|
unless @hide_line_numbers
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
@d.pointsize = scale_fontsize(@marker_font_size)
|
104
|
-
@d.gravity = CenterGravity
|
105
|
-
# TODO Center text over line
|
106
|
-
@d = @d.annotate_scaled(@base_image,
|
107
|
-
0, 0, # Width of box to draw text in
|
108
|
-
x, @graph_bottom + (LABEL_MARGIN * 2.0), # Coordinates of text
|
109
|
-
marker_label.to_s, @scale)
|
110
|
-
end # unless
|
111
|
-
@d = @d.stroke_antialias true
|
114
|
+
text_renderer = Gruff::Renderer::Text.new(marker_label, font: @font, size: @marker_font_size, color: @font_color)
|
115
|
+
text_renderer.render(0, 0, x, @graph_bottom + (LABEL_MARGIN * 2.0), Magick::CenterGravity)
|
116
|
+
end
|
112
117
|
end
|
113
118
|
end
|
114
119
|
|
@@ -116,20 +121,19 @@ protected
|
|
116
121
|
# Draw on the Y axis instead of the X
|
117
122
|
|
118
123
|
def draw_label(y_offset, index, label = nil)
|
119
|
-
|
120
|
-
lbl =
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
1, 1,
|
129
|
-
-@graph_left + LABEL_MARGIN * 2.0, y_offset,
|
130
|
-
lbl, @scale)
|
131
|
-
@labels_seen[index] = 1
|
124
|
+
draw_unique_label(index) do
|
125
|
+
lbl = @use_data_label ? label : @labels[index]
|
126
|
+
|
127
|
+
text_renderer = Gruff::Renderer::Text.new(lbl, font: @font, size: @marker_font_size, color: @font_color)
|
128
|
+
if RUBY_PLATFORM == 'java'
|
129
|
+
text_renderer.render(1, 1, @graph_left - LABEL_MARGIN * 2.0, y_offset, Magick::EastGravity)
|
130
|
+
else
|
131
|
+
text_renderer.render(1, 1, -@graph_left + LABEL_MARGIN * 2.0, y_offset, Magick::EastGravity)
|
132
|
+
end
|
132
133
|
end
|
133
134
|
end
|
134
135
|
|
136
|
+
def calculate_spacing
|
137
|
+
@scale * @group_spacing * (column_count - 1)
|
138
|
+
end
|
135
139
|
end
|
@@ -1,44 +1,60 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'gruff/side_bar'
|
4
|
+
require 'gruff/helper/stacked_mixin'
|
4
5
|
|
5
|
-
##
|
6
6
|
# New gruff graph type added to enable sideways stacking bar charts
|
7
7
|
# (basically looks like a x/y flip of a standard stacking bar chart)
|
8
8
|
#
|
9
9
|
# alun.eyre@googlemail.com
|
10
|
-
|
11
10
|
class Gruff::SideStackedBar < Gruff::SideBar
|
12
11
|
include StackedMixin
|
12
|
+
include BarValueLabelMixin
|
13
13
|
|
14
|
-
# Spacing factor applied between bars
|
14
|
+
# Spacing factor applied between bars.
|
15
15
|
attr_accessor :bar_spacing
|
16
16
|
|
17
|
+
# Number of pixels between bar segments.
|
18
|
+
attr_accessor :segment_spacing
|
19
|
+
|
20
|
+
# Set the number output format for labels using sprintf.
|
21
|
+
# Default is +"%.2f"+.
|
22
|
+
attr_accessor :label_formatting
|
23
|
+
|
24
|
+
# Output the values for the bars on a bar graph.
|
25
|
+
# Default is +false+.
|
26
|
+
attr_accessor :show_labels_for_bar_values
|
27
|
+
|
28
|
+
def initialize_ivars
|
29
|
+
super
|
30
|
+
@label_formatting = nil
|
31
|
+
@show_labels_for_bar_values = false
|
32
|
+
end
|
33
|
+
private :initialize_ivars
|
34
|
+
|
17
35
|
def draw
|
18
36
|
@has_left_labels = true
|
19
37
|
get_maximum_by_stack
|
20
38
|
super
|
21
39
|
end
|
22
40
|
|
23
|
-
|
41
|
+
private
|
24
42
|
|
25
43
|
def draw_bars
|
26
44
|
# Setup spacing.
|
27
45
|
#
|
28
46
|
# Columns sit stacked.
|
29
47
|
@bar_spacing ||= 0.9
|
48
|
+
@segment_spacing ||= 2.0
|
30
49
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
-
@norm_data.each_with_index do |data_row, row_index|
|
41
|
-
data_row[DATA_VALUES_INDEX].each_with_index do |data_point, point_index|
|
50
|
+
bar_width = @graph_height / column_count.to_f
|
51
|
+
height = Array.new(column_count, 0)
|
52
|
+
length = Array.new(column_count, @graph_left)
|
53
|
+
padding = (bar_width * (1 - @bar_spacing)) / 2
|
54
|
+
bar_value_label = BarValueLabel.new(column_count, bar_width)
|
55
|
+
|
56
|
+
store.norm_data.each_with_index do |data_row, row_index|
|
57
|
+
data_row.points.each_with_index do |data_point, point_index|
|
42
58
|
## using the original calcs from the stacked bar chart to get the difference between
|
43
59
|
## part of the bart chart we wish to stack.
|
44
60
|
temp1 = @graph_left + (@graph_width -
|
@@ -47,49 +63,37 @@ protected
|
|
47
63
|
temp2 = @graph_left + @graph_width - height[point_index] - 1
|
48
64
|
difference = temp2 - temp1
|
49
65
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
right_x = left_x + difference
|
55
|
-
right_y = left_y + @bar_width * @bar_spacing
|
66
|
+
left_x = length[point_index]
|
67
|
+
left_y = @graph_top + (bar_width * point_index) + padding
|
68
|
+
right_x = left_x + difference - @segment_spacing
|
69
|
+
right_y = left_y + bar_width * @bar_spacing
|
56
70
|
length[point_index] += difference
|
57
71
|
height[point_index] += (data_point * @graph_width - 2)
|
58
72
|
|
59
|
-
|
60
|
-
|
61
|
-
label_values[point_index][:right_x] = right_x
|
62
|
-
end
|
73
|
+
bar_value_label.coordinates[point_index] = [left_x, left_y, right_x, right_y]
|
74
|
+
bar_value_label.values[point_index] += store.data[row_index].points[point_index]
|
63
75
|
|
64
76
|
# if a data point is 0 it can result in weird really thing lines
|
65
77
|
# that shouldn't even be there being drawn on top of the existing
|
66
78
|
# bar - this is bad
|
67
79
|
if data_point != 0
|
68
|
-
|
80
|
+
rect_renderer = Gruff::Renderer::Rectangle.new(color: data_row.color)
|
81
|
+
rect_renderer.render(left_x, left_y, right_x, right_y)
|
69
82
|
# Calculate center based on bar_width and current row
|
70
83
|
end
|
71
84
|
# we still need to draw the labels
|
72
85
|
# Calculate center based on bar_width and current row
|
73
|
-
label_center =
|
86
|
+
label_center = left_y + bar_width / 2
|
74
87
|
draw_label(label_center, point_index)
|
75
88
|
end
|
76
89
|
end
|
90
|
+
|
77
91
|
if @show_labels_for_bar_values
|
78
|
-
|
79
|
-
|
80
|
-
draw_value_label(data[:right_x] + 40, (@graph_top + (((i + 1) * @bar_width) - (@bar_width / 2))) - 12, val.commify, true)
|
92
|
+
bar_value_label.prepare_sidebar_rendering(@label_formatting) do |x, y, text|
|
93
|
+
draw_value_label(x, y, text, true)
|
81
94
|
end
|
82
95
|
end
|
83
96
|
|
84
|
-
|
97
|
+
Gruff::Renderer.finish
|
85
98
|
end
|
86
|
-
|
87
|
-
def larger_than_max?(data_point, index = 0)
|
88
|
-
max(data_point, index) > @maximum_value
|
89
|
-
end
|
90
|
-
|
91
|
-
def max(data_point, index)
|
92
|
-
@data.inject(0) { |sum, item| sum + item[DATA_VALUES_INDEX][index] }
|
93
|
-
end
|
94
|
-
|
95
99
|
end
|
data/lib/gruff/spider.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'gruff/base'
|
2
4
|
|
3
5
|
# Experimental!!! See also the Net graph.
|
4
6
|
#
|
5
7
|
# Submitted by Kevin Clark http://glu.ttono.us/
|
6
8
|
class Gruff::Spider < Gruff::Base
|
7
|
-
|
8
|
-
# Hide all text
|
9
|
+
# Hide all text.
|
9
10
|
attr_reader :hide_text
|
10
11
|
attr_accessor :hide_axes
|
11
12
|
attr_reader :transparent_background
|
12
13
|
attr_accessor :rotation
|
13
14
|
|
14
15
|
def transparent_background=(value)
|
15
|
-
@
|
16
|
-
@base_image = render_transparent_background if value
|
16
|
+
Gruff::Renderer.setup_transparent_background(@columns, @rows) if value
|
17
17
|
end
|
18
18
|
|
19
19
|
def hide_text=(value)
|
@@ -32,7 +32,7 @@ class Gruff::Spider < Gruff::Base
|
|
32
32
|
|
33
33
|
super
|
34
34
|
|
35
|
-
return unless
|
35
|
+
return unless data_given?
|
36
36
|
|
37
37
|
# Setup basic positioning
|
38
38
|
radius = @graph_height / 2.0
|
@@ -41,7 +41,7 @@ class Gruff::Spider < Gruff::Base
|
|
41
41
|
|
42
42
|
@unit_length = radius / @max_value
|
43
43
|
|
44
|
-
additive_angle = (2 * Math::PI) /
|
44
|
+
additive_angle = (2 * Math::PI) / store.length
|
45
45
|
|
46
46
|
# Draw axes
|
47
47
|
draw_axes(center_x, center_y, radius, additive_angle) unless hide_axes
|
@@ -49,7 +49,7 @@ class Gruff::Spider < Gruff::Base
|
|
49
49
|
# Draw polygon
|
50
50
|
draw_polygon(center_x, center_y, additive_angle)
|
51
51
|
|
52
|
-
|
52
|
+
Gruff::Renderer.finish
|
53
53
|
end
|
54
54
|
|
55
55
|
private
|
@@ -66,16 +66,8 @@ private
|
|
66
66
|
y = y_offset + ((radius + r_offset) * Math.sin(angle))
|
67
67
|
|
68
68
|
# Draw label
|
69
|
-
|
70
|
-
|
71
|
-
@d.pointsize = scale_fontsize(legend_font_size)
|
72
|
-
@d.stroke = 'transparent'
|
73
|
-
@d.font_weight = BoldWeight
|
74
|
-
@d.gravity = CenterGravity
|
75
|
-
@d.annotate_scaled(@base_image,
|
76
|
-
0, 0,
|
77
|
-
x, y,
|
78
|
-
amount, @scale)
|
69
|
+
text_renderer = Gruff::Renderer::Text.new(amount, font: @font, size: legend_font_size, color: @marker_color, weight: Magick::BoldWeight)
|
70
|
+
text_renderer.render(0, 0, x, y, Magick::CenterGravity)
|
79
71
|
end
|
80
72
|
|
81
73
|
def draw_axes(center_x, center_y, radius, additive_angle, line_color = nil)
|
@@ -83,18 +75,14 @@ private
|
|
83
75
|
|
84
76
|
current_angle = rotation * Math::PI / 180.0
|
85
77
|
|
86
|
-
|
87
|
-
@d.stroke(line_color || data_row[DATA_COLOR_INDEX])
|
88
|
-
@d.stroke_width 5.0
|
89
|
-
|
78
|
+
store.data.each do |data_row|
|
90
79
|
x_offset = radius * Math.cos(current_angle)
|
91
80
|
y_offset = radius * Math.sin(current_angle)
|
92
81
|
|
93
|
-
|
94
|
-
|
95
|
-
center_y + y_offset)
|
82
|
+
Gruff::Renderer::Line.new(color: line_color || data_row.color, width: 5.0)
|
83
|
+
.render(center_x, center_y, center_x + x_offset, center_y + y_offset)
|
96
84
|
|
97
|
-
draw_label(center_x, center_y, current_angle, radius, data_row
|
85
|
+
draw_label(center_x, center_y, current_angle, radius, data_row.label.to_s) unless hide_text
|
98
86
|
|
99
87
|
current_angle += additive_angle
|
100
88
|
end
|
@@ -104,21 +92,16 @@ private
|
|
104
92
|
points = []
|
105
93
|
current_angle = rotation * Math::PI / 180.0
|
106
94
|
|
107
|
-
|
108
|
-
points << center_x + normalize_points(data_row
|
109
|
-
points << center_y + normalize_points(data_row
|
95
|
+
store.data.each do |data_row|
|
96
|
+
points << center_x + normalize_points(data_row.points.first) * Math.cos(current_angle)
|
97
|
+
points << center_y + normalize_points(data_row.points.first) * Math.sin(current_angle)
|
110
98
|
current_angle += additive_angle
|
111
99
|
end
|
112
100
|
|
113
|
-
|
114
|
-
@d.stroke(color || @marker_color)
|
115
|
-
@d.fill(color || @marker_color)
|
116
|
-
@d.fill_opacity 0.4
|
117
|
-
@d.polygon(*points)
|
101
|
+
Gruff::Renderer::Polygon.new(color: color || @marker_color, opacity: 0.4).render(points)
|
118
102
|
end
|
119
103
|
|
120
104
|
def sums_for_spider
|
121
|
-
|
105
|
+
store.data.reduce(0.0) { |sum, data_row| sum + data_row.points.first }
|
122
106
|
end
|
123
|
-
|
124
107
|
end
|