diff options
author | Jason Dai <dai.xiaojun@gmail.com> | 2017-08-08 12:02:13 +0000 |
---|---|---|
committer | Clement Ho <clemmakesapps@gmail.com> | 2017-08-08 12:02:13 +0000 |
commit | 2b9a64a212e3bcd27c1335b22a857f4df6846254 (patch) | |
tree | 81d0c7b7a1e8fee76f8692168db8c0ec68309f7c /app/assets | |
parent | 2b781c782de19b99526a649df5595e4161a84dc7 (diff) | |
download | gitlab-ce-2b9a64a212e3bcd27c1335b22a857f4df6846254.tar.gz |
Fix bar chart does not display label at hour 0
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/graphs/graphs_charts.js | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/app/assets/javascripts/graphs/graphs_charts.js b/app/assets/javascripts/graphs/graphs_charts.js index 279ffef770f..ec6eab34989 100644 --- a/app/assets/javascripts/graphs/graphs_charts.js +++ b/app/assets/javascripts/graphs/graphs_charts.js @@ -1,4 +1,5 @@ import Chart from 'vendor/Chart'; +import _ from 'underscore'; document.addEventListener('DOMContentLoaded', () => { const projectChartData = JSON.parse(document.getElementById('projectChartData').innerHTML); @@ -27,28 +28,25 @@ document.addEventListener('DOMContentLoaded', () => { return generateChart(); }; - const chartData = (keys, values) => { - const data = { - labels: keys, - datasets: [{ - fillColor: 'rgba(220,220,220,0.5)', - strokeColor: 'rgba(220,220,220,1)', - barStrokeWidth: 1, - barValueSpacing: 1, - barDatasetSpacing: 1, - data: values, - }], - }; - return data; - }; - - const hourData = chartData(projectChartData.hour.keys, projectChartData.hour.values); + const chartData = data => ({ + labels: Object.keys(data), + datasets: [{ + fillColor: 'rgba(220,220,220,0.5)', + strokeColor: 'rgba(220,220,220,1)', + barStrokeWidth: 1, + barValueSpacing: 1, + barDatasetSpacing: 1, + data: _.values(data), + }], + }); + + const hourData = chartData(projectChartData.hour); responsiveChart($('#hour-chart'), hourData); - const dayData = chartData(projectChartData.weekDays.keys, projectChartData.weekDays.values); + const dayData = chartData(projectChartData.weekDays); responsiveChart($('#weekday-chart'), dayData); - const monthData = chartData(projectChartData.month.keys, projectChartData.month.values); + const monthData = chartData(projectChartData.month); responsiveChart($('#month-chart'), monthData); const data = projectChartData.languages; |