diff --git a/Gemfile b/Gemfile
index 1884105..912bcb4 100644
--- a/Gemfile
+++ b/Gemfile
@@ -8,3 +8,4 @@ gem 'puma'
gem 'sqlite3'
gem 'bcrypt'
gem 'gettext'
+gem 'chartkick'
diff --git a/Gemfile.lock b/Gemfile.lock
index ca3398b..995a623 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -23,6 +23,7 @@ GEM
bcrypt (3.1.20)
benchmark (0.4.0)
bigdecimal (3.1.9)
+ chartkick (5.1.4)
concurrent-ruby (1.3.5)
connection_pool (2.5.0)
drb (2.2.1)
@@ -91,6 +92,7 @@ PLATFORMS
DEPENDENCIES
bcrypt
+ chartkick
gettext
puma
rackup
diff --git a/views/layout.erb b/views/layout.erb
index defbed5..8f974f6 100644
--- a/views/layout.erb
+++ b/views/layout.erb
@@ -3,6 +3,8 @@
<%= _("Vote") %>
+
+
<% if current_user %>
diff --git a/views/votes_show_closed.erb b/views/votes_show_closed.erb
index f75958f..4ca8b71 100644
--- a/views/votes_show_closed.erb
+++ b/views/votes_show_closed.erb
@@ -46,6 +46,20 @@
<% end %>
+<%
+data = []
+colors = []
+settings.values.reverse.each do |v|
+ d = { name: v[:label], data: [] }
+ @vote.candidates.each do |c|
+ d[:data] << [c.name, c.mj.count[v[:id]]]
+ end
+ data << d
+ colors << v[:color]
+end
+%>
+<%= bar_chart data, colors: colors, stacked: true, legend: 'bottom' %>
+
<%= _("Organizers") %>
diff --git a/vote.rb b/vote.rb
index 4c6a71d..e9e2475 100644
--- a/vote.rb
+++ b/vote.rb
@@ -3,6 +3,7 @@ require 'sinatra/activerecord'
require 'bcrypt'
require 'gettext'
require 'securerandom'
+require 'chartkick'
require_relative 'mj'
class Vote < ActiveRecord::Base
@@ -56,13 +57,12 @@ bindtextdomain('vote', 'locale')
set_locale('ca')
enable :sessions
-set :values, [ { :id => 1, :label => _("Awful") },
- { :id => 2, :label => _("Very bad") },
- { :id => 3, :label => _("Bad") },
- { :id => 4, :label => _("Mediocre") },
- { :id => 5, :label => _("Good") },
- { :id => 6, :label => _("Very good") },
- { :id => 7, :label => _("Excellent") } ]
+set :values, [ { :id => 1, :label => _("Awful"), :color => '#ff4500' },
+ { :id => 2, :label => _("Very bad"), :color => '#ffa500' },
+ { :id => 3, :label => _("Bad"), :color => '#ffff00' },
+ { :id => 4, :label => _("Mediocre"), :color => '#9acd32' },
+ { :id => 5, :label => _("Good"), :color => '#228b22' },
+ { :id => 6, :label => _("Very good"), :color => '#006400' } ]
MajorityJudgment.values = settings.values
get '/' do