From 34a2dc6b9707a2d15ae2f6501d86b3770cc5a088 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 28 Jan 2019 14:16:41 +0000 Subject: [PATCH] stats: turn satisfaction into a stacked area chart --- app/controllers/stats_controller.rb | 8 ++++---- app/views/stats/index.html.haml | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index 196c292d6..5a7579fa7 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -129,9 +129,9 @@ class StatsController < ApplicationController def satisfaction_usagers legend = { - Feedback.ratings.fetch(:happy) => "Satisfaits", - Feedback.ratings.fetch(:neutral) => "Neutres", - Feedback.ratings.fetch(:unhappy) => "Mécontents" + Feedback.ratings.fetch(:unhappy) => "Mécontents", + Feedback.ratings.fetch(:neutral) => "Neutres", + Feedback.ratings.fetch(:happy) => "Satisfaits" } number_of_weeks = 6 @@ -139,7 +139,7 @@ class StatsController < ApplicationController .group_by_week(:created_at, last: number_of_weeks, current: false) .count - Feedback.ratings.values.map do |rating| + legend.keys.map do |rating| data = Feedback .where(rating: rating) .group_by_week(:created_at, last: number_of_weeks, current: false) diff --git a/app/views/stats/index.html.haml b/app/views/stats/index.html.haml index 80b46b8d6..c0483ce45 100644 --- a/app/views/stats/index.html.haml +++ b/app/views/stats/index.html.haml @@ -25,8 +25,10 @@ .chart-container .chart - = line_chart @satisfaction_usagers, - colors: ["#15AD70", "#F28900", "rgba(161, 0, 5, 0.9)"] + = area_chart @satisfaction_usagers, + stacked: true, + max: 100, + colors: ["#BD0107", "#F28900", "#15AD70"] .stat-card.stat-card-half.pull-left %span.stat-card-title