Files
firefly-iii/public/js/reports/default/multi-year.js

48 lines
1.6 KiB
JavaScript
Raw Normal View History

2015-12-12 17:51:07 +01:00
/* globals google, startDate ,reportURL, endDate , reportType ,accountIds , picker:true, minDate, expenseRestShow:true, incomeRestShow:true, year, month, hideTheRest, showTheRest, showTheRestExpense, hideTheRestExpense, columnChart, lineChart, stackedColumnChart */
$(function () {
"use strict";
drawChart();
});
2015-05-08 17:13:49 +02:00
function drawChart() {
2015-05-24 20:41:14 +02:00
"use strict";
2015-12-14 21:12:10 +01:00
// income and expense over multi year:
columnChart('chart/report/in-out/' + reportType + '/' + startDate + '/' + endDate + '/' + accountIds, 'income-expenses-chart');
columnChart('chart/report/in-out-sum/' + reportType + '/' + startDate + '/' + endDate + '/' + accountIds, 'income-expenses-sum-chart');
2015-12-15 12:38:18 +01:00
$.each($('.account-chart'), function (i, v) {
2015-12-14 21:12:10 +01:00
var holder = $(v);
2015-12-15 12:38:18 +01:00
console.log('Will draw chart for account #' + holder.data('id'));
});
// draw budget chart based on selected budgets:
$('.budget-checkbox').on('change', updateBudgetChart);
}
function updateBudgetChart(e) {
console.log('will update budget chart.');
// get all budget ids:
var budgets = [];
$.each($('.budget-checkbox'), function (i, v) {
var current = $(v);
if (current.prop('checked')) {
budgets.push(current.val());
}
2015-12-14 21:12:10 +01:00
});
2015-12-15 12:38:18 +01:00
var budgetIds = budgets.join(',');
2015-12-14 21:12:10 +01:00
// remove old chart:
$('#budgets-chart').replaceWith('<canvas id="budgets-chart" class="budgets-chart" style="width:100%;height:400px;"></canvas>');
2015-12-15 12:38:18 +01:00
// draw chart. Redraw when exists? Not sure if we support that.
columnChart('chart/budget/multi-year/' + reportType + '/' + startDate + '/' + endDate + '/' + accountIds + '/' + budgetIds, 'budgets-chart');
2015-12-14 21:12:10 +01:00
}