diff --git a/app/partials/analytics/analytics.controller.js b/app/partials/analytics/analytics.controller.js index ce2b833..7c886dc 100644 --- a/app/partials/analytics/analytics.controller.js +++ b/app/partials/analytics/analytics.controller.js @@ -383,6 +383,7 @@ angular.module('acufuel') $scope.getCS = function() { //var makeId = makeId; analyticsService.getCS().then(function(result) { + console.log("===customersupports===",result) $scope.csValues = result; $scope.optionscs = { chart: { @@ -418,124 +419,204 @@ angular.module('acufuel') } $scope.getCS(); + + + $scope.hfpValuesOne = {}; + $scope.hfpValuesOne.key = "JET-A Full Service"; + $scope.hfpValuesOne.values = []; + + $scope.hfpValuesTwo = {}; + $scope.hfpValuesTwo.key = "100LL Full Service"; + $scope.hfpValuesTwo.values = []; + + $scope.hfpFinalData = []; - - $scope.hfpValues = []; $scope.getHfpChartData = function() { - //var makeId = makeId; analyticsService.gethfpChart().then(function(result) { - $scope.hfpValues = result; - //console.log('---kd result--',$scope.hfpValues); - - /*Historic Fuel Price */ - - $scope.optionshfp = { - chart: { - type: 'cumulativeLineChart', - height: 450, - margin: { - top: 40, - right: 20, - bottom: 50, - left: 65 - }, - x: function(d) { - return d[0]; - }, - y: function(d) { - return d[1] / 100 ; - }, - average: function(d) { - return d.mean / 100; - }, - - color: ["#FEDFC3"], - duration: 300, - useInteractiveGuideline: true, - clipVoronoi: false, - - xAxis: { - axisLabel: '', - - tickFormat: function(d) { - return d3.time.format('%m/%d/%y')(new Date(d)) - //return d3.time.format('%b \-%y')(new Date(d)) - }, - showMaxMin: false, - staggerLabels: true - }, - - yAxis: { - axisLabel: 'PaP/Retail Price', - - tickFormat: function(d) { - //return d3.format('')(d).toFixed(2); - return '$ '+d.toFixed(2) - }, - axisLabelDistance: 5 + 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 if ($scope.drf.fromDate != undefined && $scope.drf.toDate != undefined) { + + + } else if ($scope.hfp.fromDate != undefined && $scope.hfp.toDate != undefined) { $scope.fillForm = false; //from date format - $scope.dat1 = $scope.drf.fromDate; + $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("-"); - $scope.dat2 = $scope.drf.toDate; + //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("-"); - 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; + 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 { @@ -545,151 +626,55 @@ angular.module('acufuel') } - /*Date Range Filter for Historic fuel Price*/ - $scope.submitDateHfp = function() { - - if ($scope.hfp.fromDate === undefined) { - + + /*Date Range Filter for Monthly fuel Sales*/ + $scope.submitDate = function() { + if ($scope.drf.fromDate === undefined) { $scope.fillForm = true; - } else if ($scope.hfp.fromDate != undefined && $scope.hfp.toDate === undefined || $scope.hfp.toDate === '') { + } 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.hfp.fromDate; + $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.getDRFHfpChart($scope.fd, DefaultToDate).then(function(result) { - $scope.hfpValues = result; - $scope.optionshfp = { - chart: { - type: 'cumulativeLineChart', - height: 450, - margin: { - top: 40, - right: 20, - bottom: 50, - left: 65 - }, - x: function(d) { - return d[0]; - }, - y: function(d) { - return d[1] / 100; - }, - average: function(d) { - return d.mean / 100; - }, - - color: ["#FEDFC3"], - duration: 300, - useInteractiveGuideline: true, - clipVoronoi: false, - - xAxis: { - axisLabel: '', - - tickFormat: function(d) { - return d3.time.format('%d / %m / %y')(new Date(d)) - // return d3.time.format('%b \-%y')(new Date(d)) - }, - showMaxMin: false, - staggerLabels: true - }, - - yAxis: { - axisLabel: 'PaP/Retail Price', - - tickFormat: function(d) { - //return d3.format('')(d).toFixed(2); - return '$ '+d.toFixed(2) - }, - axisLabelDistance: 5 - } - } - }; - $scope.datahfp = [{ - key: "Long", - values: $scope.hfpValues, - mean: 0 - }]; + analyticsService.getDRFChart($scope.fd, DefaultToDate).then(function(result) { + $scope.datamfs = []; + $scope.datamfs = result; }) - - - } else if ($scope.hfp.fromDate != undefined && $scope.hfp.toDate != undefined) { + + 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.hfp.fromDate; + $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("-"); - //to date format - $scope.dat2 = $scope.hfp.toDate; + $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.getDRFHfpChart($scope.fd, $scope.td).then(function(result) { - $scope.hfpValues = result; - $scope.optionshfp = { - chart: { - type: 'cumulativeLineChart', - height: 450, - margin: { - top: 40, - right: 20, - bottom: 50, - left: 65 - }, - x: function(d) { - return d[0]; - }, - y: function(d) { - return d[1] / 100 ; - }, - average: function(d) { - return d.mean / 100; - }, - - color: ["#FEDFC3"], - duration: 300, - useInteractiveGuideline: true, - clipVoronoi: false, - - xAxis: { - axisLabel: '', - - tickFormat: function(d) { - return d3.time.format('%d / %m / %y')(new Date(d)) - //return d3.time.format('%b \-%y')(new Date(d)) - }, - showMaxMin: false, - staggerLabels: true - }, - - yAxis: { - axisLabel: 'PaP/Retail Price', - - tickFormat: function(d) { - //return d3.format('')(d).toFixed(2); - return '$ '+d.toFixed(2) - }, - axisLabelDistance: 5 - } - } - }; - $scope.datahfp = [{ - key: "Long", - values:$scope.hfpValues, - mean: 0 - }]; + 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 { @@ -699,6 +684,9 @@ angular.module('acufuel') } + + + /*Date Range Filter for Customer Sources*/ $scope.submitDateCs = function() { if ($scope.cs.fromDate === undefined) { diff --git a/app/partials/analytics/analytics.html b/app/partials/analytics/analytics.html index d6d82f6..74c3686 100644 --- a/app/partials/analytics/analytics.html +++ b/app/partials/analytics/analytics.html @@ -33,6 +33,9 @@ border-color: grey; } + #chart svg { + height: 400px; + } @import 'https://code.highcharts.com/css/themes/sand-signika.css'; @@ -88,9 +91,10 @@

Historic Fuel Pricing

-
- +
+ +