gruff 0.13.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 +4 -4
- data/.github/workflows/ci.yml +79 -0
- data/.rubocop.yml +29 -31
- data/CHANGELOG.md +43 -0
- data/README.md +11 -5
- data/gruff.gemspec +8 -10
- data/lib/gruff/accumulator_bar.rb +4 -2
- data/lib/gruff/area.rb +9 -12
- data/lib/gruff/bar.rb +46 -31
- data/lib/gruff/base.rb +236 -207
- data/lib/gruff/bezier.rb +6 -8
- data/lib/gruff/box_plot.rb +174 -0
- data/lib/gruff/bullet.rb +17 -16
- data/lib/gruff/candlestick.rb +112 -0
- data/lib/gruff/dot.rb +14 -14
- data/lib/gruff/font.rb +42 -0
- data/lib/gruff/helper/bar_conversion.rb +5 -5
- data/lib/gruff/helper/bar_value_label.rb +26 -20
- data/lib/gruff/helper/stacked_mixin.rb +4 -3
- data/lib/gruff/histogram.rb +9 -7
- data/lib/gruff/line.rb +96 -83
- data/lib/gruff/mini/bar.rb +9 -6
- data/lib/gruff/mini/legend.rb +16 -12
- data/lib/gruff/mini/pie.rb +9 -6
- data/lib/gruff/mini/side_bar.rb +9 -6
- data/lib/gruff/net.rb +16 -22
- data/lib/gruff/patch/rmagick.rb +0 -1
- data/lib/gruff/patch/string.rb +2 -1
- data/lib/gruff/pie.rb +42 -75
- data/lib/gruff/renderer/bezier.rb +8 -9
- data/lib/gruff/renderer/circle.rb +8 -9
- data/lib/gruff/renderer/dash_line.rb +10 -10
- data/lib/gruff/renderer/dot.rb +15 -14
- data/lib/gruff/renderer/ellipse.rb +8 -9
- data/lib/gruff/renderer/line.rb +8 -11
- data/lib/gruff/renderer/polygon.rb +9 -10
- data/lib/gruff/renderer/polyline.rb +8 -9
- data/lib/gruff/renderer/rectangle.rb +11 -8
- data/lib/gruff/renderer/renderer.rb +25 -40
- data/lib/gruff/renderer/text.rb +21 -37
- data/lib/gruff/scatter.rb +86 -85
- data/lib/gruff/side_bar.rb +50 -37
- data/lib/gruff/side_stacked_bar.rb +26 -35
- data/lib/gruff/spider.rb +52 -28
- data/lib/gruff/stacked_area.rb +20 -16
- data/lib/gruff/stacked_bar.rb +44 -22
- data/lib/gruff/store/store.rb +6 -10
- data/lib/gruff/store/xy_data.rb +2 -0
- data/lib/gruff/themes.rb +6 -6
- data/lib/gruff/version.rb +1 -1
- data/lib/gruff.rb +70 -57
- data/rails_generators/gruff/templates/controller.rb +1 -1
- metadata +15 -32
- data/.rubocop_todo.yml +0 -182
- data/.travis.yml +0 -23
- data/assets/plastik/blue.png +0 -0
- data/assets/plastik/green.png +0 -0
- data/assets/plastik/red.png +0 -0
- data/lib/gruff/photo_bar.rb +0 -93
- data/lib/gruff/scene.rb +0 -198
- data/lib/gruff/store/custom_data.rb +0 -36
data/lib/gruff/spider.rb
CHANGED
@@ -19,35 +19,52 @@ class Gruff::Spider < Gruff::Base
|
|
19
19
|
attr_writer :hide_axes
|
20
20
|
attr_writer :rotation
|
21
21
|
|
22
|
+
def initialize(max_value, target_width = 800)
|
23
|
+
super(target_width)
|
24
|
+
@max_value = max_value
|
25
|
+
end
|
26
|
+
|
22
27
|
def transparent_background=(value)
|
23
|
-
|
28
|
+
renderer.transparent_background(@columns, @rows) if value
|
24
29
|
end
|
25
30
|
|
26
31
|
def hide_text=(value)
|
27
32
|
@hide_title = @hide_text = value
|
28
33
|
end
|
29
34
|
|
30
|
-
|
31
|
-
super(target_width)
|
32
|
-
@max_value = max_value
|
33
|
-
end
|
35
|
+
private
|
34
36
|
|
35
|
-
def
|
37
|
+
def initialize_attributes
|
36
38
|
super
|
37
39
|
@hide_legend = true
|
38
40
|
@hide_axes = false
|
39
41
|
@hide_text = false
|
40
42
|
@rotation = 0
|
41
|
-
|
42
|
-
private :initialize_ivars
|
43
|
+
@marker_font.bold = true
|
43
44
|
|
44
|
-
def draw
|
45
45
|
@hide_line_markers = true
|
46
|
+
@hide_line_markers.freeze
|
47
|
+
end
|
46
48
|
|
49
|
+
def setup_graph_measurements
|
47
50
|
super
|
48
51
|
|
49
|
-
|
52
|
+
@graph_left += LABEL_MARGIN
|
53
|
+
@graph_top += LABEL_MARGIN
|
54
|
+
@graph_right -= LABEL_MARGIN
|
55
|
+
@graph_bottom -= LABEL_MARGIN
|
50
56
|
|
57
|
+
@graph_width = @graph_right - @graph_left
|
58
|
+
@graph_height = @graph_bottom - @graph_top
|
59
|
+
end
|
60
|
+
|
61
|
+
def setup_data
|
62
|
+
raise(Gruff::IncorrectNumberOfDatasetsException, 'Requires 3 or more data sets') if store.length < 3
|
63
|
+
|
64
|
+
super
|
65
|
+
end
|
66
|
+
|
67
|
+
def draw_graph
|
51
68
|
# Setup basic positioning
|
52
69
|
radius = @graph_height / 2.0
|
53
70
|
center_x = @graph_left + (@graph_width / 2.0)
|
@@ -64,34 +81,45 @@ class Gruff::Spider < Gruff::Base
|
|
64
81
|
draw_polygon(center_x, center_y, additive_angle)
|
65
82
|
end
|
66
83
|
|
67
|
-
private
|
68
|
-
|
69
84
|
def normalize_points(value)
|
70
85
|
value * @unit_length
|
71
86
|
end
|
72
87
|
|
73
88
|
def draw_label(center_x, center_y, angle, radius, amount)
|
74
|
-
|
75
|
-
|
76
|
-
|
89
|
+
degree = rad2deg(angle)
|
90
|
+
metrics = text_metrics(@marker_font, amount)
|
91
|
+
|
92
|
+
r_offset = LABEL_MARGIN # The distance out from the center of the pie to get point
|
93
|
+
x_offset = center_x # The label points need to be tweaked slightly
|
94
|
+
|
95
|
+
x_offset -= begin
|
96
|
+
case degree
|
97
|
+
when 0..45, 315..360
|
98
|
+
0
|
99
|
+
when 135..225
|
100
|
+
metrics.width
|
101
|
+
else
|
102
|
+
metrics.width / 2
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
y_offset = center_y - (metrics.height / 2.0) # This one doesn't though
|
77
107
|
x = x_offset + ((radius + r_offset) * Math.cos(angle))
|
78
108
|
y = y_offset + ((radius + r_offset) * Math.sin(angle))
|
79
109
|
|
80
|
-
|
81
|
-
text_renderer = Gruff::Renderer::Text.new(amount, font: @font, size: @legend_font_size, color: @marker_color, weight: Magick::BoldWeight)
|
82
|
-
text_renderer.add_to_render_queue(0, 0, x, y, Magick::CenterGravity)
|
110
|
+
draw_label_at(metrics.width, metrics.height, x, y, amount, Magick::CenterGravity)
|
83
111
|
end
|
84
112
|
|
85
113
|
def draw_axes(center_x, center_y, radius, additive_angle, line_color = nil)
|
86
114
|
return if @hide_axes
|
87
115
|
|
88
|
-
current_angle = @rotation
|
116
|
+
current_angle = deg2rad(@rotation)
|
89
117
|
|
90
118
|
store.data.each do |data_row|
|
91
119
|
x_offset = radius * Math.cos(current_angle)
|
92
120
|
y_offset = radius * Math.sin(current_angle)
|
93
121
|
|
94
|
-
Gruff::Renderer::Line.new(color: line_color || data_row.color, width: 5.0)
|
122
|
+
Gruff::Renderer::Line.new(renderer, color: line_color || data_row.color, width: 5.0)
|
95
123
|
.render(center_x, center_y, center_x + x_offset, center_y + y_offset)
|
96
124
|
|
97
125
|
draw_label(center_x, center_y, current_angle, radius, data_row.label.to_s) unless @hide_text
|
@@ -102,18 +130,14 @@ private
|
|
102
130
|
|
103
131
|
def draw_polygon(center_x, center_y, additive_angle, color = nil)
|
104
132
|
points = []
|
105
|
-
current_angle = @rotation
|
133
|
+
current_angle = deg2rad(@rotation)
|
106
134
|
|
107
135
|
store.data.each do |data_row|
|
108
|
-
points << center_x + normalize_points(data_row.points.first) * Math.cos(current_angle)
|
109
|
-
points << center_y + normalize_points(data_row.points.first) * Math.sin(current_angle)
|
136
|
+
points << (center_x + (normalize_points(data_row.points.first) * Math.cos(current_angle)))
|
137
|
+
points << (center_y + (normalize_points(data_row.points.first) * Math.sin(current_angle)))
|
110
138
|
current_angle += additive_angle
|
111
139
|
end
|
112
140
|
|
113
|
-
Gruff::Renderer::Polygon.new(color: color || @marker_color, opacity: 0.4).render(points)
|
114
|
-
end
|
115
|
-
|
116
|
-
def sums_for_spider
|
117
|
-
store.data.sum { |data_row| data_row.points.first }
|
141
|
+
Gruff::Renderer::Polygon.new(renderer, color: color || @marker_color, opacity: 0.4).render(points)
|
118
142
|
end
|
119
143
|
end
|
data/lib/gruff/stacked_area.rb
CHANGED
@@ -12,34 +12,38 @@
|
|
12
12
|
#
|
13
13
|
class Gruff::StackedArea < Gruff::Base
|
14
14
|
include StackedMixin
|
15
|
-
attr_writer :last_series_goes_on_bottom
|
16
15
|
|
17
|
-
|
16
|
+
# @deprecated
|
17
|
+
def last_series_goes_on_bottom=(_value)
|
18
|
+
warn '#last_series_goes_on_bottom is deprecated. It is no longer effective.'
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def initialize_attributes
|
18
24
|
super
|
19
|
-
@
|
25
|
+
@minimum_value = 0.0
|
20
26
|
end
|
21
|
-
private :initialize_ivars
|
22
27
|
|
23
|
-
def
|
28
|
+
def setup_data
|
24
29
|
calculate_maximum_by_stack
|
25
30
|
super
|
31
|
+
end
|
26
32
|
|
27
|
-
|
28
|
-
|
29
|
-
x_increment = @graph_width / (column_count - 1).to_f
|
33
|
+
def draw_graph
|
34
|
+
x_increment = @graph_width / (column_count - 1)
|
30
35
|
|
31
36
|
height = Array.new(column_count, 0)
|
32
37
|
|
33
38
|
data_points = nil
|
34
|
-
|
35
|
-
store.norm_data.public_send(iterator) do |data_row|
|
39
|
+
store.norm_data.each do |data_row|
|
36
40
|
prev_data_points = data_points
|
37
41
|
data_points = []
|
38
42
|
|
39
43
|
data_row.points.each_with_index do |data_point, index|
|
40
44
|
# Use incremented x and scaled y
|
41
45
|
new_x = @graph_left + (x_increment * index)
|
42
|
-
new_y = @graph_top + (@graph_height - data_point * @graph_height - height[index])
|
46
|
+
new_y = @graph_top + (@graph_height - (data_point * @graph_height) - height[index])
|
43
47
|
|
44
48
|
height[index] += (data_point * @graph_height)
|
45
49
|
|
@@ -51,20 +55,20 @@ class Gruff::StackedArea < Gruff::Base
|
|
51
55
|
|
52
56
|
poly_points = data_points.dup
|
53
57
|
if prev_data_points
|
54
|
-
(prev_data_points.length / 2 - 1).downto(0) do |i|
|
58
|
+
((prev_data_points.length / 2) - 1).downto(0) do |i|
|
55
59
|
poly_points << prev_data_points[2 * i]
|
56
|
-
poly_points << prev_data_points[2 * i + 1]
|
60
|
+
poly_points << prev_data_points[(2 * i) + 1]
|
57
61
|
end
|
58
62
|
else
|
59
63
|
poly_points << @graph_right
|
60
|
-
poly_points << @graph_bottom - 1
|
64
|
+
poly_points << (@graph_bottom - 1)
|
61
65
|
poly_points << @graph_left
|
62
|
-
poly_points << @graph_bottom - 1
|
66
|
+
poly_points << (@graph_bottom - 1)
|
63
67
|
end
|
64
68
|
poly_points << data_points[0]
|
65
69
|
poly_points << data_points[1]
|
66
70
|
|
67
|
-
Gruff::Renderer::Polygon.new(color: data_row.color).render(poly_points)
|
71
|
+
Gruff::Renderer::Polygon.new(renderer, color: data_row.color).render(poly_points)
|
68
72
|
end
|
69
73
|
end
|
70
74
|
end
|
data/lib/gruff/stacked_bar.rb
CHANGED
@@ -30,76 +30,98 @@ class Gruff::StackedBar < Gruff::Base
|
|
30
30
|
# Prevent drawing of column labels below a stacked bar graph. Default is +false+.
|
31
31
|
attr_writer :hide_labels
|
32
32
|
|
33
|
-
|
33
|
+
private
|
34
|
+
|
35
|
+
def initialize_attributes
|
34
36
|
super
|
35
37
|
@bar_spacing = 0.9
|
36
38
|
@segment_spacing = 2
|
37
39
|
@label_formatting = nil
|
38
40
|
@show_labels_for_bar_values = false
|
39
41
|
@hide_labels = false
|
42
|
+
@minimum_value = 0.0
|
40
43
|
end
|
41
|
-
private :initialize_ivars
|
42
44
|
|
43
|
-
|
44
|
-
def draw
|
45
|
+
def setup_data
|
45
46
|
calculate_maximum_by_stack
|
46
47
|
super
|
47
|
-
|
48
|
+
end
|
49
|
+
|
50
|
+
def setup_graph_measurements
|
51
|
+
super
|
52
|
+
return if @hide_line_markers
|
53
|
+
|
54
|
+
if @show_labels_for_bar_values
|
55
|
+
proc_text_metrics = ->(text) { text_metrics(@marker_font, text) }
|
48
56
|
|
57
|
+
if maximum_value >= 0
|
58
|
+
_, metrics = Gruff::BarValueLabel.metrics(maximum_value, @label_formatting, proc_text_metrics)
|
59
|
+
@graph_top += metrics.height
|
60
|
+
end
|
61
|
+
|
62
|
+
@graph_height = @graph_bottom - @graph_top
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Draws a bar graph, but multiple sets are stacked on top of each other.
|
67
|
+
def draw_graph
|
49
68
|
# Setup spacing.
|
50
69
|
#
|
51
70
|
# Columns sit stacked.
|
52
|
-
bar_width = @graph_width / column_count
|
71
|
+
bar_width = @graph_width / column_count
|
53
72
|
padding = (bar_width * (1 - @bar_spacing)) / 2
|
54
73
|
|
55
74
|
height = Array.new(column_count, 0)
|
56
|
-
|
75
|
+
length = Array.new(column_count, @graph_bottom)
|
76
|
+
stack_bar_value_labels = Gruff::BarValueLabel::StackedBar.new
|
57
77
|
|
58
78
|
store.norm_data.each_with_index do |data_row, row_index|
|
59
79
|
data_row.points.each_with_index do |data_point, point_index|
|
60
|
-
|
80
|
+
temp1 = @graph_top + (@graph_height - (data_point * @graph_height) - height[point_index])
|
81
|
+
temp2 = @graph_top + @graph_height - height[point_index]
|
82
|
+
difference = temp2 - temp1
|
83
|
+
difference = 0 if difference < 0
|
61
84
|
|
62
85
|
# Use incremented x and scaled y
|
63
86
|
left_x = @graph_left + (bar_width * point_index) + padding
|
64
|
-
left_y =
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
right_y = @graph_top + @graph_height - height[point_index]
|
87
|
+
left_y = length[point_index] - difference
|
88
|
+
right_x = left_x + (bar_width * @bar_spacing)
|
89
|
+
right_y = length[point_index]
|
90
|
+
right_y -= @segment_spacing if row_index != store.columns - 1
|
69
91
|
|
70
92
|
# update the total height of the current stacked bar
|
93
|
+
length[point_index] -= difference
|
71
94
|
height[point_index] += (data_point * @graph_height)
|
72
95
|
|
73
|
-
rect_renderer = Gruff::Renderer::Rectangle.new(color: data_row.color)
|
96
|
+
rect_renderer = Gruff::Renderer::Rectangle.new(renderer, color: data_row.color)
|
74
97
|
rect_renderer.render(left_x, left_y, right_x, right_y)
|
75
98
|
|
76
99
|
# Calculate center based on bar_width and current row
|
77
|
-
label_center = left_x + bar_width * @bar_spacing / 2.0
|
100
|
+
label_center = left_x + (bar_width * @bar_spacing / 2.0)
|
78
101
|
draw_label(label_center, point_index)
|
79
102
|
|
80
103
|
bar_value_label = Gruff::BarValueLabel::Bar.new([left_x, left_y, right_x, right_y], store.data[row_index].points[point_index])
|
81
|
-
|
104
|
+
stack_bar_value_labels.add(bar_value_label, point_index)
|
82
105
|
end
|
83
106
|
end
|
84
107
|
|
85
108
|
if @show_labels_for_bar_values
|
86
|
-
|
87
|
-
|
109
|
+
proc_text_metrics = ->(text) { text_metrics(@marker_font, text) }
|
110
|
+
stack_bar_value_labels.prepare_rendering(@label_formatting, proc_text_metrics) do |x, y, text, _text_width, text_height|
|
111
|
+
draw_value_label(bar_width * @bar_spacing, text_height, x, y, text)
|
88
112
|
end
|
89
113
|
end
|
90
114
|
end
|
91
115
|
|
92
|
-
protected
|
93
|
-
|
94
116
|
def hide_labels?
|
95
117
|
@hide_labels
|
96
118
|
end
|
97
119
|
|
98
120
|
def hide_left_label_area?
|
99
|
-
@hide_line_markers
|
121
|
+
@hide_line_markers && @y_axis_label.nil?
|
100
122
|
end
|
101
123
|
|
102
124
|
def hide_bottom_label_area?
|
103
|
-
hide_labels?
|
125
|
+
hide_labels? && @x_axis_label.nil? && @legend_at_bottom == false
|
104
126
|
end
|
105
127
|
end
|
data/lib/gruff/store/store.rb
CHANGED
@@ -3,27 +3,23 @@
|
|
3
3
|
module Gruff
|
4
4
|
# @private
|
5
5
|
class Store
|
6
|
-
attr_reader :data
|
6
|
+
attr_reader :data
|
7
7
|
|
8
8
|
def initialize(data_class)
|
9
9
|
@data_class = data_class
|
10
10
|
@data = []
|
11
|
-
@norm_data = []
|
12
|
-
@normalized = false
|
13
11
|
end
|
14
12
|
|
15
13
|
def add(*args)
|
16
14
|
@data << @data_class.new(*args)
|
17
15
|
end
|
18
16
|
|
19
|
-
def
|
20
|
-
|
21
|
-
|
22
|
-
@norm_data << data_row.normalize(**keywords)
|
23
|
-
end
|
17
|
+
def norm_data
|
18
|
+
@norm_data || []
|
19
|
+
end
|
24
20
|
|
25
|
-
|
26
|
-
|
21
|
+
def normalize(**keywords)
|
22
|
+
@norm_data = @data.map { |data_row| data_row.normalize(**keywords) }
|
27
23
|
end
|
28
24
|
|
29
25
|
def empty?
|
data/lib/gruff/store/xy_data.rb
CHANGED
data/lib/gruff/themes.rb
CHANGED
@@ -16,7 +16,7 @@ module Gruff
|
|
16
16
|
marker_color: 'white',
|
17
17
|
font_color: 'white',
|
18
18
|
background_colors: %w[black #4a465a]
|
19
|
-
}
|
19
|
+
}.freeze
|
20
20
|
|
21
21
|
# A color scheme plucked from the colors on the popular usability blog.
|
22
22
|
THIRTYSEVEN_SIGNALS = {
|
@@ -32,7 +32,7 @@ module Gruff
|
|
32
32
|
marker_color: 'black',
|
33
33
|
font_color: 'black',
|
34
34
|
background_colors: %w[#d1edf5 white]
|
35
|
-
}
|
35
|
+
}.freeze
|
36
36
|
|
37
37
|
# A color scheme from the colors used on the 2005 Rails keynote
|
38
38
|
# presentation at RubyConf.
|
@@ -49,7 +49,7 @@ module Gruff
|
|
49
49
|
marker_color: 'white',
|
50
50
|
font_color: 'white',
|
51
51
|
background_colors: %w[#0083a3 #0083a3]
|
52
|
-
}
|
52
|
+
}.freeze
|
53
53
|
|
54
54
|
# A color scheme similar to that used on the popular podcast site.
|
55
55
|
ODEO = {
|
@@ -65,7 +65,7 @@ module Gruff
|
|
65
65
|
marker_color: 'white',
|
66
66
|
font_color: 'white',
|
67
67
|
background_colors: %w[#ff47a4 #ff1f81]
|
68
|
-
}
|
68
|
+
}.freeze
|
69
69
|
|
70
70
|
# A pastel theme
|
71
71
|
PASTEL = {
|
@@ -81,7 +81,7 @@ module Gruff
|
|
81
81
|
marker_color: '#aea9a9', # Grey
|
82
82
|
font_color: 'black',
|
83
83
|
background_colors: 'white'
|
84
|
-
}
|
84
|
+
}.freeze
|
85
85
|
|
86
86
|
# A greyscale theme
|
87
87
|
GREYSCALE = {
|
@@ -96,6 +96,6 @@ module Gruff
|
|
96
96
|
marker_color: '#aea9a9', # Grey
|
97
97
|
font_color: 'black',
|
98
98
|
background_colors: 'white'
|
99
|
-
}
|
99
|
+
}.freeze
|
100
100
|
end
|
101
101
|
end
|
data/lib/gruff/version.rb
CHANGED
data/lib/gruff.rb
CHANGED
@@ -1,61 +1,74 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'rmagick'
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
4
|
+
|
5
|
+
require_relative 'gruff/patch/rmagick'
|
6
|
+
require_relative 'gruff/patch/string'
|
7
|
+
require_relative 'gruff/renderer/renderer'
|
8
|
+
require_relative 'gruff/store/store'
|
9
|
+
require_relative 'gruff/font'
|
10
|
+
require_relative 'gruff/base'
|
11
|
+
require_relative 'gruff/version'
|
12
|
+
|
13
|
+
##
|
14
|
+
# = Gruff. Graphs.
|
15
|
+
#
|
16
|
+
module Gruff
|
17
|
+
# @private
|
18
|
+
def self.libpath(path)
|
19
|
+
File.join(__dir__, 'gruff', path)
|
20
|
+
end
|
21
|
+
|
22
|
+
autoload :BarConversion, Gruff.libpath('helper/bar_conversion')
|
23
|
+
autoload :BarValueLabel, Gruff.libpath('helper/bar_value_label')
|
24
|
+
class Base
|
25
|
+
autoload :StackedMixin, Gruff.libpath('helper/stacked_mixin')
|
26
|
+
end
|
27
|
+
|
28
|
+
autoload :AccumulatorBar, Gruff.libpath('accumulator_bar')
|
29
|
+
autoload :Area, Gruff.libpath('area')
|
30
|
+
autoload :Bar, Gruff.libpath('bar')
|
31
|
+
autoload :Bezier, Gruff.libpath('bezier')
|
32
|
+
autoload :BoxPlot, Gruff.libpath('box_plot')
|
33
|
+
autoload :Bullet, Gruff.libpath('bullet')
|
34
|
+
autoload :Candlestick, Gruff.libpath('candlestick')
|
35
|
+
autoload :Dot, Gruff.libpath('dot')
|
36
|
+
autoload :Histogram, Gruff.libpath('histogram')
|
37
|
+
autoload :Line, Gruff.libpath('line')
|
38
|
+
autoload :Net, Gruff.libpath('net')
|
39
|
+
autoload :Pie, Gruff.libpath('pie')
|
40
|
+
autoload :Scatter, Gruff.libpath('scatter')
|
41
|
+
autoload :SideBar, Gruff.libpath('side_bar')
|
42
|
+
autoload :SideStackedBar, Gruff.libpath('side_stacked_bar')
|
43
|
+
autoload :Spider, Gruff.libpath('spider')
|
44
|
+
autoload :StackedArea, Gruff.libpath('stacked_area')
|
45
|
+
autoload :StackedBar, Gruff.libpath('stacked_bar')
|
46
|
+
|
47
|
+
autoload :Layer, Gruff.libpath('scene')
|
48
|
+
autoload :Themes, Gruff.libpath('themes')
|
49
|
+
|
50
|
+
class Renderer
|
51
|
+
autoload :Bezier, Gruff.libpath('renderer/bezier')
|
52
|
+
autoload :Circle, Gruff.libpath('renderer/circle')
|
53
|
+
autoload :DashLine, Gruff.libpath('renderer/dash_line')
|
54
|
+
autoload :Dot, Gruff.libpath('renderer/dot')
|
55
|
+
autoload :Ellipse, Gruff.libpath('renderer/ellipse')
|
56
|
+
autoload :Line, Gruff.libpath('renderer/line')
|
57
|
+
autoload :Polygon, Gruff.libpath('renderer/polygon')
|
58
|
+
autoload :Polyline, Gruff.libpath('renderer/polyline')
|
59
|
+
autoload :Rectangle, Gruff.libpath('renderer/rectangle')
|
60
|
+
autoload :Text, Gruff.libpath('renderer/text')
|
61
|
+
end
|
62
|
+
|
63
|
+
class Store
|
64
|
+
autoload :BasicData, Gruff.libpath('store/basic_data')
|
65
|
+
autoload :XYData, Gruff.libpath('store/xy_data')
|
66
|
+
end
|
67
|
+
|
68
|
+
module Mini
|
69
|
+
autoload :Bar, Gruff.libpath('mini/bar')
|
70
|
+
autoload :Legend, Gruff.libpath('mini/legend')
|
71
|
+
autoload :Pie, Gruff.libpath('mini/pie')
|
72
|
+
autoload :SideBar, Gruff.libpath('mini/side_bar')
|
73
|
+
end
|
61
74
|
end
|
@@ -26,7 +26,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
26
26
|
|
27
27
|
g.labels = {0 => '2004', 2 => '2005', 4 => '2006'}
|
28
28
|
|
29
|
-
send_data(g.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "gruff.png")
|
29
|
+
send_data(g.to_image.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "gruff.png")
|
30
30
|
end
|
31
31
|
|
32
32
|
end
|