diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2017-07-25 13:12:30 +0300 |
---|---|---|
committer | Tim Zallmann <tzallmann@gitlab.com> | 2017-07-27 16:03:04 +0300 |
commit | 84a3ab25fe9dd9002c8c47976d7f17fc2a897071 (patch) | |
tree | 19e195829b8d7ece2b452df1c58e8e0ce08705b3 /app/assets/javascripts/pipelines | |
parent | 395e34bd0fd32e6f8d8145f14d71ea3c1350b46f (diff) |
Moved Inline JS for Pipelines Charts + new Pipeline to dispatcher
Diffstat (limited to 'app/assets/javascripts/pipelines')
-rw-r--r-- | app/assets/javascripts/pipelines/pipelines_times.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/app/assets/javascripts/pipelines/pipelines_times.js b/app/assets/javascripts/pipelines/pipelines_times.js new file mode 100644 index 00000000000..b5e7a0e53d9 --- /dev/null +++ b/app/assets/javascripts/pipelines/pipelines_times.js @@ -0,0 +1,27 @@ +import Chart from 'vendor/Chart'; + +document.addEventListener('DOMContentLoaded', () => { + const chartData = JSON.parse(document.getElementById('pipelinesTimesChartsData').innerHTML); + const data = { + labels: chartData.labels, + datasets: [{ + fillColor: 'rgba(220,220,220,0.5)', + strokeColor: 'rgba(220,220,220,1)', + barStrokeWidth: 1, + barValueSpacing: 1, + barDatasetSpacing: 1, + data: chartData.values, + }], + }; + const ctx = $('#build_timesChart').get(0).getContext('2d'); + const options = { + scaleOverlay: true, + responsive: true, + maintainAspectRatio: false, + }; + if (window.innerWidth < 768) { + // Scale fonts if window width lower than 768px (iPad portrait) + options.scaleFontSize = 8; + } + new Chart(ctx).Bar(data, options); +}); |