sinatra-charter 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
@@ -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 = @chart['labels']
61
- @chart['data'].each { |i| g.data i.first.to_i, i.last }
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sinatra-charter}
8
- s.version = "0.1.5"
8
+ s.version = "0.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Lorenzo Planas"]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 5
9
- version: 0.1.5
8
+ - 6
9
+ version: 0.1.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Lorenzo Planas