mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 02:36:28 +00:00 
			
		
		
		
	Some extended code for the category report.
This commit is contained in:
		| @@ -8,6 +8,8 @@ | ||||
|  | ||||
| /* globals $, Chart, currencySymbol,mon_decimal_point ,accounting, mon_thousands_sep, frac_digits */ | ||||
|  | ||||
| var allCharts = {}; | ||||
|  | ||||
| /* | ||||
|  Make some colours: | ||||
|  */ | ||||
| @@ -29,7 +31,6 @@ var colourSet = [ | ||||
|     [240, 98, 146], | ||||
|     [0, 121, 107], | ||||
|     [194, 24, 91] | ||||
|  | ||||
| ]; | ||||
|  | ||||
| var fillColors = []; | ||||
| @@ -234,6 +235,11 @@ function lineChart(URL, container, options) { | ||||
| function areaChart(URL, container, options) { | ||||
|     "use strict"; | ||||
|  | ||||
|     if ($('#' + container).length === 0) { | ||||
|         console.log('No container called ' + container + ' was found.'); | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     $.getJSON(URL).done(function (data) { | ||||
|         var ctx = document.getElementById(container).getContext("2d"); | ||||
|         var newData = {}; | ||||
| @@ -358,14 +364,30 @@ function stackedColumnChart(URL, container, options) { | ||||
| function pieChart(URL, container, options) { | ||||
|     "use strict"; | ||||
|  | ||||
|     if ($('#' + container).length === 0) { | ||||
|         console.log('No container called ' + container + ' was found.'); | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     $.getJSON(URL).done(function (data) { | ||||
|  | ||||
|         var ctx = document.getElementById(container).getContext("2d"); | ||||
|         new Chart(ctx, { | ||||
|             type: 'pie', | ||||
|             data: data, | ||||
|             options: defaultPieOptions | ||||
|         }); | ||||
|         if (allCharts.hasOwnProperty(container)) { | ||||
|             console.log('Will draw updated pie chart'); | ||||
|  | ||||
|             allCharts[container].data.datasets = data.datasets; | ||||
|             allCharts[container].data.labels = data.labels; | ||||
|             allCharts[container].update(); | ||||
|         } else { | ||||
|             // new chart! | ||||
|             console.log('Will draw new pie chart'); | ||||
|             var ctx = document.getElementById(container).getContext("2d"); | ||||
|             allCharts[container] = new Chart(ctx, { | ||||
|                 type: 'pie', | ||||
|                 data: data, | ||||
|                 options: defaultPieOptions | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|  | ||||
|     }).fail(function () { | ||||
|         $('#' + container).addClass('general-chart-error'); | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| /* globals $, columnChart,showTour, Tour, google, lineChart, pieChart, stackedColumnChart, areaChart */ | ||||
|     /* globals $, columnChart,showTour, Tour, google, lineChart, pieChart, stackedColumnChart, areaChart */ | ||||
|  | ||||
| $(function () { | ||||
|     "use strict"; | ||||
|   | ||||
							
								
								
									
										10
									
								
								public/js/ff/reports/category/all.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								public/js/ff/reports/category/all.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| /* | ||||
|  * all.js | ||||
|  * Copyright (C) 2016 thegrumpydictator@gmail.com | ||||
|  * | ||||
|  * This software may be modified and distributed under the terms of the | ||||
|  * Creative Commons Attribution-ShareAlike 4.0 International License. | ||||
|  * | ||||
|  * See the LICENSE file for details. | ||||
|  */ | ||||
|  | ||||
							
								
								
									
										57
									
								
								public/js/ff/reports/category/month.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								public/js/ff/reports/category/month.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,57 @@ | ||||
| /* | ||||
|  * month.js | ||||
|  * Copyright (C) 2016 thegrumpydictator@gmail.com | ||||
|  * | ||||
|  * This software may be modified and distributed under the terms of the | ||||
|  * Creative Commons Attribution-ShareAlike 4.0 International License. | ||||
|  * | ||||
|  * See the LICENSE file for details. | ||||
|  */ | ||||
|  | ||||
| $(function () { | ||||
|     "use strict"; | ||||
|     drawChart(); | ||||
|     $('#categories-in-pie-chart-checked').on('change', redrawCatInPie); | ||||
|     $('#categories-out-pie-chart-checked').on('change', redrawCatOutPie); | ||||
| }); | ||||
|  | ||||
|  | ||||
| function drawChart() { | ||||
|     "use strict"; | ||||
|  | ||||
|     // month view: | ||||
|  | ||||
|     // draw pie chart of income, depending on "show other transactions too": | ||||
|     redrawCatInPie(); | ||||
|     redrawCatOutPie(); | ||||
| } | ||||
|  | ||||
| function redrawCatOutPie() { | ||||
|     "use strict"; | ||||
|     var checkbox = $('#categories-out-pie-chart-checked'); | ||||
|     var container = 'categories-out-pie-chart'; | ||||
|  | ||||
|     // | ||||
|     var others = '0'; | ||||
|     // check if box is checked: | ||||
|     if (checkbox.prop('checked')) { | ||||
|         others = '1'; | ||||
|     } | ||||
|  | ||||
|     pieChart('chart/category/' + accountIds + '/' + categoryIds + '/' + startDate + '/' + endDate + '/' + others + '/expense', container); | ||||
| } | ||||
|  | ||||
| function redrawCatInPie() { | ||||
|     "use strict"; | ||||
|     var checkbox = $('#categories-in-pie-chart-checked'); | ||||
|     var container = 'categories-in-pie-chart'; | ||||
|  | ||||
|     // | ||||
|     var others = '0'; | ||||
|     // check if box is checked: | ||||
|     if (checkbox.prop('checked')) { | ||||
|         others = '1'; | ||||
|     } | ||||
|  | ||||
|     pieChart('chart/category/' + accountIds + '/' + categoryIds + '/' + startDate + '/' + endDate + '/' + others + '/income', container); | ||||
| } | ||||
		Reference in New Issue
	
	Block a user