Commit 42a7e1488df19ed35d599161031a2b9c52df3df9

Authored by Kuldeep Arora
1 parent 084c4873ba
Exists in master

hpf testing

app/partials/analytics/analytics.controller.js
1 'use strict'; 1 'use strict';
2 angular.module('acufuel') 2 angular.module('acufuel')
3 .controller('analyticsController', ['$scope', 'analyticsService', function($scope, analyticsService) { 3 .controller('analyticsController', ['$scope', 'analyticsService', function($scope, analyticsService) {
4 4
5 5
6 // Sand Signika Overview without drill down -KD 6 // Sand Signika Overview without drill down -KD
7 /* $scope.getAllRegionalPap = function() { 7 /* $scope.getAllRegionalPap = function() {
8 $scope.flag=true; 8 $scope.flag=true;
9 $scope.stateList = [{region:'Alabama',code:'AL'},{region:'Alaska',code:'AK'},{region:'Arizona',code:'AZ'},{region:'Arkansas',code:'AR'}, 9 $scope.stateList = [{region:'Alabama',code:'AL'},{region:'Alaska',code:'AK'},{region:'Arizona',code:'AZ'},{region:'Arkansas',code:'AR'},
10 {region:'California',code:'CA' },{region:'Colorado',code:'CO'},{region:'Connecticut',code:'CT'},{region:'Delaware',code:'DE'}, 10 {region:'California',code:'CA' },{region:'Colorado',code:'CO'},{region:'Connecticut',code:'CT'},{region:'Delaware',code:'DE'},
11 {region:'Florida' ,code:'FL'},{region:'Georgia' ,code:'GA'},{region:'Hawaii' ,code:'HI'},{region:'Idaho' ,code:'ID'}, 11 {region:'Florida' ,code:'FL'},{region:'Georgia' ,code:'GA'},{region:'Hawaii' ,code:'HI'},{region:'Idaho' ,code:'ID'},
12 {region:'Illinois',code:'IL'},{region:'Indiana' ,code:'IN'},{region:'Iowa' ,code:'IA'},{region:'Kansas' ,code:'KS'}, 12 {region:'Illinois',code:'IL'},{region:'Indiana' ,code:'IN'},{region:'Iowa' ,code:'IA'},{region:'Kansas' ,code:'KS'},
13 {region:'Kentucky' ,code:'KY'},{region:'Louisiana' ,code:'LA'},{region:'Maine' ,code:'ME'},{region:'Maryland' ,code:'MD'}, 13 {region:'Kentucky' ,code:'KY'},{region:'Louisiana' ,code:'LA'},{region:'Maine' ,code:'ME'},{region:'Maryland' ,code:'MD'},
14 {region:'Massachusetts' ,code:'MA'},{region:'Michigan' ,code:'MI'},{region:'Minnesota' ,code:'MN'}, 14 {region:'Massachusetts' ,code:'MA'},{region:'Michigan' ,code:'MI'},{region:'Minnesota' ,code:'MN'},
15 {region:'Mississippi' ,code:'MS'},{region:'Missouri' ,code:'MO'},{region:'Montana',code:'MT'},{region:'Nebraska' ,code:'NE'}, 15 {region:'Mississippi' ,code:'MS'},{region:'Missouri' ,code:'MO'},{region:'Montana',code:'MT'},{region:'Nebraska' ,code:'NE'},
16 {region:'Nevada' ,code:'NV'},{region:'New Hampshire' ,code:'NH'},{region:'New Jersey' ,code:'NJ'},{region:'New Mexico' ,code:'NM'}, 16 {region:'Nevada' ,code:'NV'},{region:'New Hampshire' ,code:'NH'},{region:'New Jersey' ,code:'NJ'},{region:'New Mexico' ,code:'NM'},
17 {region:'New York' ,code:'NY'},{region:'North Carolina' ,code:'NC'},{region:'North Dakota' ,code:'ND'},{region:'Ohio' ,code:'OH'}, 17 {region:'New York' ,code:'NY'},{region:'North Carolina' ,code:'NC'},{region:'North Dakota' ,code:'ND'},{region:'Ohio' ,code:'OH'},
18 {region:'Oklahoma' ,code:'OK'},{region:'Oregon' ,code:'OR'},{region:'Pennsylvania',code:'PA'},{region:'Rhode Island' ,code:'RI'}, 18 {region:'Oklahoma' ,code:'OK'},{region:'Oregon' ,code:'OR'},{region:'Pennsylvania',code:'PA'},{region:'Rhode Island' ,code:'RI'},
19 {region:'South Carolina' ,code:'SC'},{region:'South Dakota' ,code:'SD'},{region:'Tennessee' ,code:'TN'},{region:'Texas' ,code:'TX'}, 19 {region:'South Carolina' ,code:'SC'},{region:'South Dakota' ,code:'SD'},{region:'Tennessee' ,code:'TN'},{region:'Texas' ,code:'TX'},
20 {region:'Utah' ,code:'UT'},{region:'Vermont' ,code:'VT'},{region:'Virginia' ,code:'VA'},{region:'Washington' ,code:'WA'}, 20 {region:'Utah' ,code:'UT'},{region:'Vermont' ,code:'VT'},{region:'Virginia' ,code:'VA'},{region:'Washington' ,code:'WA'},
21 {region:'West Virginia' ,code:'WV'},{region:'Wisconsin' ,code:'WI'},{region:'Wyoming',code:'WY'}] 21 {region:'West Virginia' ,code:'WV'},{region:'Wisconsin' ,code:'WI'},{region:'Wyoming',code:'WY'}]
22 22
23 analyticsService.getAllRPP().then(function(result) { 23 analyticsService.getAllRPP().then(function(result) {
24 for (var i = 0; i < $scope.stateList.length; i++) { 24 for (var i = 0; i < $scope.stateList.length; i++) {
25 for (var j = 0; j<result.length; j++){ 25 for (var j = 0; j<result.length; j++){
26 if ($scope.stateList[i].region === result[j].region) { 26 if ($scope.stateList[i].region === result[j].region) {
27 result[j].code = $scope.stateList[i].code; 27 result[j].code = $scope.stateList[i].code;
28 result[j].averagePAP = result[j].averagePAP.toFixed(2); 28 result[j].averagePAP = result[j].averagePAP.toFixed(2);
29 } 29 }
30 } 30 }
31 } 31 }
32 $scope.flag=false; 32 $scope.flag=false;
33 // Instantiate the map 33 // Instantiate the map
34 Highcharts.mapChart('regional-pap', { 34 Highcharts.mapChart('regional-pap', {
35 35
36 chart: { 36 chart: {
37 map: 'countries/us/us-all', 37 map: 'countries/us/us-all',
38 borderWidth: 1, 38 borderWidth: 1,
39 }, 39 },
40 40
41 title: { 41 title: {
42 text: 'Regional PAP' 42 text: 'Regional PAP'
43 }, 43 },
44 44
45 exporting: { 45 exporting: {
46 sourceWidth: 600, 46 sourceWidth: 600,
47 sourceHeight: 500 47 sourceHeight: 500
48 }, 48 },
49 49
50 legend: { 50 legend: {
51 layout: 'vertical', 51 layout: 'vertical',
52 borderWidth: 0, 52 borderWidth: 0,
53 backgroundColor: 'rgba(255,255,255,0.85)', 53 backgroundColor: 'rgba(255,255,255,0.85)',
54 floating: true, 54 floating: true,
55 width:'12px', 55 width:'12px',
56 height:'200px', 56 height:'200px',
57 verticalAlign: 'bottom', 57 verticalAlign: 'bottom',
58 y: 0, 58 y: 0,
59 x: -230, 59 x: -230,
60 }, 60 },
61 61
62 mapNavigation: { 62 mapNavigation: {
63 enabled: true 63 enabled: true
64 }, 64 },
65 65
66 colorAxis: { 66 colorAxis: {
67 min: 1, 67 min: 1,
68 type: 'logarithmic', 68 type: 'logarithmic',
69 minColor: '#2b908f', 69 minColor: '#2b908f',
70 maxColor: '#000022', 70 maxColor: '#000022',
71 stops: [ 71 stops: [
72 [0, '#EFEFFF'], 72 [0, '#EFEFFF'],
73 [5, '#f45b5b'], 73 [5, '#f45b5b'],
74 [10, 'rgb(117,0,0)'] 74 [10, 'rgb(117,0,0)']
75 ] 75 ]
76 }, 76 },
77 77
78 series: [{ 78 series: [{
79 animation: { 79 animation: {
80 duration: 1000 80 duration: 1000
81 }, 81 },
82 data: result, 82 data: result,
83 joinBy: ['postal-code', 'code'], 83 joinBy: ['postal-code', 'code'],
84 dataLabels: { 84 dataLabels: {
85 enabled: true, 85 enabled: true,
86 color: '#FFFFFF', 86 color: '#FFFFFF',
87 format: '{point.code}' 87 format: '{point.code}'
88 }, 88 },
89 name: 'Data' , 89 name: 'Data' ,
90 tooltip: { 90 tooltip: {
91 pointFormat: '{point.region} : {point.averagePAP}' 91 pointFormat: '{point.region} : {point.averagePAP}'
92 }, 92 },
93 }] 93 }]
94 }); 94 });
95 }) 95 })
96 } 96 }
97 97
98 $scope.getAllRegionalPap();*/ 98 $scope.getAllRegionalPap();*/
99 99
100 100
101 //Implemented drill down chart and Now used this on 07 Sep 2018 -KD 101 //Implemented drill down chart and Now used this on 07 Sep 2018 -KD
102 102
103 /* 103 /*
104 TODO: 104 TODO:
105 - Check data labels after drilling. Label rank? New positions? 105 - Check data labels after drilling. Label rank? New positions?
106 */ 106 */
107 $scope.getAllRegionalPapDrilldown = function() { 107 $scope.getAllRegionalPapDrilldown = function() {
108 $scope.flag=true;//for spinner 108 $scope.flag=true;//for spinner
109 var data = Highcharts.geojson(Highcharts.maps['countries/us/us-all']); 109 var data = Highcharts.geojson(Highcharts.maps['countries/us/us-all']);
110 var separators = Highcharts.geojson(Highcharts.maps['countries/us/us-all'], 'mapline'); 110 var separators = Highcharts.geojson(Highcharts.maps['countries/us/us-all'], 'mapline');
111 // Some responsiveness 111 // Some responsiveness
112 //var small = $('#container').width() < 400; 112 //var small = $('#container').width() < 400;
113 113
114 analyticsService.getAllRPP().then(function(result) { 114 analyticsService.getAllRPP().then(function(result) {
115 for (var i = 0; i < data.length; i++) { 115 for (var i = 0; i < data.length; i++) {
116 for (var j = 0; j<result.length; j++){ 116 for (var j = 0; j<result.length; j++){
117 if (data[i].name === result[j].region) { 117 if (data[i].name === result[j].region) {
118 118
119 data[i].value = result[j].averagePAP.toFixed(2); 119 data[i].value = result[j].averagePAP.toFixed(2);
120 120
121 } 121 }
122 } 122 }
123 123
124 } 124 }
125 125
126 $.each(data, function (i) { 126 $.each(data, function (i) {
127 this.drilldown = this.properties['hc-key']; 127 this.drilldown = this.properties['hc-key'];
128 this.value = this.value; 128 this.value = this.value;
129 }); 129 });
130 130
131 $scope.flag=false; 131 $scope.flag=false;
132 // Instantiate the map 132 // Instantiate the map
133 Highcharts.mapChart('container', { 133 Highcharts.mapChart('container', {
134 chart: { 134 chart: {
135 events: { 135 events: {
136 drilldown: function (e) { 136 drilldown: function (e) {
137 if (!e.seriesOptions) { 137 if (!e.seriesOptions) {
138 var chart = this, 138 var chart = this,
139 mapKey = 'countries/us/' + e.point.drilldown + '-all', 139 mapKey = 'countries/us/' + e.point.drilldown + '-all',
140 140
141 // Handle error, the timeout is cleared on success 141 // Handle error, the timeout is cleared on success
142 fail = setTimeout(function () { 142 fail = setTimeout(function () {
143 if (!Highcharts.maps[mapKey]) { 143 if (!Highcharts.maps[mapKey]) {
144 chart.showLoading('<i class="icon-frown"></i> Failed loading ' + e.point.name); 144 chart.showLoading('<i class="icon-frown"></i> Failed loading ' + e.point.name);
145 fail = setTimeout(function () { 145 fail = setTimeout(function () {
146 chart.hideLoading(); 146 chart.hideLoading();
147 }, 1000); 147 }, 1000);
148 } 148 }
149 }, 3000); 149 }, 3000);
150 150
151 // Show the spinner 151 // Show the spinner
152 chart.showLoading('<i class="icon-spinner icon-spin icon-3x"></i>'); // Font Awesome spinner 152 chart.showLoading('<i class="icon-spinner icon-spin icon-3x"></i>'); // Font Awesome spinner
153 153
154 // Load the drilldown map 154 // Load the drilldown map
155 $.getScript('https://code.highcharts.com/mapdata/' + mapKey + '.js', function () { 155 $.getScript('https://code.highcharts.com/mapdata/' + mapKey + '.js', function () {
156 156
157 var region = e.point.name; 157 var region = e.point.name;
158 //called the get api region wise 158 //called the get api region wise
159 analyticsService.getRPP(region).then(function(result) { 159 analyticsService.getRPP(region).then(function(result) {
160 160
161 data = Highcharts.geojson(Highcharts.maps[mapKey]); 161 data = Highcharts.geojson(Highcharts.maps[mapKey]);
162 162
163 for (var i = 0; i < data.length; i++) { 163 for (var i = 0; i < data.length; i++) {
164 for (var j = 0; j<result.length; j++){ 164 for (var j = 0; j<result.length; j++){
165 165
166 //delete the County word from api result to match with map data 166 //delete the County word from api result to match with map data
167 result[j].region = result[j].region.replace("County",""); 167 result[j].region = result[j].region.replace("County","");
168 168
169 if (data[i].name.trim() === result[j].region.trim()) { 169 if (data[i].name.trim() === result[j].region.trim()) {
170 170
171 data[i].value = result[j].averagePAP.toFixed(2); 171 data[i].value = result[j].averagePAP.toFixed(2);
172 172
173 } 173 }
174 } 174 }
175 175
176 } 176 }
177 }) 177 })
178 178
179 // Set a non-random bogus value 179 // Set a non-random bogus value
180 180
181 $.each(data, function (i) { 181 $.each(data, function (i) {
182 this.value = this.value; 182 this.value = this.value;
183 }); 183 });
184 184
185 // Hide loading and add series 185 // Hide loading and add series
186 chart.hideLoading(); 186 chart.hideLoading();
187 clearTimeout(fail); 187 clearTimeout(fail);
188 chart.addSeriesAsDrilldown(e.point, { 188 chart.addSeriesAsDrilldown(e.point, {
189 name: e.point.name, 189 name: e.point.name,
190 data: data, 190 data: data,
191 dataLabels: { 191 dataLabels: {
192 enabled: true, 192 enabled: true,
193 format: '{point.name}' 193 format: '{point.name}'
194 } 194 }
195 }); 195 });
196 }); 196 });
197 } 197 }
198 198
199 this.setTitle(null, { text: e.point.name }); 199 this.setTitle(null, { text: e.point.name });
200 }, 200 },
201 drillup: function () { 201 drillup: function () {
202 this.setTitle(null, { text: '' }); 202 this.setTitle(null, { text: '' });
203 } 203 }
204 } 204 }
205 }, 205 },
206 206
207 title: { 207 title: {
208 text: 'USA Map-Drilldown for Regional Pricing' 208 text: 'USA Map-Drilldown for Regional Pricing'
209 }, 209 },
210 210
211 subtitle: { 211 subtitle: {
212 text: '', 212 text: '',
213 floating: true, 213 floating: true,
214 align: 'right', 214 align: 'right',
215 y: 50, 215 y: 50,
216 style: { 216 style: {
217 fontSize: '16px' 217 fontSize: '16px'
218 } 218 }
219 }, 219 },
220 220
221 /* legend: small ? {} : { 221 /* legend: small ? {} : {
222 layout: 'vertical', 222 layout: 'vertical',
223 align: 'right', 223 align: 'right',
224 verticalAlign: 'middle' 224 verticalAlign: 'middle'
225 }, 225 },
226 226
227 colorAxis: { 227 colorAxis: {
228 min: 0, 228 min: 0,
229 minColor: '#E6E7E8', 229 minColor: '#E6E7E8',
230 maxColor: '#005645' 230 maxColor: '#005645'
231 },*/ 231 },*/
232 232
233 mapNavigation: { 233 mapNavigation: {
234 enabled: true, 234 enabled: true,
235 buttonOptions: { 235 buttonOptions: {
236 verticalAlign: 'bottom' 236 verticalAlign: 'bottom'
237 } 237 }
238 }, 238 },
239 239
240 plotOptions: { 240 plotOptions: {
241 map: { 241 map: {
242 states: { 242 states: {
243 hover: { 243 hover: {
244 color: '#EEDD66' 244 color: '#EEDD66'
245 } 245 }
246 } 246 }
247 } 247 }
248 }, 248 },
249 249
250 series: [{ 250 series: [{
251 data: data, 251 data: data,
252 name: 'USA', 252 name: 'USA',
253 dataLabels: { 253 dataLabels: {
254 enabled: true, 254 enabled: true,
255 format: '{point.properties.postal-code}' 255 format: '{point.properties.postal-code}'
256 } 256 }
257 }, { 257 }, {
258 type: 'mapline', 258 type: 'mapline',
259 data: separators, 259 data: separators,
260 color: 'silver', 260 color: 'silver',
261 enableMouseTracking: false, 261 enableMouseTracking: false,
262 animation: { 262 animation: {
263 duration: 500 263 duration: 500
264 } 264 }
265 }], 265 }],
266 266
267 drilldown: { 267 drilldown: {
268 activeDataLabelStyle: { 268 activeDataLabelStyle: {
269 color: '#FFFFFF', 269 color: '#FFFFFF',
270 textDecoration: 'none', 270 textDecoration: 'none',
271 textOutline: '1px #000000' 271 textOutline: '1px #000000'
272 }, 272 },
273 drillUpButton: { 273 drillUpButton: {
274 relativeTo: 'spacingBox', 274 relativeTo: 'spacingBox',
275 position: { 275 position: {
276 x: 0, 276 x: 0,
277 y: 60 277 y: 60
278 } 278 }
279 } 279 }
280 } 280 }
281 }); 281 });
282 }) 282 })
283 } 283 }
284 284
285 $scope.getAllRegionalPapDrilldown(); 285 $scope.getAllRegionalPapDrilldown();
286 286
287 287
288 /*$(document).ready(function() { 288 /*$(document).ready(function() {
289 $(function() { 289 $(function() {
290 jQuery('#map').vectorMap({ 290 jQuery('#map').vectorMap({
291 map: 'us_lcc', 291 map: 'us_lcc',
292 backgroundColor: '#ffce99', 292 backgroundColor: '#ffce99',
293 color: '#dfdfdd', 293 color: '#dfdfdd',
294 hoverOpacity: 0, 294 hoverOpacity: 0,
295 selectedColor: '#5f8b98', 295 selectedColor: '#5f8b98',
296 hoverColor: '#5f8b98', 296 hoverColor: '#5f8b98',
297 enableZoom: true, 297 enableZoom: true,
298 showTooltip: true, 298 showTooltip: true,
299 scaleColors: ['#dfdfdd'], 299 scaleColors: ['#dfdfdd'],
300 //values: sample_data 300 //values: sample_data
301 onRegionClick: function(event, code) { 301 onRegionClick: function(event, code) {
302 var map = $('#map').vectorMap('get', 'mapObject'); 302 var map = $('#map').vectorMap('get', 'mapObject');
303 var name = map.getRegionName(code); 303 var name = map.getRegionName(code);
304 getRegionPap(name); 304 getRegionPap(name);
305 }, 305 },
306 normalizeFunction: 'polynomial' 306 normalizeFunction: 'polynomial'
307 }); 307 });
308 }); 308 });
309 }) 309 })
310 310
311 311
312 312
313 function getRegionPap(code) { 313 function getRegionPap(code) {
314 $scope.showLoader = true; 314 $scope.showLoader = true;
315 analyticsService.getRPP(code).then(function(result) { 315 analyticsService.getRPP(code).then(function(result) {
316 $scope.rppData = result; 316 $scope.rppData = result;
317 $scope.showLoader = false; 317 $scope.showLoader = false;
318 $('#popup1').css('display', 'block'); 318 $('#popup1').css('display', 'block');
319 }) 319 })
320 }*/ 320 }*/
321 321
322 322
323 $scope.cancelStatus = function() { 323 $scope.cancelStatus = function() {
324 $('#popup1').css('display', 'none'); 324 $('#popup1').css('display', 'none');
325 } 325 }
326 $scope.ordersCost = 0; 326 $scope.ordersCost = 0;
327 $scope.ordersCount = 0; 327 $scope.ordersCount = 0;
328 328
329 $scope.orderCostAndCount = function() { 329 $scope.orderCostAndCount = function() {
330 analyticsService.orderCostAndCount().then(function(result) { 330 analyticsService.orderCostAndCount().then(function(result) {
331 $scope.ordersCost = result.cost; 331 $scope.ordersCost = result.cost;
332 $scope.ordersCount = result.count; 332 $scope.ordersCount = result.count;
333 }) 333 })
334 } 334 }
335 335
336 $scope.drf = {}; 336 $scope.drf = {};
337 $scope.hfp = {}; 337 $scope.hfp = {};
338 $scope.cs = {}; 338 $scope.cs = {};
339 $scope.mfsValues = []; 339 $scope.mfsValues = [];
340 $scope.msfarray = []; 340 $scope.msfarray = [];
341 $scope.getMFS = function() { 341 $scope.getMFS = function() {
342 //var makeId = makeId; 342 //var makeId = makeId;
343 analyticsService.getMFS().then(function(result) { 343 analyticsService.getMFS().then(function(result) {
344 $scope.mfsValues = result; 344 $scope.mfsValues = result;
345 $scope.optionsmfs = { 345 $scope.optionsmfs = {
346 chart: { 346 chart: {
347 type: 'multiBarChart', 347 type: 'multiBarChart',
348 height: 450, 348 height: 450,
349 margin: { 349 margin: {
350 top: 45, 350 top: 45,
351 right: 20, 351 right: 20,
352 bottom: 45, 352 bottom: 45,
353 left: 45 353 left: 45
354 }, 354 },
355 clipEdge: true, 355 clipEdge: true,
356 //staggerLabels: true, 356 //staggerLabels: true,
357 duration: 500, 357 duration: 500,
358 stacked: false, 358 stacked: false,
359 color: ["#FEDFC3", "#990000", "#000099", "#009900"], 359 color: ["#FEDFC3", "#990000", "#000099", "#009900"],
360 xAxis: { 360 xAxis: {
361 axisLabel: 'Months', 361 axisLabel: 'Months',
362 showMaxMin: false, 362 showMaxMin: false,
363 }, 363 },
364 yAxis: { 364 yAxis: {
365 axisLabel: 'Orders', 365 axisLabel: 'Orders',
366 axisLabelDistance: -20, 366 axisLabelDistance: -20,
367 tickFormat: function(d) { 367 tickFormat: function(d) {
368 return d3.format(',.1f')(d); 368 return d3.format(',.1f')(d);
369 } 369 }
370 } 370 }
371 } 371 }
372 }; 372 };
373 $scope.datamfs = $scope.mfsValues; 373 $scope.datamfs = $scope.mfsValues;
374 }) 374 })
375 } 375 }
376 376
377 $scope.orderCostAndCount(); 377 $scope.orderCostAndCount();
378 $scope.getMFS(); 378 $scope.getMFS();
379 $scope.csValues = []; 379 $scope.csValues = [];
380 $scope.getCS = function() { 380 $scope.getCS = function() {
381 //var makeId = makeId; 381 //var makeId = makeId;
382 analyticsService.getCS().then(function(result) { 382 analyticsService.getCS().then(function(result) {
383 $scope.csValues = result; 383 $scope.csValues = result;
384 $scope.optionscs = { 384 $scope.optionscs = {
385 chart: { 385 chart: {
386 type: 'pieChart', 386 type: 'pieChart',
387 height: 500, 387 height: 500,
388 // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"], 388 // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"],
389 x: function(d) { 389 x: function(d) {
390 return d.key; 390 return d.key;
391 }, 391 },
392 y: function(d) { 392 y: function(d) {
393 return d.y; 393 return d.y;
394 }, 394 },
395 showLabels: false, 395 showLabels: false,
396 segmentShowStroke: false, 396 segmentShowStroke: false,
397 animationSteps: 20, 397 animationSteps: 20,
398 animationEasing: "linear", 398 animationEasing: "linear",
399 animateScale: true, 399 animateScale: true,
400 duration: 500, 400 duration: 500,
401 labelThreshold: 0.01, 401 labelThreshold: 0.01,
402 labelSunbeamLayout: true, 402 labelSunbeamLayout: true,
403 legend: { 403 legend: {
404 margin: { 404 margin: {
405 top: 5, 405 top: 5,
406 right: 35, 406 right: 35,
407 bottom: 5, 407 bottom: 5,
408 left: 0 408 left: 0
409 } 409 }
410 } 410 }
411 } 411 }
412 }; 412 };
413 $scope.datacs = $scope.csValues; 413 $scope.datacs = $scope.csValues;
414 }) 414 })
415 } 415 }
416 416
417 $scope.getCS(); 417 $scope.getCS();
418 418
419 419
420 $scope.hfpValues = []; 420 $scope.hfpValues = [];
421 $scope.getHfpChartData = function() { 421 $scope.getHfpChartData = function() {
422 //var makeId = makeId; 422 //var makeId = makeId;
423 analyticsService.gethfpChart().then(function(result) { 423 analyticsService.gethfpChart().then(function(result) {
424 $scope.hfpValues = result; 424 $scope.hfpValues = result;
425 //console.log('---kd result--',$scope.hfpValues); 425 console.log('---kd result--',$scope.hfpValues);
426 426
427 /*Historic Fuel Price */ 427 /*Historic Fuel Price */
428 428
429 $scope.optionshfp = { 429 $scope.optionshfp = {
430 chart: { 430 chart: {
431 type: 'cumulativeLineChart', 431 type: 'cumulativeLineChart',
432 height: 450, 432 height: 450,
433 margin: { 433 margin: {
434 top: 40, 434 top: 40,
435 right: 20, 435 right: 20,
436 bottom: 50, 436 bottom: 50,
437 left: 65 437 left: 65
438 }, 438 },
439 x: function(d) { 439 x: function(d) {
440 return d[0]; 440 return d[0];
441 }, 441 },
442 y: function(d) { 442 y: function(d) {
443 return d[1] / 100 ; 443 return d[1] / 100 ;
444 }, 444 },
445 average: function(d) { 445 average: function(d) {
446 return d.mean / 100; 446 return d.mean / 100;
447 }, 447 },
448 448
449 color: ["#FEDFC3"], 449 color: ["#FEDFC3"],
450 duration: 300, 450 duration: 300,
451 useInteractiveGuideline: true, 451 useInteractiveGuideline: true,
452 clipVoronoi: false, 452 clipVoronoi: false,
453 453
454 xAxis: { 454 xAxis: {
455 axisLabel: '', 455 axisLabel: '',
456 456
457 tickFormat: function(d) { 457 tickFormat: function(d) {
458 return d3.time.format('%m/%d/%y')(new Date(d)) 458 return d3.time.format('%m/%d/%y')(new Date(d))
459 //return d3.time.format('%b \-%y')(new Date(d)) 459 //return d3.time.format('%b \-%y')(new Date(d))
460 }, 460 },
461 showMaxMin: false, 461 showMaxMin: false,
462 staggerLabels: true 462 staggerLabels: true
463 }, 463 },
464 464
465 yAxis: { 465 yAxis: {
466 axisLabel: 'PaP/Retail Price', 466 axisLabel: 'PaP/Retail Price',
467 467
468 tickFormat: function(d) { 468 tickFormat: function(d) {
469 //return d3.format('')(d).toFixed(2); 469 //return d3.format('')(d).toFixed(2);
470 return '$ '+d.toFixed(2) 470 return '$ '+d.toFixed(2)
471 }, 471 },
472 axisLabelDistance: 5 472 axisLabelDistance: 5
473 } 473 }
474 } 474 }
475 }; 475 };
476 $scope.datahfp = [{ 476 $scope.datahfp = [{
477 key: "Long", 477 key: "Long",
478 values: $scope.hfpValues, 478 values: $scope.hfpValues,
479 mean: 0 479 mean: 0
480 }]; 480 }];
481 481
482 }) 482 })
483 } 483 }
484 484
485 $scope.getHfpChartData(); 485 $scope.getHfpChartData();
486 486
487 487
488 /*Date Range Filter for Monthly fuel Sales*/ 488 /*Date Range Filter for Monthly fuel Sales*/
489 $scope.submitDate = function() { 489 $scope.submitDate = function() {
490 if ($scope.drf.fromDate === undefined) { 490 if ($scope.drf.fromDate === undefined) {
491 $scope.fillForm = true; 491 $scope.fillForm = true;
492 } else if ($scope.drf.fromDate != undefined && $scope.drf.toDate === undefined || $scope.drf.toDate === '') { 492 } else if ($scope.drf.fromDate != undefined && $scope.drf.toDate === undefined || $scope.drf.toDate === '') {
493 $scope.fillForm = false; 493 $scope.fillForm = false;
494 var today = new Date(); 494 var today = new Date();
495 var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2); 495 var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2);
496 //from date format 496 //from date format
497 $scope.dat1 = $scope.drf.fromDate; 497 $scope.dat1 = $scope.drf.fromDate;
498 $scope.fd1 = $scope.dat1.split("/").reverse(); 498 $scope.fd1 = $scope.dat1.split("/").reverse();
499 $scope.tmp = $scope.fd1[2]; 499 $scope.tmp = $scope.fd1[2];
500 $scope.fd1[2] = $scope.fd1[1]; 500 $scope.fd1[2] = $scope.fd1[1];
501 $scope.fd1[1] = $scope.tmp; 501 $scope.fd1[1] = $scope.tmp;
502 $scope.fd = $scope.fd1.join("-"); 502 $scope.fd = $scope.fd1.join("-");
503 analyticsService.getDRFChart($scope.fd, DefaultToDate).then(function(result) { 503 analyticsService.getDRFChart($scope.fd, DefaultToDate).then(function(result) {
504 $scope.datamfs = []; 504 $scope.datamfs = [];
505 $scope.datamfs = result; 505 $scope.datamfs = result;
506 }) 506 })
507 507
508 analyticsService.orderCostAndCountByDate($scope.fd, DefaultToDate).then(function(result) { 508 analyticsService.orderCostAndCountByDate($scope.fd, DefaultToDate).then(function(result) {
509 $scope.ordersCost = result.cost; 509 $scope.ordersCost = result.cost;
510 $scope.ordersCount = result.count; 510 $scope.ordersCount = result.count;
511 }) 511 })
512 } else if ($scope.drf.fromDate != undefined && $scope.drf.toDate != undefined) { 512 } else if ($scope.drf.fromDate != undefined && $scope.drf.toDate != undefined) {
513 $scope.fillForm = false; 513 $scope.fillForm = false;
514 //from date format 514 //from date format
515 $scope.dat1 = $scope.drf.fromDate; 515 $scope.dat1 = $scope.drf.fromDate;
516 $scope.fd1 = $scope.dat1.split("/").reverse(); 516 $scope.fd1 = $scope.dat1.split("/").reverse();
517 $scope.tmp = $scope.fd1[2]; 517 $scope.tmp = $scope.fd1[2];
518 $scope.fd1[2] = $scope.fd1[1]; 518 $scope.fd1[2] = $scope.fd1[1];
519 $scope.fd1[1] = $scope.tmp; 519 $scope.fd1[1] = $scope.tmp;
520 $scope.fd = $scope.fd1.join("-"); 520 $scope.fd = $scope.fd1.join("-");
521 $scope.dat2 = $scope.drf.toDate; 521 $scope.dat2 = $scope.drf.toDate;
522 $scope.td1 = $scope.dat2.split("/").reverse(); 522 $scope.td1 = $scope.dat2.split("/").reverse();
523 $scope.tmp1 = $scope.td1[2]; 523 $scope.tmp1 = $scope.td1[2];
524 $scope.td1[2] = $scope.td1[1]; 524 $scope.td1[2] = $scope.td1[1];
525 $scope.td1[1] = $scope.tmp1; 525 $scope.td1[1] = $scope.tmp1;
526 $scope.td = $scope.td1.join("-"); 526 $scope.td = $scope.td1.join("-");
527 527
528 analyticsService.getDRFChart($scope.fd, $scope.td).then(function(result) { 528 analyticsService.getDRFChart($scope.fd, $scope.td).then(function(result) {
529 $scope.datamfs = []; 529 $scope.datamfs = [];
530 $scope.datamfs = result; 530 $scope.datamfs = result;
531 }) 531 })
532 532
533 analyticsService.orderCostAndCountByDate($scope.fd, $scope.td).then(function(result) { 533 analyticsService.orderCostAndCountByDate($scope.fd, $scope.td).then(function(result) {
534 $scope.ordersCost = result.cost; 534 $scope.ordersCost = result.cost;
535 $scope.ordersCount = result.count; 535 $scope.ordersCount = result.count;
536 }) 536 })
537 537
538 } else { 538 } else {
539 $scope.fillForm = true; 539 $scope.fillForm = true;
540 } 540 }
541 541
542 542
543 } 543 }
544 544
545 /*Date Range Filter for Historic fuel Price*/ 545 /*Date Range Filter for Historic fuel Price*/
546 $scope.submitDateHfp = function() { 546 $scope.submitDateHfp = function() {
547 547
548 if ($scope.hfp.fromDate === undefined) { 548 if ($scope.hfp.fromDate === undefined) {
549 549
550 $scope.fillForm = true; 550 $scope.fillForm = true;
551 } else if ($scope.hfp.fromDate != undefined && $scope.hfp.toDate === undefined || $scope.hfp.toDate === '') { 551 } else if ($scope.hfp.fromDate != undefined && $scope.hfp.toDate === undefined || $scope.hfp.toDate === '') {
552 $scope.fillForm = false; 552 $scope.fillForm = false;
553 var today = new Date(); 553 var today = new Date();
554 var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2); 554 var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2);
555 //from date format 555 //from date format
556 $scope.dat1 = $scope.hfp.fromDate; 556 $scope.dat1 = $scope.hfp.fromDate;
557 $scope.fd1 = $scope.dat1.split("/").reverse(); 557 $scope.fd1 = $scope.dat1.split("/").reverse();
558 $scope.tmp = $scope.fd1[2]; 558 $scope.tmp = $scope.fd1[2];
559 $scope.fd1[2] = $scope.fd1[1]; 559 $scope.fd1[2] = $scope.fd1[1];
560 $scope.fd1[1] = $scope.tmp; 560 $scope.fd1[1] = $scope.tmp;
561 $scope.fd = $scope.fd1.join("-"); 561 $scope.fd = $scope.fd1.join("-");
562 analyticsService.getDRFHfpChart($scope.fd, DefaultToDate).then(function(result) { 562 analyticsService.getDRFHfpChart($scope.fd, DefaultToDate).then(function(result) {
563 $scope.hfpValues = result; 563 $scope.hfpValues = result;
564 $scope.optionshfp = { 564 $scope.optionshfp = {
565 chart: { 565 chart: {
566 type: 'cumulativeLineChart', 566 type: 'cumulativeLineChart',
567 height: 450, 567 height: 450,
568 margin: { 568 margin: {
569 top: 40, 569 top: 40,
570 right: 20, 570 right: 20,
571 bottom: 50, 571 bottom: 50,
572 left: 65 572 left: 65
573 }, 573 },
574 x: function(d) { 574 x: function(d) {
575 return d[0]; 575 return d[0];
576 }, 576 },
577 y: function(d) { 577 y: function(d) {
578 return d[1] / 100; 578 return d[1] / 100;
579 }, 579 },
580 average: function(d) { 580 average: function(d) {
581 return d.mean / 100; 581 return d.mean / 100;
582 }, 582 },
583 583
584 color: ["#FEDFC3"], 584 color: ["#FEDFC3"],
585 duration: 300, 585 duration: 300,
586 useInteractiveGuideline: true, 586 useInteractiveGuideline: true,
587 clipVoronoi: false, 587 clipVoronoi: false,
588 588
589 xAxis: { 589 xAxis: {
590 axisLabel: '', 590 axisLabel: '',
591 591
592 tickFormat: function(d) { 592 tickFormat: function(d) {
593 return d3.time.format('%d / %m / %y')(new Date(d)) 593 return d3.time.format('%d / %m / %y')(new Date(d))
594 // return d3.time.format('%b \-%y')(new Date(d)) 594 // return d3.time.format('%b \-%y')(new Date(d))
595 }, 595 },
596 showMaxMin: false, 596 showMaxMin: false,
597 staggerLabels: true 597 staggerLabels: true
598 }, 598 },
599 599
600 yAxis: { 600 yAxis: {
601 axisLabel: 'PaP/Retail Price', 601 axisLabel: 'PaP/Retail Price',
602 602
603 tickFormat: function(d) { 603 tickFormat: function(d) {
604 //return d3.format('')(d).toFixed(2); 604 //return d3.format('')(d).toFixed(2);
605 return '$ '+d.toFixed(2) 605 return '$ '+d.toFixed(2)
606 }, 606 },
607 axisLabelDistance: 5 607 axisLabelDistance: 5
608 } 608 }
609 } 609 }
610 }; 610 };
611 $scope.datahfp = [{ 611 $scope.datahfp = [{
612 key: "Long", 612 key: "Long",
613 values: $scope.hfpValues, 613 values: $scope.hfpValues,
614 mean: 0 614 mean: 0
615 }]; 615 }];
616 }) 616 })
617 617
618 618
619 } else if ($scope.hfp.fromDate != undefined && $scope.hfp.toDate != undefined) { 619 } else if ($scope.hfp.fromDate != undefined && $scope.hfp.toDate != undefined) {
620 $scope.fillForm = false; 620 $scope.fillForm = false;
621 //from date format 621 //from date format
622 $scope.dat1 = $scope.hfp.fromDate; 622 $scope.dat1 = $scope.hfp.fromDate;
623 $scope.fd1 = $scope.dat1.split("/").reverse(); 623 $scope.fd1 = $scope.dat1.split("/").reverse();
624 $scope.tmp = $scope.fd1[2]; 624 $scope.tmp = $scope.fd1[2];
625 $scope.fd1[2] = $scope.fd1[1]; 625 $scope.fd1[2] = $scope.fd1[1];
626 $scope.fd1[1] = $scope.tmp; 626 $scope.fd1[1] = $scope.tmp;
627 $scope.fd = $scope.fd1.join("-"); 627 $scope.fd = $scope.fd1.join("-");
628 //to date format 628 //to date format
629 $scope.dat2 = $scope.hfp.toDate; 629 $scope.dat2 = $scope.hfp.toDate;
630 $scope.td1 = $scope.dat2.split("/").reverse(); 630 $scope.td1 = $scope.dat2.split("/").reverse();
631 $scope.tmp1 = $scope.td1[2]; 631 $scope.tmp1 = $scope.td1[2];
632 $scope.td1[2] = $scope.td1[1]; 632 $scope.td1[2] = $scope.td1[1];
633 $scope.td1[1] = $scope.tmp1; 633 $scope.td1[1] = $scope.tmp1;
634 $scope.td = $scope.td1.join("-"); 634 $scope.td = $scope.td1.join("-");
635 635
636 analyticsService.getDRFHfpChart($scope.fd, $scope.td).then(function(result) { 636 analyticsService.getDRFHfpChart($scope.fd, $scope.td).then(function(result) {
637 console.log("===DRF HPF====",result)
637 $scope.hfpValues = result; 638 $scope.hfpValues = result;
638 $scope.optionshfp = { 639 $scope.optionshfp = {
639 chart: { 640 chart: {
640 type: 'cumulativeLineChart', 641 type: 'cumulativeLineChart',
641 height: 450, 642 height: 450,
642 margin: { 643 margin: {
643 top: 40, 644 top: 40,
644 right: 20, 645 right: 20,
645 bottom: 50, 646 bottom: 50,
646 left: 65 647 left: 65
647 }, 648 },
648 x: function(d) { 649 x: function(d) {
649 return d[0]; 650 return d[0];
650 }, 651 },
651 y: function(d) { 652 y: function(d) {
652 return d[1] / 100 ; 653 return d[1] / 100 ;
653 }, 654 },
654 average: function(d) { 655 average: function(d) {
655 return d.mean / 100; 656 return d.mean / 100;
656 }, 657 },
657 658
658 color: ["#FEDFC3"], 659 color: ["#FEDFC3"],
659 duration: 300, 660 duration: 300,
660 useInteractiveGuideline: true, 661 useInteractiveGuideline: true,
661 clipVoronoi: false, 662 clipVoronoi: false,
662 663
663 xAxis: { 664 xAxis: {
664 axisLabel: '', 665 axisLabel: '',
665 666
666 tickFormat: function(d) { 667 tickFormat: function(d) {
667 return d3.time.format('%d / %m / %y')(new Date(d)) 668 return d3.time.format('%d / %m / %y')(new Date(d))
668 //return d3.time.format('%b \-%y')(new Date(d)) 669 //return d3.time.format('%b \-%y')(new Date(d))
669 }, 670 },
670 showMaxMin: false, 671 showMaxMin: false,
671 staggerLabels: true 672 staggerLabels: true
672 }, 673 },
673 674
674 yAxis: { 675 yAxis: {
675 axisLabel: 'PaP/Retail Price', 676 axisLabel: 'PaP/Retail Price',
676 677
677 tickFormat: function(d) { 678 tickFormat: function(d) {
678 //return d3.format('')(d).toFixed(2); 679 //return d3.format('')(d).toFixed(2);
679 return '$ '+d.toFixed(2) 680 return '$ '+d.toFixed(2)
680 }, 681 },
681 axisLabelDistance: 5 682 axisLabelDistance: 5
682 } 683 }
683 } 684 }
684 }; 685 };
685 $scope.datahfp = [{ 686 $scope.datahfp = [{
686 key: "Long", 687 key: "Long",
687 values:$scope.hfpValues, 688 values:$scope.hfpValues,
688 mean: 0 689 mean: 0
689 }]; 690 }];
690 }) 691 })
691 692
692 } else { 693 } else {
693 $scope.fillForm = true; 694 $scope.fillForm = true;
694 } 695 }
695 696
696 697
697 } 698 }
698 699
699 /*Date Range Filter for Customer Sources*/ 700 /*Date Range Filter for Customer Sources*/
700 $scope.submitDateCs = function() { 701 $scope.submitDateCs = function() {
701 if ($scope.cs.fromDate === undefined) { 702 if ($scope.cs.fromDate === undefined) {
702 703
703 $scope.fillForm = true; 704 $scope.fillForm = true;
704 } else if ($scope.cs.fromDate != undefined && $scope.cs.toDate === undefined || $scope.cs.toDate === '') { 705 } else if ($scope.cs.fromDate != undefined && $scope.cs.toDate === undefined || $scope.cs.toDate === '') {
705 $scope.fillForm = false; 706 $scope.fillForm = false;
706 var today = new Date(); 707 var today = new Date();
707 var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2); 708 var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2);
708 //from date format 709 //from date format
709 $scope.dat1 = $scope.cs.fromDate; 710 $scope.dat1 = $scope.cs.fromDate;
710 $scope.fd1 = $scope.dat1.split("/").reverse(); 711 $scope.fd1 = $scope.dat1.split("/").reverse();
711 $scope.tmp = $scope.fd1[2]; 712 $scope.tmp = $scope.fd1[2];
712 $scope.fd1[2] = $scope.fd1[1]; 713 $scope.fd1[2] = $scope.fd1[1];
713 $scope.fd1[1] = $scope.tmp; 714 $scope.fd1[1] = $scope.tmp;
714 $scope.fd = $scope.fd1.join("-"); 715 $scope.fd = $scope.fd1.join("-");
715 analyticsService.getDRFCSChart($scope.fd, DefaultToDate).then(function(result) { 716 analyticsService.getDRFCSChart($scope.fd, DefaultToDate).then(function(result) {
716 $scope.csValues = result; 717 $scope.csValues = result;
717 $scope.optionscs = { 718 $scope.optionscs = {
718 chart: { 719 chart: {
719 type: 'pieChart', 720 type: 'pieChart',
720 height: 500, 721 height: 500,
721 // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"], 722 // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"],
722 x: function(d) { 723 x: function(d) {
723 return d.key; 724 return d.key;
724 }, 725 },
725 y: function(d) { 726 y: function(d) {
726 return d.y; 727 return d.y;
727 }, 728 },
728 showLabels: false, 729 showLabels: false,
729 segmentShowStroke: false, 730 segmentShowStroke: false,
730 animationSteps: 20, 731 animationSteps: 20,
731 animationEasing: "linear", 732 animationEasing: "linear",
732 animateScale: true, 733 animateScale: true,
733 duration: 500, 734 duration: 500,
734 labelThreshold: 0.01, 735 labelThreshold: 0.01,
735 labelSunbeamLayout: true, 736 labelSunbeamLayout: true,
736 legend: { 737 legend: {
737 margin: { 738 margin: {
738 top: 5, 739 top: 5,
739 right: 35, 740 right: 35,
740 bottom: 5, 741 bottom: 5,
741 left: 0 742 left: 0
742 } 743 }
743 } 744 }
744 } 745 }
745 }; 746 };
746 $scope.datacs = $scope.csValues; 747 $scope.datacs = $scope.csValues;
747 }) 748 })
748 749
749 750
750 } else if ($scope.cs.fromDate != undefined && $scope.cs.toDate != undefined) { 751 } else if ($scope.cs.fromDate != undefined && $scope.cs.toDate != undefined) {
751 $scope.fillForm = false; 752 $scope.fillForm = false;
752 //from date format 753 //from date format
753 $scope.dat1 = $scope.cs.fromDate; 754 $scope.dat1 = $scope.cs.fromDate;
754 $scope.fd1 = $scope.dat1.split("/").reverse(); 755 $scope.fd1 = $scope.dat1.split("/").reverse();
755 $scope.tmp = $scope.fd1[2]; 756 $scope.tmp = $scope.fd1[2];
756 $scope.fd1[2] = $scope.fd1[1]; 757 $scope.fd1[2] = $scope.fd1[1];
757 $scope.fd1[1] = $scope.tmp; 758 $scope.fd1[1] = $scope.tmp;
758 $scope.fd = $scope.fd1.join("-"); 759 $scope.fd = $scope.fd1.join("-");
759 //to date format 760 //to date format
760 $scope.dat2 = $scope.cs.toDate; 761 $scope.dat2 = $scope.cs.toDate;
761 $scope.td1 = $scope.dat2.split("/").reverse(); 762 $scope.td1 = $scope.dat2.split("/").reverse();
762 $scope.tmp1 = $scope.td1[2]; 763 $scope.tmp1 = $scope.td1[2];
763 $scope.td1[2] = $scope.td1[1]; 764 $scope.td1[2] = $scope.td1[1];
764 $scope.td1[1] = $scope.tmp1; 765 $scope.td1[1] = $scope.tmp1;
765 $scope.td = $scope.td1.join("-"); 766 $scope.td = $scope.td1.join("-");
766 767
767 analyticsService.getDRFCSChart($scope.fd, $scope.td).then(function(result) { 768 analyticsService.getDRFCSChart($scope.fd, $scope.td).then(function(result) {
768 $scope.csValues = result; 769 $scope.csValues = result;
769 $scope.optionscs = { 770 $scope.optionscs = {
770 chart: { 771 chart: {
771 type: 'pieChart', 772 type: 'pieChart',
772 height: 500, 773 height: 500,
773 // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"], 774 // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"],
774 x: function(d) { 775 x: function(d) {
775 return d.key; 776 return d.key;
776 }, 777 },
777 y: function(d) { 778 y: function(d) {
778 return d.y; 779 return d.y;
779 }, 780 },
780 showLabels: false, 781 showLabels: false,
781 segmentShowStroke: false, 782 segmentShowStroke: false,
782 animationSteps: 20, 783 animationSteps: 20,
783 animationEasing: "linear", 784 animationEasing: "linear",
784 animateScale: true, 785 animateScale: true,
785 duration: 500, 786 duration: 500,
786 labelThreshold: 0.01, 787 labelThreshold: 0.01,
787 labelSunbeamLayout: true, 788 labelSunbeamLayout: true,
788 legend: { 789 legend: {
789 margin: { 790 margin: {
790 top: 5, 791 top: 5,
791 right: 35, 792 right: 35,
792 bottom: 5, 793 bottom: 5,
793 left: 0 794 left: 0
794 } 795 }
795 } 796 }
796 } 797 }
797 }; 798 };
798 $scope.datacs = $scope.csValues; 799 $scope.datacs = $scope.csValues;
799 }) 800 })
800 801
801 } else { 802 } else {
802 $scope.fillForm = true; 803 $scope.fillForm = true;
803 } 804 }
804 805
805 806
806 } 807 }
807 808
808 809
809 }]); 810 }]);
app/partials/analytics/analytics.service.js
1 (function(){ 1 (function(){
2 'use strict'; 2 'use strict';
3 angular.module('acufuel') 3 angular.module('acufuel')
4 .service('analyticsService', ['$q', '$http', 'BASE_URL',analyticsService]); 4 .service('analyticsService', ['$q', '$http', 'BASE_URL',analyticsService]);
5 5
6 function analyticsService($q, $http, BASE_URL) { 6 function analyticsService($q, $http, BASE_URL) {
7 var temp = {}; 7 var temp = {};
8 8
9 9
10 this.getMFS = function(){ 10 this.getMFS = function(){
11 var deferred = $q.defer(); 11 var deferred = $q.defer();
12 $http({ 12 $http({
13 method : 'GET', 13 method : 'GET',
14 url : BASE_URL.url + '/fuelOrder/analytics' 14 url : BASE_URL.url + '/fuelOrder/analytics'
15 }) 15 })
16 .then(function (result){ 16 .then(function (result){
17 deferred.resolve(result.data); 17 deferred.resolve(result.data);
18 },function (result){ 18 },function (result){
19 console.log(result) 19 console.log(result)
20 deferred.resolve(result.data); 20 deferred.resolve(result.data);
21 }) 21 })
22 return deferred.promise; 22 return deferred.promise;
23 } 23 }
24 24
25 this.orderCostAndCount = function(){ 25 this.orderCostAndCount = function(){
26 var deferred = $q.defer(); 26 var deferred = $q.defer();
27 $http({ 27 $http({
28 method : 'GET', 28 method : 'GET',
29 // url : BASE_URL.url +'/fuelOrder/export/mfs' 29 // url : BASE_URL.url +'/fuelOrder/export/mfs'
30 url : BASE_URL.url + '/fuelOrder/orderCostAndCount' 30 url : BASE_URL.url + '/fuelOrder/orderCostAndCount'
31 }) 31 })
32 .then(function (result){ 32 .then(function (result){
33 deferred.resolve(result.data); 33 deferred.resolve(result.data);
34 },function (result){ 34 },function (result){
35 console.log(result) 35 console.log(result)
36 deferred.resolve(result.data); 36 deferred.resolve(result.data);
37 }) 37 })
38 return deferred.promise; 38 return deferred.promise;
39 } 39 }
40 40
41 41
42 42
43 this.getCS = function(){ 43 this.getCS = function(){
44 var deferred = $q.defer(); 44 var deferred = $q.defer();
45 $http({ 45 $http({
46 method : 'GET', 46 method : 'GET',
47 url : BASE_URL.url +'/user/sources' 47 url : BASE_URL.url +'/user/sources'
48 }) 48 })
49 .then(function (result){ 49 .then(function (result){
50 deferred.resolve(result.data); 50 deferred.resolve(result.data);
51 },function (result){ 51 },function (result){
52 console.log(result) 52 console.log(result)
53 deferred.resolve(result.data); 53 deferred.resolve(result.data);
54 }) 54 })
55 return deferred.promise; 55 return deferred.promise;
56 } 56 }
57 57
58 /* With region Code */ 58 /* With region Code */
59 this.getRPP = function(code){ 59 this.getRPP = function(code){
60 var deferred = $q.defer(); 60 var deferred = $q.defer();
61 $http({ 61 $http({
62 method : 'GET', 62 method : 'GET',
63 url : BASE_URL.url +'/fuelerlinx/getAircrafts/'+code 63 url : BASE_URL.url +'/fuelerlinx/getAircrafts/'+code
64 }) 64 })
65 .then(function (result){ 65 .then(function (result){
66 deferred.resolve(result.data); 66 deferred.resolve(result.data);
67 },function (result){ 67 },function (result){
68 console.log(result) 68 console.log(result)
69 deferred.resolve(result.data); 69 deferred.resolve(result.data);
70 }) 70 })
71 return deferred.promise; 71 return deferred.promise;
72 } 72 }
73 73
74 /* without region code */ 74 /* without region code */
75 this.getAllRPP = function(){ 75 this.getAllRPP = function(){
76 var deferred = $q.defer(); 76 var deferred = $q.defer();
77 $http({ 77 $http({
78 method : 'GET', 78 method : 'GET',
79 url : BASE_URL.url +'/fuelerlinx/getAllRegionalPap' 79 url : BASE_URL.url +'/fuelerlinx/getAllRegionalPap'
80 }) 80 })
81 .then(function (result){ 81 .then(function (result){
82 deferred.resolve(result.data); 82 deferred.resolve(result.data);
83 },function (result){ 83 },function (result){
84 console.log(result) 84 console.log(result)
85 deferred.resolve(result.data); 85 deferred.resolve(result.data);
86 }) 86 })
87 return deferred.promise; 87 return deferred.promise;
88 } 88 }
89 89
90 /*---date filter for Monthly fuel sales chart - dates are sending to the api */ 90 /*---date filter for Monthly fuel sales chart - dates are sending to the api */
91 this.getDRFChart = function(fd,td){ 91 this.getDRFChart = function(fd,td){
92 var deferred = $q.defer(); 92 var deferred = $q.defer();
93 $http({ 93 $http({
94 method : 'GET', 94 method : 'GET',
95 url : BASE_URL.url + '/fuelOrder/filterchart?fromDate='+fd+'&toDate='+td+'' 95 url : BASE_URL.url + '/fuelOrder/filterchart?fromDate='+fd+'&toDate='+td+''
96 }) 96 })
97 .then(function (result){ 97 .then(function (result){
98 deferred.resolve(result.data); 98 deferred.resolve(result.data);
99 },function (result){ 99 },function (result){
100 console.log(result) 100 console.log(result)
101 deferred.resolve(result.data); 101 deferred.resolve(result.data);
102 }) 102 })
103 return deferred.promise; 103 return deferred.promise;
104 } 104 }
105 105
106 106
107 this.orderCostAndCountByDate = function(fd,td){ 107 this.orderCostAndCountByDate = function(fd,td){
108 var deferred = $q.defer(); 108 var deferred = $q.defer();
109 $http({ 109 $http({
110 method : 'GET', 110 method : 'GET',
111 url : BASE_URL.url + '/fuelOrder/orderCostAndCountByDate?fromDate='+fd+'&toDate='+td+'' 111 url : BASE_URL.url + '/fuelOrder/orderCostAndCountByDate?fromDate='+fd+'&toDate='+td+''
112 }) 112 })
113 .then(function (result){ 113 .then(function (result){
114 deferred.resolve(result.data); 114 deferred.resolve(result.data);
115 },function (result){ 115 },function (result){
116 console.log(result) 116 console.log(result)
117 deferred.resolve(result.data); 117 deferred.resolve(result.data);
118 }) 118 })
119 return deferred.promise; 119 return deferred.promise;
120 } 120 }
121 121
122 /*---date filter for Historic Fuel price --- DRF--Date Range Filter */ 122 /*---date filter for Historic Fuel price --- DRF--Date Range Filter */
123 this.getDRFHfpChart = function(fd,td){ 123 this.getDRFHfpChart = function(fd,td){
124 var deferred = $q.defer(); 124 var deferred = $q.defer();
125 $http({ 125 $http({
126 method : 'GET', 126 method : 'GET',
127 url : BASE_URL.url + '/fuelOrder/hfp/filterchart?fromDate='+fd+'&toDate='+td+'' 127 url : BASE_URL.url + '/fuelOrder/hfp/filterchart?fromDate='+fd+'&toDate='+td+''
128 }) 128 })
129 .then(function (result){ 129 .then(function (result){
130 deferred.resolve(result.data); 130 deferred.resolve(result.data);
131 },function (result){ 131 },function (result){
132 console.log(result) 132 console.log(result)
133 deferred.resolve(result.data); 133 deferred.resolve(result.data);
134 }) 134 })
135 return deferred.promise; 135 return deferred.promise;
136 } 136 }
137 137
138 138
139 this.gethfpChart = function(fd,td){ 139 this.gethfpChart = function(){
140 var deferred = $q.defer(); 140 var deferred = $q.defer();
141 $http({ 141 $http({
142 method : 'GET', 142 method : 'GET',
143 url : BASE_URL.url + '/fuelOrder/hfp/' 143 url : BASE_URL.url + '/fuelOrder/hfp/'
144 }) 144 })
145 .then(function (result){ 145 .then(function (result){
146 deferred.resolve(result.data); 146 deferred.resolve(result.data);
147 },function (result){ 147 },function (result){
148 console.log(result) 148 console.log(result)
149 deferred.resolve(result.data); 149 deferred.resolve(result.data);
150 }) 150 })
151 return deferred.promise; 151 return deferred.promise;
152 } 152 }
153 153
154 /*---date filter for Customer Sources --- DRF--Date Range Filter */ 154 /*---date filter for Customer Sources --- DRF--Date Range Filter */
155 this.getDRFCSChart = function(fd,td){ 155 this.getDRFCSChart = function(fd,td){
156 var deferred = $q.defer(); 156 var deferred = $q.defer();
157 $http({ 157 $http({
158 method : 'GET', 158 method : 'GET',
159 url : BASE_URL.url + '/user/cs/filterchart?fromDate='+fd+'&toDate='+td+'' 159 url : BASE_URL.url + '/user/cs/filterchart?fromDate='+fd+'&toDate='+td+''
160 }) 160 })
161 .then(function (result){ 161 .then(function (result){
162 deferred.resolve(result.data); 162 deferred.resolve(result.data);
163 },function (result){ 163 },function (result){
164 console.log(result) 164 console.log(result)
165 deferred.resolve(result.data); 165 deferred.resolve(result.data);
166 }) 166 })
167 return deferred.promise; 167 return deferred.promise;
168 } 168 }
169 169
170 } 170 }
171 171
172 })(); 172 })();