Host the charting library ourselves instead of from Google

This fixes the debt chart not working in Firefox (has a built-in tracking blocker). Also made chart nicer
to display by adding percentages
This commit is contained in:
redfast00 2019-04-13 21:26:51 +02:00
parent 98f60701ec
commit ce5c1e3fbe
No known key found for this signature in database
GPG Key ID: 5946E0E34FD0553C
3 changed files with 4 additions and 4 deletions

View File

@ -22,6 +22,8 @@
//= require react
//= require react_ujs
//= require components
//= require Chart.bundle
//= require chartkick
//= require_tree .
ready = function() {

View File

@ -12,7 +12,7 @@ class Statistics < Rails::Application
def shamehash
none_shaming = total_debt + shameful_users.sum(:balance)
shameful_users.inject({'Reputable users' => none_shaming.to_f / total_debt}) do |h, u|
h.merge({u.name => - u.balance.to_f / total_debt})
h.merge({u.name => - u.balance.to_f / total_debt * 100.0})
end
end
@ -31,4 +31,3 @@ class Statistics < Rails::Application
.take([shameful_users.count, 4].max)
end
end

View File

@ -1,5 +1,4 @@
%h1.columns-title Tab
= javascript_include_tag "//www.google.com/jsapi", "chartkick"
.pure-g.landing_columns
.pure-u-1.pure-u-md-1-2
%h2 Authentication
@ -7,4 +6,4 @@
%p= link_to "Log in met Zeus WPI", user_zeuswpi_omniauth_authorize_path, class: "pure-button pure-button-primary login-button"
.pure-u-1.pure-u-md-1-2
%h2 Pie of Shame
= pie_chart @statistics.shamehash
= pie_chart @statistics.shamehash, suffix: '%'