Commit 039002959d12be8fc8a9fe9280f6c23725172e7a
1 parent
bb09cc25d4
Exists in
master
minor change
Showing
1 changed file
with
13 additions
and
12 deletions
Show diff stats
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 | reduceXTicks: false, | 349 | reduceXTicks: false, |
350 | margin: { | 350 | margin: { |
351 | top: 45, | 351 | top: 45, |
352 | right: 20, | 352 | right: 20, |
353 | bottom: 45, | 353 | bottom: 45, |
354 | left: 45 | 354 | left: 45 |
355 | }, | 355 | }, |
356 | clipEdge: true, | 356 | clipEdge: true, |
357 | //staggerLabels: true, | 357 | //staggerLabels: true, |
358 | duration: 500, | 358 | duration: 500, |
359 | stacked: false, | 359 | stacked: false, |
360 | /*color: ["#FEDFC3", "#990000", "#000099", "#009900"],*/ | 360 | /*color: ["#FEDFC3", "#990000", "#000099", "#009900"],*/ |
361 | color: ["#A9A9A9", "#000099", "#990000", "#009900"], | 361 | color: ["#A9A9A9", "#000099", "#990000", "#009900"], |
362 | xAxis: { | 362 | xAxis: { |
363 | axisLabel: 'Months', | 363 | axisLabel: 'Months', |
364 | showMaxMin: false, | 364 | showMaxMin: false, |
365 | }, | 365 | }, |
366 | yAxis: { | 366 | yAxis: { |
367 | axisLabel: 'Orders', | 367 | axisLabel: 'Orders', |
368 | axisLabelDistance: -20, | 368 | axisLabelDistance: -20, |
369 | tickFormat: function(d) { | 369 | tickFormat: function(d) { |
370 | return d3.format(',.1f')(d); | 370 | return d3.format(',.1f')(d); |
371 | } | 371 | } |
372 | } | 372 | } |
373 | 373 | ||
374 | } | 374 | } |
375 | }; | 375 | }; |
376 | $scope.datamfs = $scope.mfsValues; | 376 | $scope.datamfs = $scope.mfsValues; |
377 | }) | 377 | }) |
378 | } | 378 | } |
379 | 379 | ||
380 | $scope.orderCostAndCount(); | 380 | $scope.orderCostAndCount(); |
381 | $scope.getMFS(); | 381 | $scope.getMFS(); |
382 | $scope.csValues = []; | 382 | $scope.csValues = []; |
383 | $scope.getCS = function() { | 383 | $scope.getCS = function() { |
384 | //var makeId = makeId; | 384 | //var makeId = makeId; |
385 | analyticsService.getCS().then(function(result) { | 385 | analyticsService.getCS().then(function(result) { |
386 | console.log("===customersupports===",result) | 386 | //console.log("===customersupports===",result) |
387 | $scope.csValues = result; | 387 | $scope.csValues = result; |
388 | $scope.optionscs = { | 388 | $scope.optionscs = { |
389 | chart: { | 389 | chart: { |
390 | type: 'pieChart', | 390 | type: 'pieChart', |
391 | height: 500, | 391 | height: 500, |
392 | // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"], | 392 | // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"], |
393 | x: function(d) { | 393 | x: function(d) { |
394 | return d.key; | 394 | return d.key; |
395 | }, | 395 | }, |
396 | y: function(d) { | 396 | y: function(d) { |
397 | return d.y; | 397 | return d.y; |
398 | }, | 398 | }, |
399 | showLabels: false, | 399 | showLabels: false, |
400 | segmentShowStroke: false, | 400 | segmentShowStroke: false, |
401 | animationSteps: 20, | 401 | animationSteps: 20, |
402 | animationEasing: "linear", | 402 | animationEasing: "linear", |
403 | animateScale: true, | 403 | animateScale: true, |
404 | duration: 500, | 404 | duration: 500, |
405 | labelThreshold: 0.01, | 405 | labelThreshold: 0.01, |
406 | labelSunbeamLayout: true, | 406 | labelSunbeamLayout: true, |
407 | legend: { | 407 | legend: { |
408 | margin: { | 408 | margin: { |
409 | top: 5, | 409 | top: 5, |
410 | right: 35, | 410 | right: 35, |
411 | bottom: 5, | 411 | bottom: 5, |
412 | left: 0 | 412 | left: 0 |
413 | } | 413 | } |
414 | } | 414 | } |
415 | } | 415 | } |
416 | }; | 416 | }; |
417 | $scope.datacs = $scope.csValues; | 417 | $scope.datacs = $scope.csValues; |
418 | }) | 418 | }) |
419 | } | 419 | } |
420 | 420 | ||
421 | $scope.getCS(); | 421 | $scope.getCS(); |
422 | 422 | ||
423 | 423 | ||
424 | $scope.hfpValuesOne = {}; | 424 | $scope.hfpValuesOne = {}; |
425 | $scope.hfpValuesOne.key = "JET-A Full Service"; | 425 | $scope.hfpValuesOne.key = "JET-A Full Service"; |
426 | $scope.hfpValuesOne.values = []; | 426 | $scope.hfpValuesOne.values = []; |
427 | 427 | ||
428 | $scope.hfpValuesTwo = {}; | 428 | $scope.hfpValuesTwo = {}; |
429 | $scope.hfpValuesTwo.key = "100LL Full Service"; | 429 | $scope.hfpValuesTwo.key = "100LL Full Service"; |
430 | $scope.hfpValuesTwo.values = []; | 430 | $scope.hfpValuesTwo.values = []; |
431 | 431 | ||
432 | $scope.hfpFinalData = []; | 432 | $scope.hfpFinalData = []; |
433 | 433 | ||
434 | $scope.getHfpChartData = function() { | 434 | $scope.getHfpChartData = function() { |
435 | analyticsService.gethfpChart().then(function(result) { | 435 | analyticsService.gethfpChart().then(function(result) { |
436 | for(var i=0; i<result.length; i++) { | 436 | for(var i=0; i<result.length; i++) { |
437 | if(result[i].includes("JET-A Full Service") ){ | 437 | if(result[i].includes("JET-A Full Service") ){ |
438 | let datePusha = result[i][0]; | 438 | let datePusha = result[i][0]; |
439 | let tempValue = result[i][1].toFixed(2); | 439 | let tempValue = result[i][1].toFixed(2); |
440 | let valePusha = parseInt(tempValue); | 440 | let valePusha = parseFloat(tempValue); |
441 | $scope.hfpValuesOne.values.push([datePusha, valePusha]) | 441 | $scope.hfpValuesOne.values.push([datePusha, valePusha]) |
442 | }else if(result[i].includes("100LL Full Service") ) { | 442 | }else if(result[i].includes("100LL Full Service") ) { |
443 | let datePushb = result[i][0]; | 443 | let datePushb = result[i][0]; |
444 | let tempvalePushb = result[i][1].toFixed(2); | 444 | let tempvalePushb = result[i][1].toFixed(2); |
445 | let valePushb = parseInt(tempvalePushb); | 445 | let valePushb = parseFloat(tempvalePushb); |
446 | $scope.hfpValuesTwo.values.push([datePushb, valePushb]) | 446 | $scope.hfpValuesTwo.values.push([datePushb, valePushb]) |
447 | } | 447 | } |
448 | } | 448 | } |
449 | $scope.hfpFinalData.push($scope.hfpValuesOne, $scope.hfpValuesTwo); | 449 | $scope.hfpFinalData.push($scope.hfpValuesOne, $scope.hfpValuesTwo); |
450 | // console.log('$scope.hfpFinalData', $scope.hfpFinalData); | 450 | // console.log('$scope.hfpFinalData', $scope.hfpFinalData); |
451 | 451 | ||
452 | var chart = nv.models.lineChart() | 452 | var chart = nv.models.lineChart() |
453 | .x(function(d) { return d[0] }) | 453 | .x(function(d) { return d[0] }) |
454 | //adjusting, 100% is 1.00, not 100 as it is in the data | 454 | //adjusting, 100% is 1.00, not 100 as it is in the data |
455 | .y(function(d) { return d[1]}) | 455 | .y(function(d) { return d[1]}) |
456 | .color(d3.scale.category10().range()) | 456 | .color(d3.scale.category10().range()) |
457 | .useInteractiveGuideline(true) | 457 | .useInteractiveGuideline(true) |
458 | ; | 458 | ; |
459 | 459 | ||
460 | chart.xAxis | 460 | chart.xAxis |
461 | .tickFormat(function(d) { | 461 | .tickFormat(function(d) { |
462 | return d3.time.format('%x')(new Date(d)) | 462 | return d3.time.format('%x')(new Date(d)) |
463 | }); | 463 | }); |
464 | 464 | ||
465 | chart.yAxis | 465 | chart.yAxis |
466 | .axisLabel("PaP / Retail Price") | 466 | .axisLabel("PaP / Retail Price") |
467 | .axisLabelDistance(-5) | 467 | .axisLabelDistance(-5) |
468 | .tickFormat(d3.format(',.2f')).showMaxMin(false); | 468 | .tickFormat(d3.format(',.2f')).showMaxMin(false); |
469 | 469 | ||
470 | d3.select('#chart svg') | 470 | d3.select('#chart svg') |
471 | .datum($scope.hfpFinalData) | 471 | .datum($scope.hfpFinalData) |
472 | .transition().duration(500) | 472 | .transition().duration(500) |
473 | .call(chart) | 473 | .call(chart) |
474 | ; | 474 | ; |
475 | 475 | ||
476 | nv.utils.windowResize(chart.update); | 476 | nv.utils.windowResize(chart.update); |
477 | 477 | ||
478 | return chart; | 478 | return chart; |
479 | }); | 479 | }); |
480 | } | 480 | } |
481 | $scope.getHfpChartData(); | 481 | $scope.getHfpChartData(); |
482 | 482 | ||
483 | /*Date Range Filter for Historic fuel Price*/ | 483 | /*Date Range Filter for Historic fuel Price*/ |
484 | $scope.submitDateHfp = function() { | 484 | $scope.submitDateHfp = function() { |
485 | 485 | ||
486 | $scope.hfpValuesFirst = {}; | 486 | $scope.hfpValuesFirst = {}; |
487 | $scope.hfpValuesFirst.key = "JET-A Full Service"; | 487 | $scope.hfpValuesFirst.key = "JET-A Full Service"; |
488 | $scope.hfpValuesFirst.values = []; | 488 | $scope.hfpValuesFirst.values = []; |
489 | 489 | ||
490 | $scope.hfpValuesSecond = {}; | 490 | $scope.hfpValuesSecond = {}; |
491 | $scope.hfpValuesSecond.key = "100LL Full Service"; | 491 | $scope.hfpValuesSecond.key = "100LL Full Service"; |
492 | $scope.hfpValuesSecond.values = []; | 492 | $scope.hfpValuesSecond.values = []; |
493 | 493 | ||
494 | $scope.hfpRangeData = []; | 494 | $scope.hfpRangeData = []; |
495 | 495 | ||
496 | if ($scope.hfp.fromDate === undefined) { | 496 | if ($scope.hfp.fromDate === undefined) { |
497 | 497 | ||
498 | $scope.fillForm = true; | 498 | $scope.fillForm = true; |
499 | } else if ($scope.hfp.fromDate != undefined && $scope.hfp.toDate === undefined || $scope.hfp.toDate === '') { | 499 | } else if ($scope.hfp.fromDate != undefined && $scope.hfp.toDate === undefined || $scope.hfp.toDate === '') { |
500 | $scope.fillForm = false; | 500 | $scope.fillForm = false; |
501 | var today = new Date(); | 501 | var today = new Date(); |
502 | var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2); | 502 | var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2) + " " + '23:59:59'; |
503 | //from date format | 503 | //from date format |
504 | $scope.dat1 = $scope.hfp.fromDate; | 504 | $scope.dat1 = $scope.hfp.fromDate; |
505 | $scope.fd1 = $scope.dat1.split("/").reverse(); | 505 | $scope.fd1 = $scope.dat1.split("/").reverse(); |
506 | $scope.tmp = $scope.fd1[2]; | 506 | $scope.tmp = $scope.fd1[2]; |
507 | $scope.fd1[2] = $scope.fd1[1]; | 507 | $scope.fd1[2] = $scope.fd1[1]; |
508 | $scope.fd1[1] = $scope.tmp; | 508 | $scope.fd1[1] = $scope.tmp; |
509 | $scope.fd = $scope.fd1.join("-"); | 509 | $scope.fd = $scope.fd1.join("-"); |
510 | // console.log("===date====",$scope.fd,"===dad====",DefaultToDate) | ||
510 | analyticsService.getDRFHfpChart($scope.fd, DefaultToDate).then(function(result) { | 511 | analyticsService.getDRFHfpChart($scope.fd, DefaultToDate).then(function(result) { |
511 | // console.log("===date range===",$scope.fd,DefaultToDate) | 512 | // console.log("===date range===",$scope.fd,DefaultToDate) |
512 | for(var i=0; i<result.length; i++) { | 513 | for(var i=0; i<result.length; i++) { |
513 | if(result[i].includes("JET-A Full Service") ){ | 514 | if(result[i].includes("JET-A Full Service") ){ |
514 | let datePusha = result[i][0]; | 515 | let datePusha = result[i][0]; |
515 | let tempValue = result[i][1].toFixed(2); | 516 | let tempValue = result[i][1].toFixed(2); |
516 | let valePusha = parseInt(tempValue); | 517 | let valePusha = parseFloat(tempValue); |
517 | $scope.hfpValuesFirst.values.push([datePusha, valePusha]) | 518 | $scope.hfpValuesFirst.values.push([datePusha, valePusha]) |
518 | }else if(result[i].includes("100LL Full Service") ) { | 519 | }else if(result[i].includes("100LL Full Service") ) { |
519 | let datePushb = result[i][0]; | 520 | let datePushb = result[i][0]; |
520 | let tempvalePushb = result[i][1].toFixed(2); | 521 | let tempvalePushb = result[i][1].toFixed(2); |
521 | let valePushb = parseInt(tempvalePushb); | 522 | let valePushb = parseFloat(tempvalePushb); |
522 | $scope.hfpValuesSecond.values.push([datePushb, valePushb]) | 523 | $scope.hfpValuesSecond.values.push([datePushb, valePushb]) |
523 | } | 524 | } |
524 | } | 525 | } |
525 | $scope.hfpRangeData.push($scope.hfpValuesFirst, $scope.hfpValuesSecond); | 526 | $scope.hfpRangeData.push($scope.hfpValuesFirst, $scope.hfpValuesSecond); |
526 | // console.log('$scope.hfpRangeData', $scope.hfpRangeData); | 527 | //console.log('$scope.hfpRangeData', $scope.hfpRangeData); |
527 | 528 | ||
528 | var chart = nv.models.lineChart() | 529 | var chart = nv.models.lineChart() |
529 | .x(function(d) { if(d.length >0){return d[0]}}) | 530 | .x(function(d) { if(d.length >0){return d[0]}}) |
530 | //adjusting, 100% is 1.00, not 100 as it is in the data | 531 | //adjusting, 100% is 1.00, not 100 as it is in the data |
531 | .y(function(d) { return d[1]}) | 532 | .y(function(d) { return d[1]}) |
532 | .color(d3.scale.category10().range()) | 533 | .color(d3.scale.category10().range()) |
533 | .useInteractiveGuideline(true) | 534 | .useInteractiveGuideline(true) |
534 | ; | 535 | ; |
535 | 536 | ||
536 | chart.xAxis | 537 | chart.xAxis |
537 | .tickFormat(function(d) { | 538 | .tickFormat(function(d) { |
538 | return d3.time.format('%x')(new Date(d)) | 539 | return d3.time.format('%x')(new Date(d)) |
539 | }); | 540 | }); |
540 | 541 | ||
541 | chart.yAxis | 542 | chart.yAxis |
542 | .axisLabel("PaP / Retail Price") | 543 | .axisLabel("PaP / Retail Price") |
543 | .axisLabelDistance(-5) | 544 | .axisLabelDistance(-5) |
544 | .tickFormat(d3.format(',.2f')).showMaxMin(false); | 545 | .tickFormat(d3.format(',.2f')).showMaxMin(false); |
545 | 546 | ||
546 | d3.select('#chart svg') | 547 | d3.select('#chart svg') |
547 | .datum($scope.hfpRangeData) | 548 | .datum($scope.hfpRangeData) |
548 | .transition().duration(500) | 549 | .transition().duration(500) |
549 | .call(chart) | 550 | .call(chart) |
550 | ; | 551 | ; |
551 | 552 | ||
552 | nv.utils.windowResize(chart.update); | 553 | nv.utils.windowResize(chart.update); |
553 | 554 | ||
554 | return chart; | 555 | return chart; |
555 | }) | 556 | }) |
556 | 557 | ||
557 | 558 | ||
558 | } else if ($scope.hfp.fromDate != undefined && $scope.hfp.toDate != undefined) { | 559 | } else if ($scope.hfp.fromDate != undefined && $scope.hfp.toDate != undefined) { |
559 | $scope.fillForm = false; | 560 | $scope.fillForm = false; |
560 | //from date format | 561 | //from date format |
561 | $scope.dat1 = $scope.hfp.fromDate; | 562 | $scope.dat1 = $scope.hfp.fromDate; |
562 | $scope.fd1 = $scope.dat1.split("/").reverse(); | 563 | $scope.fd1 = $scope.dat1.split("/").reverse(); |
563 | $scope.tmp = $scope.fd1[2]; | 564 | $scope.tmp = $scope.fd1[2]; |
564 | $scope.fd1[2] = $scope.fd1[1]; | 565 | $scope.fd1[2] = $scope.fd1[1]; |
565 | $scope.fd1[1] = $scope.tmp; | 566 | $scope.fd1[1] = $scope.tmp; |
566 | $scope.fd = $scope.fd1.join("-"); | 567 | $scope.fd = $scope.fd1.join("-"); |
567 | //to date format | 568 | //to date format |
568 | $scope.dat2 = $scope.hfp.toDate; | 569 | $scope.dat2 = $scope.hfp.toDate; |
569 | $scope.td1 = $scope.dat2.split("/").reverse(); | 570 | $scope.td1 = $scope.dat2.split("/").reverse(); |
570 | $scope.tmp1 = $scope.td1[2]; | 571 | $scope.tmp1 = $scope.td1[2]; |
571 | $scope.td1[2] = $scope.td1[1]; | 572 | $scope.td1[2] = $scope.td1[1]; |
572 | $scope.td1[1] = $scope.tmp1; | 573 | $scope.td1[1] = $scope.tmp1; |
573 | $scope.td = $scope.td1.join("-"); | 574 | $scope.td = $scope.td1.join("-") + " " + '23:59:59'; |
574 | 575 | // console.log("===both dates==",$scope.td) | |
575 | analyticsService.getDRFHfpChart($scope.fd, $scope.td).then(function(result) { | 576 | analyticsService.getDRFHfpChart($scope.fd, $scope.td).then(function(result) { |
576 | //console.log("===date range22===",result); | 577 | //console.log("===date range22===",result); |
577 | for(var i=0; i<result.length; i++) { | 578 | for(var i=0; i<result.length; i++) { |
578 | if(result[i].includes("JET-A Full Service") ){ | 579 | if(result[i].includes("JET-A Full Service") ){ |
579 | let datePusha = result[i][0]; | 580 | let datePusha = result[i][0]; |
580 | let tempValue = result[i][1].toFixed(2); | 581 | let tempValue = result[i][1].toFixed(2); |
581 | let valePusha = parseInt(tempValue); | 582 | let valePusha = parseFloat(tempValue); |
582 | $scope.hfpValuesFirst.values.push([datePusha, valePusha]) | 583 | $scope.hfpValuesFirst.values.push([datePusha, valePusha]) |
583 | }else if(result[i].includes("100LL Full Service") ) { | 584 | }else if(result[i].includes("100LL Full Service") ) { |
584 | let datePushb = result[i][0]; | 585 | let datePushb = result[i][0]; |
585 | let tempvalePushb = result[i][1].toFixed(2); | 586 | let tempvalePushb = result[i][1].toFixed(2); |
586 | let valePushb = parseInt(tempvalePushb); | 587 | let valePushb = parseFloat(tempvalePushb); |
587 | $scope.hfpValuesSecond.values.push([datePushb, valePushb]) | 588 | $scope.hfpValuesSecond.values.push([datePushb, valePushb]) |
588 | } | 589 | } |
589 | } | 590 | } |
590 | $scope.hfpRangeData.push($scope.hfpValuesFirst, $scope.hfpValuesSecond); | 591 | $scope.hfpRangeData.push($scope.hfpValuesFirst, $scope.hfpValuesSecond); |
591 | // console.log('$scope.hfpRangeData', $scope.hfpRangeData); | 592 | // console.log('$scope.hfpRangeData', $scope.hfpRangeData); |
592 | 593 | ||
593 | var chart = nv.models.lineChart() | 594 | var chart = nv.models.lineChart() |
594 | .x(function(d) { if(d.length >0){return d[0] }}) | 595 | .x(function(d) { if(d.length >0){return d[0] }}) |
595 | //adjusting, 100% is 1.00, not 100 as it is in the data | 596 | //adjusting, 100% is 1.00, not 100 as it is in the data |
596 | .y(function(d) { return d[1]}) | 597 | .y(function(d) { return d[1]}) |
597 | .color(d3.scale.category10().range()) | 598 | .color(d3.scale.category10().range()) |
598 | .useInteractiveGuideline(true) | 599 | .useInteractiveGuideline(true) |
599 | ; | 600 | ; |
600 | 601 | ||
601 | chart.xAxis | 602 | chart.xAxis |
602 | .tickFormat(function(d) { | 603 | .tickFormat(function(d) { |
603 | return d3.time.format('%x')(new Date(d)) | 604 | return d3.time.format('%x')(new Date(d)) |
604 | }); | 605 | }); |
605 | 606 | ||
606 | chart.yAxis | 607 | chart.yAxis |
607 | .axisLabel("PaP / Retail Price") | 608 | .axisLabel("PaP / Retail Price") |
608 | .axisLabelDistance(-5) | 609 | .axisLabelDistance(-5) |
609 | .tickFormat(d3.format(',.2f')).showMaxMin(false); | 610 | .tickFormat(d3.format(',.2f')).showMaxMin(false); |
610 | 611 | ||
611 | d3.select('#chart svg') | 612 | d3.select('#chart svg') |
612 | .datum($scope.hfpRangeData) | 613 | .datum($scope.hfpRangeData) |
613 | .transition().duration(500) | 614 | .transition().duration(500) |
614 | .call(chart) | 615 | .call(chart) |
615 | ; | 616 | ; |
616 | 617 | ||
617 | nv.utils.windowResize(chart.update); | 618 | nv.utils.windowResize(chart.update); |
618 | 619 | ||
619 | return chart; | 620 | return chart; |
620 | }) | 621 | }) |
621 | 622 | ||
622 | } else { | 623 | } else { |
623 | $scope.fillForm = true; | 624 | $scope.fillForm = true; |
624 | } | 625 | } |
625 | 626 | ||
626 | 627 | ||
627 | } | 628 | } |
628 | 629 | ||
629 | 630 | ||
630 | /*Date Range Filter for Monthly fuel Sales*/ | 631 | /*Date Range Filter for Monthly fuel Sales*/ |
631 | $scope.submitDate = function() { | 632 | $scope.submitDate = function() { |
632 | if ($scope.drf.fromDate === undefined) { | 633 | if ($scope.drf.fromDate === undefined) { |
633 | $scope.fillForm = true; | 634 | $scope.fillForm = true; |
634 | } else if ($scope.drf.fromDate != undefined && $scope.drf.toDate === undefined || $scope.drf.toDate === '') { | 635 | } else if ($scope.drf.fromDate != undefined && $scope.drf.toDate === undefined || $scope.drf.toDate === '') { |
635 | $scope.fillForm = false; | 636 | $scope.fillForm = false; |
636 | var today = new Date(); | 637 | var today = new Date(); |
637 | var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2); | 638 | var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2); |
638 | //from date format | 639 | //from date format |
639 | $scope.dat1 = $scope.drf.fromDate; | 640 | $scope.dat1 = $scope.drf.fromDate; |
640 | $scope.fd1 = $scope.dat1.split("/").reverse(); | 641 | $scope.fd1 = $scope.dat1.split("/").reverse(); |
641 | $scope.tmp = $scope.fd1[2]; | 642 | $scope.tmp = $scope.fd1[2]; |
642 | $scope.fd1[2] = $scope.fd1[1]; | 643 | $scope.fd1[2] = $scope.fd1[1]; |
643 | $scope.fd1[1] = $scope.tmp; | 644 | $scope.fd1[1] = $scope.tmp; |
644 | $scope.fd = $scope.fd1.join("-"); | 645 | $scope.fd = $scope.fd1.join("-"); |
645 | analyticsService.getDRFChart($scope.fd, DefaultToDate).then(function(result) { | 646 | analyticsService.getDRFChart($scope.fd, DefaultToDate).then(function(result) { |
646 | $scope.datamfs = []; | 647 | $scope.datamfs = []; |
647 | $scope.datamfs = result; | 648 | $scope.datamfs = result; |
648 | }) | 649 | }) |
649 | 650 | ||
650 | analyticsService.orderCostAndCountByDate($scope.fd, DefaultToDate).then(function(result) { | 651 | analyticsService.orderCostAndCountByDate($scope.fd, DefaultToDate).then(function(result) { |
651 | $scope.ordersCost = result.cost; | 652 | $scope.ordersCost = result.cost; |
652 | $scope.ordersCount = result.count; | 653 | $scope.ordersCount = result.count; |
653 | }) | 654 | }) |
654 | } else if ($scope.drf.fromDate != undefined && $scope.drf.toDate != undefined) { | 655 | } else if ($scope.drf.fromDate != undefined && $scope.drf.toDate != undefined) { |
655 | $scope.fillForm = false; | 656 | $scope.fillForm = false; |
656 | //from date format | 657 | //from date format |
657 | $scope.dat1 = $scope.drf.fromDate; | 658 | $scope.dat1 = $scope.drf.fromDate; |
658 | $scope.fd1 = $scope.dat1.split("/").reverse(); | 659 | $scope.fd1 = $scope.dat1.split("/").reverse(); |
659 | $scope.tmp = $scope.fd1[2]; | 660 | $scope.tmp = $scope.fd1[2]; |
660 | $scope.fd1[2] = $scope.fd1[1]; | 661 | $scope.fd1[2] = $scope.fd1[1]; |
661 | $scope.fd1[1] = $scope.tmp; | 662 | $scope.fd1[1] = $scope.tmp; |
662 | $scope.fd = $scope.fd1.join("-"); | 663 | $scope.fd = $scope.fd1.join("-"); |
663 | $scope.dat2 = $scope.drf.toDate; | 664 | $scope.dat2 = $scope.drf.toDate; |
664 | $scope.td1 = $scope.dat2.split("/").reverse(); | 665 | $scope.td1 = $scope.dat2.split("/").reverse(); |
665 | $scope.tmp1 = $scope.td1[2]; | 666 | $scope.tmp1 = $scope.td1[2]; |
666 | $scope.td1[2] = $scope.td1[1]; | 667 | $scope.td1[2] = $scope.td1[1]; |
667 | $scope.td1[1] = $scope.tmp1; | 668 | $scope.td1[1] = $scope.tmp1; |
668 | $scope.td = $scope.td1.join("-"); | 669 | $scope.td = $scope.td1.join("-"); |
669 | 670 | ||
670 | analyticsService.getDRFChart($scope.fd, $scope.td).then(function(result) { | 671 | analyticsService.getDRFChart($scope.fd, $scope.td).then(function(result) { |
671 | $scope.datamfs = []; | 672 | $scope.datamfs = []; |
672 | $scope.datamfs = result; | 673 | $scope.datamfs = result; |
673 | }) | 674 | }) |
674 | 675 | ||
675 | analyticsService.orderCostAndCountByDate($scope.fd, $scope.td).then(function(result) { | 676 | analyticsService.orderCostAndCountByDate($scope.fd, $scope.td).then(function(result) { |
676 | $scope.ordersCost = result.cost; | 677 | $scope.ordersCost = result.cost; |
677 | $scope.ordersCount = result.count; | 678 | $scope.ordersCount = result.count; |
678 | }) | 679 | }) |
679 | 680 | ||
680 | } else { | 681 | } else { |
681 | $scope.fillForm = true; | 682 | $scope.fillForm = true; |
682 | } | 683 | } |
683 | 684 | ||
684 | 685 | ||
685 | } | 686 | } |
686 | 687 | ||
687 | 688 | ||
688 | 689 | ||
689 | 690 | ||
690 | /*Date Range Filter for Customer Sources*/ | 691 | /*Date Range Filter for Customer Sources*/ |
691 | $scope.submitDateCs = function() { | 692 | $scope.submitDateCs = function() { |
692 | if ($scope.cs.fromDate === undefined) { | 693 | if ($scope.cs.fromDate === undefined) { |
693 | 694 | ||
694 | $scope.fillForm = true; | 695 | $scope.fillForm = true; |
695 | } else if ($scope.cs.fromDate != undefined && $scope.cs.toDate === undefined || $scope.cs.toDate === '') { | 696 | } else if ($scope.cs.fromDate != undefined && $scope.cs.toDate === undefined || $scope.cs.toDate === '') { |
696 | $scope.fillForm = false; | 697 | $scope.fillForm = false; |
697 | var today = new Date(); | 698 | var today = new Date(); |
698 | var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2); | 699 | var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2); |
699 | //from date format | 700 | //from date format |
700 | $scope.dat1 = $scope.cs.fromDate; | 701 | $scope.dat1 = $scope.cs.fromDate; |
701 | $scope.fd1 = $scope.dat1.split("/").reverse(); | 702 | $scope.fd1 = $scope.dat1.split("/").reverse(); |
702 | $scope.tmp = $scope.fd1[2]; | 703 | $scope.tmp = $scope.fd1[2]; |
703 | $scope.fd1[2] = $scope.fd1[1]; | 704 | $scope.fd1[2] = $scope.fd1[1]; |
704 | $scope.fd1[1] = $scope.tmp; | 705 | $scope.fd1[1] = $scope.tmp; |
705 | $scope.fd = $scope.fd1.join("-"); | 706 | $scope.fd = $scope.fd1.join("-"); |
706 | analyticsService.getDRFCSChart($scope.fd, DefaultToDate).then(function(result) { | 707 | analyticsService.getDRFCSChart($scope.fd, DefaultToDate).then(function(result) { |
707 | $scope.csValues = result; | 708 | $scope.csValues = result; |
708 | $scope.optionscs = { | 709 | $scope.optionscs = { |
709 | chart: { | 710 | chart: { |
710 | type: 'pieChart', | 711 | type: 'pieChart', |
711 | height: 500, | 712 | height: 500, |
712 | // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"], | 713 | // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"], |
713 | x: function(d) { | 714 | x: function(d) { |
714 | return d.key; | 715 | return d.key; |
715 | }, | 716 | }, |
716 | y: function(d) { | 717 | y: function(d) { |
717 | return d.y; | 718 | return d.y; |
718 | }, | 719 | }, |
719 | showLabels: false, | 720 | showLabels: false, |
720 | segmentShowStroke: false, | 721 | segmentShowStroke: false, |
721 | animationSteps: 20, | 722 | animationSteps: 20, |
722 | animationEasing: "linear", | 723 | animationEasing: "linear", |
723 | animateScale: true, | 724 | animateScale: true, |
724 | duration: 500, | 725 | duration: 500, |
725 | labelThreshold: 0.01, | 726 | labelThreshold: 0.01, |
726 | labelSunbeamLayout: true, | 727 | labelSunbeamLayout: true, |
727 | legend: { | 728 | legend: { |
728 | margin: { | 729 | margin: { |
729 | top: 5, | 730 | top: 5, |
730 | right: 35, | 731 | right: 35, |
731 | bottom: 5, | 732 | bottom: 5, |
732 | left: 0 | 733 | left: 0 |
733 | } | 734 | } |
734 | } | 735 | } |
735 | } | 736 | } |
736 | }; | 737 | }; |
737 | $scope.datacs = $scope.csValues; | 738 | $scope.datacs = $scope.csValues; |
738 | }) | 739 | }) |
739 | 740 | ||
740 | 741 | ||
741 | } else if ($scope.cs.fromDate != undefined && $scope.cs.toDate != undefined) { | 742 | } else if ($scope.cs.fromDate != undefined && $scope.cs.toDate != undefined) { |
742 | $scope.fillForm = false; | 743 | $scope.fillForm = false; |
743 | //from date format | 744 | //from date format |
744 | $scope.dat1 = $scope.cs.fromDate; | 745 | $scope.dat1 = $scope.cs.fromDate; |
745 | $scope.fd1 = $scope.dat1.split("/").reverse(); | 746 | $scope.fd1 = $scope.dat1.split("/").reverse(); |
746 | $scope.tmp = $scope.fd1[2]; | 747 | $scope.tmp = $scope.fd1[2]; |
747 | $scope.fd1[2] = $scope.fd1[1]; | 748 | $scope.fd1[2] = $scope.fd1[1]; |
748 | $scope.fd1[1] = $scope.tmp; | 749 | $scope.fd1[1] = $scope.tmp; |
749 | $scope.fd = $scope.fd1.join("-"); | 750 | $scope.fd = $scope.fd1.join("-"); |
750 | //to date format | 751 | //to date format |
751 | $scope.dat2 = $scope.cs.toDate; | 752 | $scope.dat2 = $scope.cs.toDate; |
752 | $scope.td1 = $scope.dat2.split("/").reverse(); | 753 | $scope.td1 = $scope.dat2.split("/").reverse(); |
753 | $scope.tmp1 = $scope.td1[2]; | 754 | $scope.tmp1 = $scope.td1[2]; |
754 | $scope.td1[2] = $scope.td1[1]; | 755 | $scope.td1[2] = $scope.td1[1]; |
755 | $scope.td1[1] = $scope.tmp1; | 756 | $scope.td1[1] = $scope.tmp1; |
756 | $scope.td = $scope.td1.join("-"); | 757 | $scope.td = $scope.td1.join("-"); |
757 | 758 | ||
758 | analyticsService.getDRFCSChart($scope.fd, $scope.td).then(function(result) { | 759 | analyticsService.getDRFCSChart($scope.fd, $scope.td).then(function(result) { |
759 | $scope.csValues = result; | 760 | $scope.csValues = result; |
760 | $scope.optionscs = { | 761 | $scope.optionscs = { |
761 | chart: { | 762 | chart: { |
762 | type: 'pieChart', | 763 | type: 'pieChart', |
763 | height: 500, | 764 | height: 500, |
764 | // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"], | 765 | // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"], |
765 | x: function(d) { | 766 | x: function(d) { |
766 | return d.key; | 767 | return d.key; |
767 | }, | 768 | }, |
768 | y: function(d) { | 769 | y: function(d) { |
769 | return d.y; | 770 | return d.y; |
770 | }, | 771 | }, |
771 | showLabels: false, | 772 | showLabels: false, |
772 | segmentShowStroke: false, | 773 | segmentShowStroke: false, |
773 | animationSteps: 20, | 774 | animationSteps: 20, |
774 | animationEasing: "linear", | 775 | animationEasing: "linear", |
775 | animateScale: true, | 776 | animateScale: true, |
776 | duration: 500, | 777 | duration: 500, |
777 | labelThreshold: 0.01, | 778 | labelThreshold: 0.01, |
778 | labelSunbeamLayout: true, | 779 | labelSunbeamLayout: true, |
779 | legend: { | 780 | legend: { |
780 | margin: { | 781 | margin: { |
781 | top: 5, | 782 | top: 5, |
782 | right: 35, | 783 | right: 35, |
783 | bottom: 5, | 784 | bottom: 5, |
784 | left: 0 | 785 | left: 0 |
785 | } | 786 | } |
786 | } | 787 | } |
787 | } | 788 | } |
788 | }; | 789 | }; |
789 | $scope.datacs = $scope.csValues; | 790 | $scope.datacs = $scope.csValues; |
790 | }) | 791 | }) |
791 | 792 | ||
792 | } else { | 793 | } else { |
793 | $scope.fillForm = true; | 794 | $scope.fillForm = true; |
794 | } | 795 | } |
795 | 796 | ||
796 | 797 | ||
797 | } | 798 | } |
798 | 799 | ||
799 | 800 | ||
800 | }]); | 801 | }]); |