'use strict'; angular.module('acufuel') .controller('analyticsController', ['$scope', 'analyticsService', function($scope, analyticsService) { // Sand Signika Overview without drill down -KD /* $scope.getAllRegionalPap = function() { $scope.flag=true; $scope.stateList = [{region:'Alabama',code:'AL'},{region:'Alaska',code:'AK'},{region:'Arizona',code:'AZ'},{region:'Arkansas',code:'AR'}, {region:'California',code:'CA' },{region:'Colorado',code:'CO'},{region:'Connecticut',code:'CT'},{region:'Delaware',code:'DE'}, {region:'Florida' ,code:'FL'},{region:'Georgia' ,code:'GA'},{region:'Hawaii' ,code:'HI'},{region:'Idaho' ,code:'ID'}, {region:'Illinois',code:'IL'},{region:'Indiana' ,code:'IN'},{region:'Iowa' ,code:'IA'},{region:'Kansas' ,code:'KS'}, {region:'Kentucky' ,code:'KY'},{region:'Louisiana' ,code:'LA'},{region:'Maine' ,code:'ME'},{region:'Maryland' ,code:'MD'}, {region:'Massachusetts' ,code:'MA'},{region:'Michigan' ,code:'MI'},{region:'Minnesota' ,code:'MN'}, {region:'Mississippi' ,code:'MS'},{region:'Missouri' ,code:'MO'},{region:'Montana',code:'MT'},{region:'Nebraska' ,code:'NE'}, {region:'Nevada' ,code:'NV'},{region:'New Hampshire' ,code:'NH'},{region:'New Jersey' ,code:'NJ'},{region:'New Mexico' ,code:'NM'}, {region:'New York' ,code:'NY'},{region:'North Carolina' ,code:'NC'},{region:'North Dakota' ,code:'ND'},{region:'Ohio' ,code:'OH'}, {region:'Oklahoma' ,code:'OK'},{region:'Oregon' ,code:'OR'},{region:'Pennsylvania',code:'PA'},{region:'Rhode Island' ,code:'RI'}, {region:'South Carolina' ,code:'SC'},{region:'South Dakota' ,code:'SD'},{region:'Tennessee' ,code:'TN'},{region:'Texas' ,code:'TX'}, {region:'Utah' ,code:'UT'},{region:'Vermont' ,code:'VT'},{region:'Virginia' ,code:'VA'},{region:'Washington' ,code:'WA'}, {region:'West Virginia' ,code:'WV'},{region:'Wisconsin' ,code:'WI'},{region:'Wyoming',code:'WY'}] analyticsService.getAllRPP().then(function(result) { for (var i = 0; i < $scope.stateList.length; i++) { for (var j = 0; j Failed loading ' + e.point.name); fail = setTimeout(function () { chart.hideLoading(); }, 1000); } }, 3000); // Show the spinner chart.showLoading(''); // Font Awesome spinner // Load the drilldown map $.getScript('https://code.highcharts.com/mapdata/' + mapKey + '.js', function () { var region = e.point.name; //called the get api region wise analyticsService.getRPP(region).then(function(result) { console.log("===region====",region,"====result====",result) data = Highcharts.geojson(Highcharts.maps[mapKey]); for (var i = 0; i < data.length; i++) { for (var j = 0; j0){return d[0]}}) //adjusting, 100% is 1.00, not 100 as it is in the data .y(function(d) { return d[1]}) .color(d3.scale.category10().range()) .useInteractiveGuideline(true) ; chart.xAxis .tickFormat(function(d) { return d3.time.format('%x')(new Date(d)) }); chart.yAxis .axisLabel("PaP / Retail Price") .axisLabelDistance(-5) .tickFormat(d3.format(',.2f')).showMaxMin(false); d3.select('#chart svg') .datum($scope.hfpRangeData) .transition().duration(500) .call(chart) ; nv.utils.windowResize(chart.update); return chart; }) } else if ($scope.hfp.fromDate != undefined && $scope.hfp.toDate != undefined) { $scope.fillForm = false; //from date format $scope.dat1 = $scope.hfp.fromDate; $scope.fd1 = $scope.dat1.split("/").reverse(); $scope.tmp = $scope.fd1[2]; $scope.fd1[2] = $scope.fd1[1]; $scope.fd1[1] = $scope.tmp; $scope.fd = $scope.fd1.join("-"); //to date format $scope.dat2 = $scope.hfp.toDate; $scope.td1 = $scope.dat2.split("/").reverse(); $scope.tmp1 = $scope.td1[2]; $scope.td1[2] = $scope.td1[1]; $scope.td1[1] = $scope.tmp1; $scope.td = $scope.td1.join("-") + " " + '23:59:59'; // console.log("===both dates==",$scope.td) analyticsService.getDRFHfpChart($scope.fd, $scope.td).then(function(result) { //console.log("===date range22===",result); for(var i=0; i0){return d[0] }}) //adjusting, 100% is 1.00, not 100 as it is in the data .y(function(d) { return d[1]}) .color(d3.scale.category10().range()) .useInteractiveGuideline(true) ; chart.xAxis .tickFormat(function(d) { return d3.time.format('%x')(new Date(d)) }); chart.yAxis .axisLabel("PaP / Retail Price") .axisLabelDistance(-5) .tickFormat(d3.format(',.2f')).showMaxMin(false); d3.select('#chart svg') .datum($scope.hfpRangeData) .transition().duration(500) .call(chart) ; nv.utils.windowResize(chart.update); return chart; }) } else { $scope.fillForm = true; } } /*Date Range Filter for Monthly fuel Sales*/ $scope.submitDate = function() { if ($scope.drf.fromDate === undefined) { $scope.fillForm = true; } else if ($scope.drf.fromDate != undefined && $scope.drf.toDate === undefined || $scope.drf.toDate === '') { $scope.fillForm = false; var today = new Date(); var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2); //from date format $scope.dat1 = $scope.drf.fromDate; $scope.fd1 = $scope.dat1.split("/").reverse(); $scope.tmp = $scope.fd1[2]; $scope.fd1[2] = $scope.fd1[1]; $scope.fd1[1] = $scope.tmp; $scope.fd = $scope.fd1.join("-"); analyticsService.getDRFChart($scope.fd, DefaultToDate).then(function(result) { $scope.datamfs = []; $scope.datamfs = result; }) analyticsService.orderCostAndCountByDate($scope.fd, DefaultToDate).then(function(result) { $scope.ordersCost = result.cost; $scope.ordersCount = result.count; }) } else if ($scope.drf.fromDate != undefined && $scope.drf.toDate != undefined) { $scope.fillForm = false; //from date format $scope.dat1 = $scope.drf.fromDate; $scope.fd1 = $scope.dat1.split("/").reverse(); $scope.tmp = $scope.fd1[2]; $scope.fd1[2] = $scope.fd1[1]; $scope.fd1[1] = $scope.tmp; $scope.fd = $scope.fd1.join("-"); $scope.dat2 = $scope.drf.toDate; $scope.td1 = $scope.dat2.split("/").reverse(); $scope.tmp1 = $scope.td1[2]; $scope.td1[2] = $scope.td1[1]; $scope.td1[1] = $scope.tmp1; $scope.td = $scope.td1.join("-"); analyticsService.getDRFChart($scope.fd, $scope.td).then(function(result) { $scope.datamfs = []; $scope.datamfs = result; }) analyticsService.orderCostAndCountByDate($scope.fd, $scope.td).then(function(result) { $scope.ordersCost = result.cost; $scope.ordersCount = result.count; }) } else { $scope.fillForm = true; } } /*Date Range Filter for Customer Sources*/ $scope.submitDateCs = function() { if ($scope.cs.fromDate === undefined) { $scope.fillForm = true; } else if ($scope.cs.fromDate != undefined && $scope.cs.toDate === undefined || $scope.cs.toDate === '') { $scope.fillForm = false; var today = new Date(); var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2); //from date format $scope.dat1 = $scope.cs.fromDate; $scope.fd1 = $scope.dat1.split("/").reverse(); $scope.tmp = $scope.fd1[2]; $scope.fd1[2] = $scope.fd1[1]; $scope.fd1[1] = $scope.tmp; $scope.fd = $scope.fd1.join("-"); analyticsService.getDRFCSChart($scope.fd, DefaultToDate).then(function(result) { $scope.csValues = result; $scope.optionscs = { chart: { type: 'pieChart', height: 500, // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"], x: function(d) { return d.key; }, y: function(d) { return d.y; }, showLabels: false, segmentShowStroke: false, animationSteps: 20, animationEasing: "linear", animateScale: true, duration: 500, labelThreshold: 0.01, labelSunbeamLayout: true, legend: { margin: { top: 5, right: 35, bottom: 5, left: 0 } } } }; $scope.datacs = $scope.csValues; }) } else if ($scope.cs.fromDate != undefined && $scope.cs.toDate != undefined) { $scope.fillForm = false; //from date format $scope.dat1 = $scope.cs.fromDate; $scope.fd1 = $scope.dat1.split("/").reverse(); $scope.tmp = $scope.fd1[2]; $scope.fd1[2] = $scope.fd1[1]; $scope.fd1[1] = $scope.tmp; $scope.fd = $scope.fd1.join("-"); //to date format $scope.dat2 = $scope.cs.toDate; $scope.td1 = $scope.dat2.split("/").reverse(); $scope.tmp1 = $scope.td1[2]; $scope.td1[2] = $scope.td1[1]; $scope.td1[1] = $scope.tmp1; $scope.td = $scope.td1.join("-"); analyticsService.getDRFCSChart($scope.fd, $scope.td).then(function(result) { $scope.csValues = result; $scope.optionscs = { chart: { type: 'pieChart', height: 500, // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"], x: function(d) { return d.key; }, y: function(d) { return d.y; }, showLabels: false, segmentShowStroke: false, animationSteps: 20, animationEasing: "linear", animateScale: true, duration: 500, labelThreshold: 0.01, labelSunbeamLayout: true, legend: { margin: { top: 5, right: 35, bottom: 5, left: 0 } } } }; $scope.datacs = $scope.csValues; }) } else { $scope.fillForm = true; } } }]);