Commit de02ae98669759c0da26a5b059730976faca9197

Authored by Kuldeep Arora
1 parent f6e8207e44
Exists in master

minor

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 $(document).ready(function() { 5 $(document).ready(function() {
6 $(function() { 6 $(function() {
7 jQuery('#map').vectorMap({ 7 jQuery('#map').vectorMap({
8 map: 'us_lcc', 8 map: 'us_lcc',
9 backgroundColor: '#ffce99', 9 backgroundColor: '#ffce99',
10 color: '#dfdfdd', 10 color: '#dfdfdd',
11 hoverOpacity: 0, 11 hoverOpacity: 0,
12 selectedColor: '#5f8b98', 12 selectedColor: '#5f8b98',
13 hoverColor: '#5f8b98', 13 hoverColor: '#5f8b98',
14 enableZoom: true, 14 enableZoom: true,
15 showTooltip: true, 15 showTooltip: true,
16 scaleColors: ['#dfdfdd'], 16 scaleColors: ['#dfdfdd'],
17 //values: sample_data 17 //values: sample_data
18 onRegionClick: function(event, code) { 18 onRegionClick: function(event, code) {
19 var map = $('#map').vectorMap('get', 'mapObject'); 19 var map = $('#map').vectorMap('get', 'mapObject');
20 var name = map.getRegionName(code); 20 var name = map.getRegionName(code);
21 getRegionPap(name); 21 getRegionPap(name);
22 }, 22 },
23 normalizeFunction: 'polynomial' 23 normalizeFunction: 'polynomial'
24 }); 24 });
25 }); 25 });
26 }) 26 })
27 27
28 function getRegionPap(code) { 28 function getRegionPap(code) {
29 $scope.showLoader = true; 29 $scope.showLoader = true;
30 analyticsService.getRPP(code).then(function(result) { 30 analyticsService.getRPP(code).then(function(result) {
31 $scope.rppData = result; 31 $scope.rppData = result;
32 $scope.showLoader = false; 32 $scope.showLoader = false;
33 $('#popup1').css('display', 'block'); 33 $('#popup1').css('display', 'block');
34 }) 34 })
35 } 35 }
36 $scope.cancelStatus = function() { 36 $scope.cancelStatus = function() {
37 $('#popup1').css('display', 'none'); 37 $('#popup1').css('display', 'none');
38 } 38 }
39 $scope.ordersCost = 0; 39 $scope.ordersCost = 0;
40 $scope.ordersCount = 0; 40 $scope.ordersCount = 0;
41 41
42 $scope.orderCostAndCount = function() { 42 $scope.orderCostAndCount = function() {
43 analyticsService.orderCostAndCount().then(function(result) { 43 analyticsService.orderCostAndCount().then(function(result) {
44 $scope.ordersCost = result.cost; 44 $scope.ordersCost = result.cost;
45 $scope.ordersCount = result.count; 45 $scope.ordersCount = result.count;
46 }) 46 })
47 } 47 }
48 48
49 $scope.drf = {}; 49 $scope.drf = {};
50 $scope.hfp = {}; 50 $scope.hfp = {};
51 $scope.cs = {}; 51 $scope.cs = {};
52 $scope.mfsValues = []; 52 $scope.mfsValues = [];
53 $scope.msfarray = []; 53 $scope.msfarray = [];
54 $scope.getMFS = function() { 54 $scope.getMFS = function() {
55 //var makeId = makeId; 55 //var makeId = makeId;
56 analyticsService.getMFS().then(function(result) { 56 analyticsService.getMFS().then(function(result) {
57 $scope.mfsValues = result; 57 $scope.mfsValues = result;
58 $scope.optionsmfs = { 58 $scope.optionsmfs = {
59 chart: { 59 chart: {
60 type: 'multiBarChart', 60 type: 'multiBarChart',
61 height: 450, 61 height: 450,
62 margin: { 62 margin: {
63 top: 45, 63 top: 45,
64 right: 20, 64 right: 20,
65 bottom: 45, 65 bottom: 45,
66 left: 45 66 left: 45
67 }, 67 },
68 clipEdge: true, 68 clipEdge: true,
69 //staggerLabels: true, 69 //staggerLabels: true,
70 duration: 500, 70 duration: 500,
71 stacked: false, 71 stacked: false,
72 color: ["#FEDFC3", "#990000", "#000099", "#009900"], 72 color: ["#FEDFC3", "#990000", "#000099", "#009900"],
73 xAxis: { 73 xAxis: {
74 axisLabel: 'Months', 74 axisLabel: 'Months',
75 showMaxMin: false, 75 showMaxMin: false,
76 }, 76 },
77 yAxis: { 77 yAxis: {
78 axisLabel: 'Orders', 78 axisLabel: 'Orders',
79 axisLabelDistance: -20, 79 axisLabelDistance: -20,
80 tickFormat: function(d) { 80 tickFormat: function(d) {
81 return d3.format(',.1f')(d); 81 return d3.format(',.1f')(d);
82 } 82 }
83 } 83 }
84 } 84 }
85 }; 85 };
86 $scope.datamfs = $scope.mfsValues; 86 $scope.datamfs = $scope.mfsValues;
87 }) 87 })
88 } 88 }
89 89
90 $scope.orderCostAndCount(); 90 $scope.orderCostAndCount();
91 $scope.getMFS(); 91 $scope.getMFS();
92 $scope.csValues = []; 92 $scope.csValues = [];
93 $scope.getCS = function() { 93 $scope.getCS = function() {
94 //var makeId = makeId; 94 //var makeId = makeId;
95 analyticsService.getCS().then(function(result) { 95 analyticsService.getCS().then(function(result) {
96 $scope.csValues = result; 96 $scope.csValues = result;
97 $scope.optionscs = { 97 $scope.optionscs = {
98 chart: { 98 chart: {
99 type: 'pieChart', 99 type: 'pieChart',
100 height: 500, 100 height: 500,
101 // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"], 101 // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"],
102 x: function(d) { 102 x: function(d) {
103 return d.key; 103 return d.key;
104 }, 104 },
105 y: function(d) { 105 y: function(d) {
106 return d.y; 106 return d.y;
107 }, 107 },
108 showLabels: false, 108 showLabels: false,
109 segmentShowStroke: false, 109 segmentShowStroke: false,
110 animationSteps: 20, 110 animationSteps: 20,
111 animationEasing: "linear", 111 animationEasing: "linear",
112 animateScale: true, 112 animateScale: true,
113 duration: 500, 113 duration: 500,
114 labelThreshold: 0.01, 114 labelThreshold: 0.01,
115 labelSunbeamLayout: true, 115 labelSunbeamLayout: true,
116 legend: { 116 legend: {
117 margin: { 117 margin: {
118 top: 5, 118 top: 5,
119 right: 35, 119 right: 35,
120 bottom: 5, 120 bottom: 5,
121 left: 0 121 left: 0
122 } 122 }
123 } 123 }
124 } 124 }
125 }; 125 };
126 $scope.datacs = $scope.csValues; 126 $scope.datacs = $scope.csValues;
127 }) 127 })
128 } 128 }
129 129
130 $scope.getCS(); 130 $scope.getCS();
131 131
132 132
133 $scope.hfpValues = []; 133 $scope.hfpValues = [];
134 $scope.getHfpChartData = function() { 134 $scope.getHfpChartData = function() {
135 //var makeId = makeId; 135 //var makeId = makeId;
136 analyticsService.gethfpChart().then(function(result) { 136 analyticsService.gethfpChart().then(function(result) {
137 $scope.hfpValues = result; 137 $scope.hfpValues = result;
138 console.log('---kd result--',$scope.hfpValues); 138 console.log('---kd result--',$scope.hfpValues);
139 139
140 /*Historic Fuel Price */ 140 /*Historic Fuel Price */
141 141
142 $scope.optionshfp = { 142 $scope.optionshfp = {
143 chart: { 143 chart: {
144 type: 'cumulativeLineChart', 144 type: 'cumulativeLineChart',
145 height: 450, 145 height: 450,
146 margin: { 146 margin: {
147 top: 40, 147 top: 40,
148 right: 20, 148 right: 20,
149 bottom: 50, 149 bottom: 50,
150 left: 65 150 left: 65
151 }, 151 },
152 x: function(d) { 152 x: function(d) {
153 return d[0]; 153 return d[0];
154 }, 154 },
155 y: function(d) { 155 y: function(d) {
156 return d[1] ; 156 return d[1] / 100 ;
157 }, 157 },
158 average: function(d) { 158 average: function(d) {
159 return d.mean / 100; 159 return d.mean / 100;
160 }, 160 },
161 161
162 color: ["#FEDFC3"], 162 color: ["#FEDFC3"],
163 duration: 300, 163 duration: 300,
164 useInteractiveGuideline: true, 164 useInteractiveGuideline: true,
165 clipVoronoi: false, 165 clipVoronoi: false,
166 166
167 xAxis: { 167 xAxis: {
168 axisLabel: '', 168 axisLabel: '',
169 169
170 tickFormat: function(d) { 170 tickFormat: function(d) {
171 // return d3.time.format('%m - %y')(new Date(d)) 171 return d3.time.format('%m/%d/%y')(new Date(d))
172 return d3.time.format('%b \-%y')(new Date(d)) 172 //return d3.time.format('%b \-%y')(new Date(d))
173 }, 173 },
174 showMaxMin: false, 174 showMaxMin: false,
175 staggerLabels: true 175 staggerLabels: true
176 }, 176 },
177 177
178 yAxis: { 178 yAxis: {
179 axisLabel: 'PaP/Retail Price', 179 axisLabel: 'PaP/Retail Price',
180 180
181 tickFormat: function(d) { 181 tickFormat: function(d) {
182 //return d3.format('')(d).toFixed(2); 182 //return d3.format('')(d).toFixed(2);
183 return '$ '+d.toFixed(2) 183 return '$ '+d.toFixed(2)
184 }, 184 },
185 axisLabelDistance: 5 185 axisLabelDistance: 5
186 } 186 }
187 } 187 }
188 }; 188 };
189 $scope.datahfp = [{ 189 $scope.datahfp = [{
190 key: "Long", 190 key: "Long",
191 values: $scope.hfpValues, 191 values: $scope.hfpValues,
192 mean: 0 192 mean: 0
193 }]; 193 }];
194 194
195 }) 195 })
196 } 196 }
197 197
198 $scope.getHfpChartData(); 198 $scope.getHfpChartData();
199 199
200 200
201 /*Date Range Filter for Monthly fuel Sales*/ 201 /*Date Range Filter for Monthly fuel Sales*/
202 $scope.submitDate = function() { 202 $scope.submitDate = function() {
203 if ($scope.drf.fromDate === undefined) { 203 if ($scope.drf.fromDate === undefined) {
204 $scope.fillForm = true; 204 $scope.fillForm = true;
205 } else if ($scope.drf.fromDate != undefined && $scope.drf.toDate === undefined || $scope.drf.toDate === '') { 205 } else if ($scope.drf.fromDate != undefined && $scope.drf.toDate === undefined || $scope.drf.toDate === '') {
206 $scope.fillForm = false; 206 $scope.fillForm = false;
207 var today = new Date(); 207 var today = new Date();
208 var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2); 208 var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2);
209 //from date format 209 //from date format
210 $scope.dat1 = $scope.drf.fromDate; 210 $scope.dat1 = $scope.drf.fromDate;
211 $scope.fd1 = $scope.dat1.split("/").reverse(); 211 $scope.fd1 = $scope.dat1.split("/").reverse();
212 $scope.tmp = $scope.fd1[2]; 212 $scope.tmp = $scope.fd1[2];
213 $scope.fd1[2] = $scope.fd1[1]; 213 $scope.fd1[2] = $scope.fd1[1];
214 $scope.fd1[1] = $scope.tmp; 214 $scope.fd1[1] = $scope.tmp;
215 $scope.fd = $scope.fd1.join("-"); 215 $scope.fd = $scope.fd1.join("-");
216 analyticsService.getDRFChart($scope.fd, DefaultToDate).then(function(result) { 216 analyticsService.getDRFChart($scope.fd, DefaultToDate).then(function(result) {
217 $scope.datamfs = []; 217 $scope.datamfs = [];
218 $scope.datamfs = result; 218 $scope.datamfs = result;
219 }) 219 })
220 220
221 analyticsService.orderCostAndCountByDate($scope.fd, DefaultToDate).then(function(result) { 221 analyticsService.orderCostAndCountByDate($scope.fd, DefaultToDate).then(function(result) {
222 $scope.ordersCost = result.cost; 222 $scope.ordersCost = result.cost;
223 $scope.ordersCount = result.count; 223 $scope.ordersCount = result.count;
224 }) 224 })
225 } else if ($scope.drf.fromDate != undefined && $scope.drf.toDate != undefined) { 225 } else if ($scope.drf.fromDate != undefined && $scope.drf.toDate != undefined) {
226 $scope.fillForm = false; 226 $scope.fillForm = false;
227 //from date format 227 //from date format
228 $scope.dat1 = $scope.drf.fromDate; 228 $scope.dat1 = $scope.drf.fromDate;
229 $scope.fd1 = $scope.dat1.split("/").reverse(); 229 $scope.fd1 = $scope.dat1.split("/").reverse();
230 $scope.tmp = $scope.fd1[2]; 230 $scope.tmp = $scope.fd1[2];
231 $scope.fd1[2] = $scope.fd1[1]; 231 $scope.fd1[2] = $scope.fd1[1];
232 $scope.fd1[1] = $scope.tmp; 232 $scope.fd1[1] = $scope.tmp;
233 $scope.fd = $scope.fd1.join("-"); 233 $scope.fd = $scope.fd1.join("-");
234 $scope.dat2 = $scope.drf.toDate; 234 $scope.dat2 = $scope.drf.toDate;
235 $scope.td1 = $scope.dat2.split("/").reverse(); 235 $scope.td1 = $scope.dat2.split("/").reverse();
236 $scope.tmp1 = $scope.td1[2]; 236 $scope.tmp1 = $scope.td1[2];
237 $scope.td1[2] = $scope.td1[1]; 237 $scope.td1[2] = $scope.td1[1];
238 $scope.td1[1] = $scope.tmp1; 238 $scope.td1[1] = $scope.tmp1;
239 $scope.td = $scope.td1.join("-"); 239 $scope.td = $scope.td1.join("-");
240 240
241 analyticsService.getDRFChart($scope.fd, $scope.td).then(function(result) { 241 analyticsService.getDRFChart($scope.fd, $scope.td).then(function(result) {
242 $scope.datamfs = []; 242 $scope.datamfs = [];
243 $scope.datamfs = result; 243 $scope.datamfs = result;
244 }) 244 })
245 245
246 analyticsService.orderCostAndCountByDate($scope.fd, $scope.td).then(function(result) { 246 analyticsService.orderCostAndCountByDate($scope.fd, $scope.td).then(function(result) {
247 $scope.ordersCost = result.cost; 247 $scope.ordersCost = result.cost;
248 $scope.ordersCount = result.count; 248 $scope.ordersCount = result.count;
249 }) 249 })
250 250
251 } else { 251 } else {
252 $scope.fillForm = true; 252 $scope.fillForm = true;
253 } 253 }
254 254
255 255
256 } 256 }
257 257
258 /*Date Range Filter for Historic fuel Price*/ 258 /*Date Range Filter for Historic fuel Price*/
259 $scope.submitDateHfp = function() { 259 $scope.submitDateHfp = function() {
260 260
261 if ($scope.hfp.fromDate === undefined) { 261 if ($scope.hfp.fromDate === undefined) {
262 262
263 $scope.fillForm = true; 263 $scope.fillForm = true;
264 } else if ($scope.hfp.fromDate != undefined && $scope.hfp.toDate === undefined || $scope.hfp.toDate === '') { 264 } else if ($scope.hfp.fromDate != undefined && $scope.hfp.toDate === undefined || $scope.hfp.toDate === '') {
265 $scope.fillForm = false; 265 $scope.fillForm = false;
266 var today = new Date(); 266 var today = new Date();
267 var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2); 267 var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2);
268 //from date format 268 //from date format
269 $scope.dat1 = $scope.hfp.fromDate; 269 $scope.dat1 = $scope.hfp.fromDate;
270 $scope.fd1 = $scope.dat1.split("/").reverse(); 270 $scope.fd1 = $scope.dat1.split("/").reverse();
271 $scope.tmp = $scope.fd1[2]; 271 $scope.tmp = $scope.fd1[2];
272 $scope.fd1[2] = $scope.fd1[1]; 272 $scope.fd1[2] = $scope.fd1[1];
273 $scope.fd1[1] = $scope.tmp; 273 $scope.fd1[1] = $scope.tmp;
274 $scope.fd = $scope.fd1.join("-"); 274 $scope.fd = $scope.fd1.join("-");
275 analyticsService.getDRFHfpChart($scope.fd, DefaultToDate).then(function(result) { 275 analyticsService.getDRFHfpChart($scope.fd, DefaultToDate).then(function(result) {
276 $scope.hfpValues = result; 276 $scope.hfpValues = result;
277 $scope.optionshfp = { 277 $scope.optionshfp = {
278 chart: { 278 chart: {
279 type: 'cumulativeLineChart', 279 type: 'cumulativeLineChart',
280 height: 450, 280 height: 450,
281 margin: { 281 margin: {
282 top: 40, 282 top: 40,
283 right: 20, 283 right: 20,
284 bottom: 50, 284 bottom: 50,
285 left: 65 285 left: 65
286 }, 286 },
287 x: function(d) { 287 x: function(d) {
288 return d[0]; 288 return d[0];
289 }, 289 },
290 y: function(d) { 290 y: function(d) {
291 return d[1] ; 291 return d[1] / 100;
292 }, 292 },
293 average: function(d) { 293 average: function(d) {
294 return d.mean / 100; 294 return d.mean / 100;
295 }, 295 },
296 296
297 color: ["#FEDFC3"], 297 color: ["#FEDFC3"],
298 duration: 300, 298 duration: 300,
299 useInteractiveGuideline: true, 299 useInteractiveGuideline: true,
300 clipVoronoi: false, 300 clipVoronoi: false,
301 301
302 xAxis: { 302 xAxis: {
303 axisLabel: '', 303 axisLabel: '',
304 304
305 tickFormat: function(d) { 305 tickFormat: function(d) {
306 // return d3.time.format('%m - %y')(new Date(d)) 306 return d3.time.format('%d / %m / %y')(new Date(d))
307 return d3.time.format('%b \-%y')(new Date(d)) 307 // return d3.time.format('%b \-%y')(new Date(d))
308 }, 308 },
309 showMaxMin: false, 309 showMaxMin: false,
310 staggerLabels: true 310 staggerLabels: true
311 }, 311 },
312 312
313 yAxis: { 313 yAxis: {
314 axisLabel: 'PaP/Retail Price', 314 axisLabel: 'PaP/Retail Price',
315 315
316 tickFormat: function(d) { 316 tickFormat: function(d) {
317 //return d3.format('')(d).toFixed(2); 317 //return d3.format('')(d).toFixed(2);
318 return '$ '+d.toFixed(2) 318 return '$ '+d.toFixed(2)
319 }, 319 },
320 axisLabelDistance: 5 320 axisLabelDistance: 5
321 } 321 }
322 } 322 }
323 }; 323 };
324 $scope.datahfp = [{ 324 $scope.datahfp = [{
325 key: "Long", 325 key: "Long",
326 values: $scope.hfpValues, 326 values: $scope.hfpValues,
327 mean: 0 327 mean: 0
328 }]; 328 }];
329 }) 329 })
330 330
331 331
332 } else if ($scope.hfp.fromDate != undefined && $scope.hfp.toDate != undefined) { 332 } else if ($scope.hfp.fromDate != undefined && $scope.hfp.toDate != undefined) {
333 $scope.fillForm = false; 333 $scope.fillForm = false;
334 //from date format 334 //from date format
335 $scope.dat1 = $scope.hfp.fromDate; 335 $scope.dat1 = $scope.hfp.fromDate;
336 $scope.fd1 = $scope.dat1.split("/").reverse(); 336 $scope.fd1 = $scope.dat1.split("/").reverse();
337 $scope.tmp = $scope.fd1[2]; 337 $scope.tmp = $scope.fd1[2];
338 $scope.fd1[2] = $scope.fd1[1]; 338 $scope.fd1[2] = $scope.fd1[1];
339 $scope.fd1[1] = $scope.tmp; 339 $scope.fd1[1] = $scope.tmp;
340 $scope.fd = $scope.fd1.join("-"); 340 $scope.fd = $scope.fd1.join("-");
341 //to date format 341 //to date format
342 $scope.dat2 = $scope.hfp.toDate; 342 $scope.dat2 = $scope.hfp.toDate;
343 $scope.td1 = $scope.dat2.split("/").reverse(); 343 $scope.td1 = $scope.dat2.split("/").reverse();
344 $scope.tmp1 = $scope.td1[2]; 344 $scope.tmp1 = $scope.td1[2];
345 $scope.td1[2] = $scope.td1[1]; 345 $scope.td1[2] = $scope.td1[1];
346 $scope.td1[1] = $scope.tmp1; 346 $scope.td1[1] = $scope.tmp1;
347 $scope.td = $scope.td1.join("-"); 347 $scope.td = $scope.td1.join("-");
348 348
349 analyticsService.getDRFHfpChart($scope.fd, $scope.td).then(function(result) { 349 analyticsService.getDRFHfpChart($scope.fd, $scope.td).then(function(result) {
350 $scope.hfpValues = result; 350 $scope.hfpValues = result;
351 $scope.optionshfp = { 351 $scope.optionshfp = {
352 chart: { 352 chart: {
353 type: 'cumulativeLineChart', 353 type: 'cumulativeLineChart',
354 height: 450, 354 height: 450,
355 margin: { 355 margin: {
356 top: 40, 356 top: 40,
357 right: 20, 357 right: 20,
358 bottom: 50, 358 bottom: 50,
359 left: 65 359 left: 65
360 }, 360 },
361 x: function(d) { 361 x: function(d) {
362 return d[0]; 362 return d[0];
363 }, 363 },
364 y: function(d) { 364 y: function(d) {
365 return d[1] ; 365 return d[1] / 100 ;
366 }, 366 },
367 average: function(d) { 367 average: function(d) {
368 return d.mean / 100; 368 return d.mean / 100;
369 }, 369 },
370 370
371 color: ["#FEDFC3"], 371 color: ["#FEDFC3"],
372 duration: 300, 372 duration: 300,
373 useInteractiveGuideline: true, 373 useInteractiveGuideline: true,
374 clipVoronoi: false, 374 clipVoronoi: false,
375 375
376 xAxis: { 376 xAxis: {
377 axisLabel: '', 377 axisLabel: '',
378 378
379 tickFormat: function(d) { 379 tickFormat: function(d) {
380 // return d3.time.format('%m - %y')(new Date(d)) 380 return d3.time.format('%d / %m / %y')(new Date(d))
381 return d3.time.format('%b \-%y')(new Date(d)) 381 //return d3.time.format('%b \-%y')(new Date(d))
382 }, 382 },
383 showMaxMin: false, 383 showMaxMin: false,
384 staggerLabels: true 384 staggerLabels: true
385 }, 385 },
386 386
387 yAxis: { 387 yAxis: {
388 axisLabel: 'PaP/Retail Price', 388 axisLabel: 'PaP/Retail Price',
389 389
390 tickFormat: function(d) { 390 tickFormat: function(d) {
391 //return d3.format('')(d).toFixed(2); 391 //return d3.format('')(d).toFixed(2);
392 return '$ '+d.toFixed(2) 392 return '$ '+d.toFixed(2)
393 }, 393 },
394 axisLabelDistance: 5 394 axisLabelDistance: 5
395 } 395 }
396 } 396 }
397 }; 397 };
398 $scope.datahfp = [{ 398 $scope.datahfp = [{
399 key: "Long", 399 key: "Long",
400 values:$scope.hfpValues, 400 values:$scope.hfpValues,
401 mean: 0 401 mean: 0
402 }]; 402 }];
403 }) 403 })
404 404
405 } else { 405 } else {
406 $scope.fillForm = true; 406 $scope.fillForm = true;
407 } 407 }
408 408
409 409
410 } 410 }
411 411
412 /*Date Range Filter for Customer Sources*/ 412 /*Date Range Filter for Customer Sources*/
413 $scope.submitDateCs = function() { 413 $scope.submitDateCs = function() {
414 if ($scope.cs.fromDate === undefined) { 414 if ($scope.cs.fromDate === undefined) {
415 415
416 $scope.fillForm = true; 416 $scope.fillForm = true;
417 } else if ($scope.cs.fromDate != undefined && $scope.cs.toDate === undefined || $scope.cs.toDate === '') { 417 } else if ($scope.cs.fromDate != undefined && $scope.cs.toDate === undefined || $scope.cs.toDate === '') {
418 $scope.fillForm = false; 418 $scope.fillForm = false;
419 var today = new Date(); 419 var today = new Date();
420 var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2); 420 var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2);
421 //from date format 421 //from date format
422 $scope.dat1 = $scope.cs.fromDate; 422 $scope.dat1 = $scope.cs.fromDate;
423 $scope.fd1 = $scope.dat1.split("/").reverse(); 423 $scope.fd1 = $scope.dat1.split("/").reverse();
424 $scope.tmp = $scope.fd1[2]; 424 $scope.tmp = $scope.fd1[2];
425 $scope.fd1[2] = $scope.fd1[1]; 425 $scope.fd1[2] = $scope.fd1[1];
426 $scope.fd1[1] = $scope.tmp; 426 $scope.fd1[1] = $scope.tmp;
427 $scope.fd = $scope.fd1.join("-"); 427 $scope.fd = $scope.fd1.join("-");
428 analyticsService.getDRFCSChart($scope.fd, DefaultToDate).then(function(result) { 428 analyticsService.getDRFCSChart($scope.fd, DefaultToDate).then(function(result) {
429 $scope.csValues = result; 429 $scope.csValues = result;
430 $scope.optionscs = { 430 $scope.optionscs = {
431 chart: { 431 chart: {
432 type: 'pieChart', 432 type: 'pieChart',
433 height: 500, 433 height: 500,
434 // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"], 434 // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"],
435 x: function(d) { 435 x: function(d) {
436 return d.key; 436 return d.key;
437 }, 437 },
438 y: function(d) { 438 y: function(d) {
439 return d.y; 439 return d.y;
440 }, 440 },
441 showLabels: false, 441 showLabels: false,
442 segmentShowStroke: false, 442 segmentShowStroke: false,
443 animationSteps: 20, 443 animationSteps: 20,
444 animationEasing: "linear", 444 animationEasing: "linear",
445 animateScale: true, 445 animateScale: true,
446 duration: 500, 446 duration: 500,
447 labelThreshold: 0.01, 447 labelThreshold: 0.01,
448 labelSunbeamLayout: true, 448 labelSunbeamLayout: true,
449 legend: { 449 legend: {
450 margin: { 450 margin: {
451 top: 5, 451 top: 5,
452 right: 35, 452 right: 35,
453 bottom: 5, 453 bottom: 5,
454 left: 0 454 left: 0
455 } 455 }
456 } 456 }
457 } 457 }
458 }; 458 };
459 $scope.datacs = $scope.csValues; 459 $scope.datacs = $scope.csValues;
460 }) 460 })
461 461
462 462
463 } else if ($scope.cs.fromDate != undefined && $scope.cs.toDate != undefined) { 463 } else if ($scope.cs.fromDate != undefined && $scope.cs.toDate != undefined) {
464 $scope.fillForm = false; 464 $scope.fillForm = false;
465 //from date format 465 //from date format
466 $scope.dat1 = $scope.cs.fromDate; 466 $scope.dat1 = $scope.cs.fromDate;
467 $scope.fd1 = $scope.dat1.split("/").reverse(); 467 $scope.fd1 = $scope.dat1.split("/").reverse();
468 $scope.tmp = $scope.fd1[2]; 468 $scope.tmp = $scope.fd1[2];
469 $scope.fd1[2] = $scope.fd1[1]; 469 $scope.fd1[2] = $scope.fd1[1];
470 $scope.fd1[1] = $scope.tmp; 470 $scope.fd1[1] = $scope.tmp;
471 $scope.fd = $scope.fd1.join("-"); 471 $scope.fd = $scope.fd1.join("-");
472 //to date format 472 //to date format
473 $scope.dat2 = $scope.cs.toDate; 473 $scope.dat2 = $scope.cs.toDate;
474 $scope.td1 = $scope.dat2.split("/").reverse(); 474 $scope.td1 = $scope.dat2.split("/").reverse();
475 $scope.tmp1 = $scope.td1[2]; 475 $scope.tmp1 = $scope.td1[2];
476 $scope.td1[2] = $scope.td1[1]; 476 $scope.td1[2] = $scope.td1[1];
477 $scope.td1[1] = $scope.tmp1; 477 $scope.td1[1] = $scope.tmp1;
478 $scope.td = $scope.td1.join("-"); 478 $scope.td = $scope.td1.join("-");
479 479
480 analyticsService.getDRFCSChart($scope.fd, $scope.td).then(function(result) { 480 analyticsService.getDRFCSChart($scope.fd, $scope.td).then(function(result) {
481 $scope.csValues = result; 481 $scope.csValues = result;
482 $scope.optionscs = { 482 $scope.optionscs = {
483 chart: { 483 chart: {
484 type: 'pieChart', 484 type: 'pieChart',
485 height: 500, 485 height: 500,
486 // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"], 486 // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"],
487 x: function(d) { 487 x: function(d) {
488 return d.key; 488 return d.key;
489 }, 489 },
490 y: function(d) { 490 y: function(d) {
491 return d.y; 491 return d.y;
492 }, 492 },
493 showLabels: false, 493 showLabels: false,
494 segmentShowStroke: false, 494 segmentShowStroke: false,
495 animationSteps: 20, 495 animationSteps: 20,
496 animationEasing: "linear", 496 animationEasing: "linear",
497 animateScale: true, 497 animateScale: true,
498 duration: 500, 498 duration: 500,
499 labelThreshold: 0.01, 499 labelThreshold: 0.01,
500 labelSunbeamLayout: true, 500 labelSunbeamLayout: true,
501 legend: { 501 legend: {
502 margin: { 502 margin: {
503 top: 5, 503 top: 5,
504 right: 35, 504 right: 35,
505 bottom: 5, 505 bottom: 5,
506 left: 0 506 left: 0
507 } 507 }
508 } 508 }
509 } 509 }
510 }; 510 };
511 $scope.datacs = $scope.csValues; 511 $scope.datacs = $scope.csValues;
512 }) 512 })
513 513
514 } else { 514 } else {
515 $scope.fillForm = true; 515 $scope.fillForm = true;
516 } 516 }
517 517
518 518
519 } 519 }
520 520
521 521
522 522
523 }]); 523 }]);