sinatra-charter 0.1.5 → 0.1.6
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.
- data/VERSION +1 -1
- data/lib/sinatra-charter.rb +33 -3
- data/sinatra-charter.gemspec +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.6
|
data/lib/sinatra-charter.rb
CHANGED
@@ -53,12 +53,42 @@ module Sinatra
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
def render_bar_chart
|
56
|
+
def render_bar_chart(options = {})
|
57
|
+
labels = {}
|
58
|
+
@chart['labels'].each_pair {|k,v| labels[k.to_i] = v}
|
57
59
|
g = Gruff::Bar.new(@chart['size'])
|
58
60
|
g.theme = chart_theme
|
59
61
|
g.title = @chart['title']
|
60
|
-
g.labels =
|
61
|
-
@chart['data'].
|
62
|
+
g.labels = labels
|
63
|
+
g.data @chart['data'].first, @chart['data'].last.map(&:to_i)
|
64
|
+
g.bar_spacing = 0.8
|
65
|
+
options.each_pair { |k, v| g.send :"#{k}=", v }
|
66
|
+
g.write chart_full_path
|
67
|
+
end
|
68
|
+
|
69
|
+
def render_hbar_chart(options = {})
|
70
|
+
labels = {}
|
71
|
+
@chart['labels'].each_pair {|k,v| labels[k.to_i] = v}
|
72
|
+
g = Gruff::SideBar.new(@chart['size'])
|
73
|
+
g.theme = chart_theme
|
74
|
+
g.title = @chart['title']
|
75
|
+
g.labels = labels
|
76
|
+
#g.data @chart['data'].last.map(&:to_i)
|
77
|
+
g.data 1,4
|
78
|
+
g.data 1,2
|
79
|
+
options.each_pair { |k, v| g.send :"#{k}=", v }
|
80
|
+
g.write chart_full_path
|
81
|
+
end
|
82
|
+
|
83
|
+
def render_pie_chart(options = {})
|
84
|
+
labels = {}
|
85
|
+
@chart['labels'].each_pair {|k,v| labels[k.to_i] = v}
|
86
|
+
g = Gruff::Pie.new(@chart['size'])
|
87
|
+
g.theme_pastel
|
88
|
+
g.title = @chart['title']
|
89
|
+
g.labels = labels
|
90
|
+
labels.each_with_index {|label, i| g.data label[i], @chart['data'].last[i]}
|
91
|
+
#options.each_pair { |k, v| g.send :"#{k}=", v }
|
62
92
|
g.write chart_full_path
|
63
93
|
end
|
64
94
|
end
|
data/sinatra-charter.gemspec
CHANGED