From 2dc39e1498eead13574a825e0cbbfd97bb78dc74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Salvador=20P=C3=A9rez=20Garc=C3=ADa?= Date: Mon, 1 Oct 2018 11:22:32 +0200 Subject: [PATCH] Enhacements in proposal progress graph Proposed action execution is shown with a red dot. Mouse hover event shows a pop up for the points of the graph. Red dots will contain the proposed acction executed for the given date. --- app/assets/javascripts/dashboard_graphs.js | 37 +++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/dashboard_graphs.js b/app/assets/javascripts/dashboard_graphs.js index a17ca01e3..6bad63d21 100644 --- a/app/assets/javascripts/dashboard_graphs.js +++ b/app/assets/javascripts/dashboard_graphs.js @@ -165,7 +165,24 @@ this.progressColumnValues, this.successfulColumnValues ], - colors: colors + colors: colors, + color: function (color, d) { + var achievement; + + if (d.id === this.successfulColumnValues[0] || !d.hasOwnProperty('x')) { + return color; + } + + achievement = this.achievements.find(function (element) { + return element.value === this.xColumnValues[d.index + 1]; + }.bind(this)); + + if (achievement !== undefined) { + return '#ff0000'; + } + + return color; + }.bind(this) }, axis: { y: { @@ -190,13 +207,25 @@ grid: { y: { lines: this.goals - }, - x: { - lines: this.achievements } }, zoom: { enabled: true + }, + tooltip: { + format: { + title: function (d) { + var achievement = this.achievements.find(function (element) { + return element.value === this.xColumnValues[d + 1]; + }.bind(this)); + + if (achievement !== undefined) { + return this.xColumnValues[d + 1] + ': ' + achievement.text; + } + + return this.xColumnValues[d + 1]; + }.bind(this) + } } }); };