From 8ed2f5d17ab6c80f977439a7fcf3013545e5433d Mon Sep 17 00:00:00 2001 From: Zarino Zappia Date: Thu, 22 Feb 2018 16:21:32 +0000 Subject: [UK] Properly align Dashboard bar chart value labels --- web/js/dashboard.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'web/js/dashboard.js') diff --git a/web/js/dashboard.js b/web/js/dashboard.js index 0eb53f964..23c5496e6 100644 --- a/web/js/dashboard.js +++ b/web/js/dashboard.js @@ -226,7 +226,6 @@ $(function(){ ctx = chartInstance.ctx; ctx.font = Chart.helpers.fontString( Chart.defaults.global.defaultFontSize * 0.8, 'bold', Chart.defaults.global.defaultFontFamily); - ctx.textAlign = 'right'; ctx.textBaseline = 'middle'; this.data.datasets.forEach(function (dataset, i) { @@ -238,10 +237,12 @@ $(function(){ var gutter = (bar._model.height - (Chart.defaults.global.defaultFontSize * 0.8)) / 2; var textX; if (width_text + 2 * gutter > width_bar) { - textX = bar._model.x + 2 * gutter; + textX = bar._model.x + gutter; + ctx.textAlign = 'left'; ctx.fillStyle = bar._model.backgroundColor; } else { textX = bar._model.x - gutter; + ctx.textAlign = 'right'; ctx.fillStyle = '#fff'; } ctx.fillText( dataValue, textX, bar._model.y ); -- cgit v1.2.3