1 |
0bb62f35
|
kohlicekjan
|
angular.module('pvpk')
|
2 |
|
|
.component('graphNumberVehicles', {
|
3 |
|
|
template: '<div><canvas id="graphNumberVehicles" class="graph-size mb-5"></canvas></div>',
|
4 |
|
|
controller: ['$rootScope', '$scope', function ($rootScope, $scope) {
|
5 |
|
|
$rootScope.$on('renderGraphNumberVehicles', function (event, args) {
|
6 |
|
|
var canvasGraphNumberVehicles = document.getElementById('graphNumberVehicles').getContext('2d')
|
7 |
|
|
|
8 |
|
|
if ($scope.graphNumberVehicles) { $scope.graphNumberVehicles.destroy() }
|
9 |
|
|
|
10 |
|
|
$scope.graphNumberVehicles = new Chart(canvasGraphNumberVehicles, {
|
11 |
|
|
type: 'bar',
|
12 |
|
|
data: args.data,
|
13 |
|
|
options: {
|
14 |
|
|
responsive: true,
|
15 |
|
|
onResize: function (chart, size) {
|
16 |
|
|
chart.options.legend.display = size.height > 240
|
17 |
|
|
chart.update()
|
18 |
|
|
},
|
19 |
|
|
legend: {
|
20 |
|
|
position: 'bottom'
|
21 |
|
|
},
|
22 |
|
|
scales: {
|
23 |
|
|
xAxes: [{
|
24 |
|
|
stacked: true,
|
25 |
|
|
ticks: {
|
26 |
|
|
autoSkip: true,
|
27 |
|
|
maxTicksLimit: 15
|
28 |
|
|
}
|
29 |
|
|
}],
|
30 |
|
|
yAxes: [{
|
31 |
|
|
scaleLabel: {
|
32 |
|
|
display: true,
|
33 |
|
|
labelString: 'počet vozidel'
|
34 |
|
|
},
|
35 |
|
|
stacked: true
|
36 |
|
|
}]
|
37 |
|
|
},
|
38 |
|
|
tooltips: {
|
39 |
|
|
mode: 'index',
|
40 |
|
|
intersect: false
|
41 |
|
|
}
|
42 |
|
|
}
|
43 |
|
|
})
|
44 |
|
|
})
|
45 |
|
|
}]
|
46 |
|
|
})
|