controller.js 1.23 KB
angular.module('focaModalGraficoCisternas')
    .controller('focaModalGraficoCisternasController', [
        '$scope',
        '$uibModalInstance',
        'filters',
        function($scope, $uibModalInstance, filters) {
            $scope.labels = [];
            $scope.series = ['Disponible', 'Cargado'];
            $scope.colores = ['#dcdcdc', '#007bff']
            $scope.data = [[],[]];
            $scope.options = {
                scales: {
                    xAxes: [{
                        stacked: true,
                    }],
                    yAxes: [{
                        stacked: true
                    }]
                },
                legend: {
                    display: true,
                    labels: {
                        fontColor: 'rgb(255, 99, 132)'
                    }
                }
            };

            $scope.cerrar = function() {
                $uibModalInstance.dismiss('cancel');
            };

            filters.cisternas.forEach(function(cisterna) {
                $scope.labels.push(cisterna.codigo);
                $scope.data[0].push(cisterna.capacidad - cisterna.estado.cantidad);
                $scope.data[1].push(cisterna.estado.cantidad);
            });
        }]
    );