mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Experimental chart [skip ci]
This commit is contained in:
parent
d1a4a83570
commit
72906a7afd
@ -149,6 +149,7 @@ class GoogleChartController extends Controller
|
||||
{
|
||||
$chart->addColumn('Budget', 'string');
|
||||
$chart->addColumn('Left', 'number');
|
||||
$chart->addColumn('Spent', 'number');
|
||||
$chart->addColumn('Overspent', 'number');
|
||||
|
||||
$budgets = $repository->getBudgets();
|
||||
@ -160,31 +161,41 @@ class GoogleChartController extends Controller
|
||||
$repetitions = $repository->getBudgetLimitRepetitions($budget, $start, $end);
|
||||
if ($repetitions->count() == 0) {
|
||||
$expenses = $repository->sumBudgetExpensesInPeriod($budget, $start, $end);
|
||||
$allEntries->push([$budget->name, 0, $expenses]);
|
||||
$allEntries->push([$budget->name, 0, 0, $expenses]);
|
||||
continue;
|
||||
}
|
||||
/** @var LimitRepetition $repetition */
|
||||
foreach ($repetitions as $repetition) {
|
||||
$expenses = $repository->sumBudgetExpensesInPeriod($budget, $repetition->startdate, $repetition->enddate);
|
||||
$allEntries->push([$budget->name . ' (' . $repetition->startdate->format('j M Y') . ')', floatval($repetition->amount), $expenses]);
|
||||
$expenses = $repository->sumBudgetExpensesInPeriod($budget, $repetition->startdate, $repetition->enddate);
|
||||
$left = $expenses > floatval($repetition->amount) ? 0 : (floatval($repetition->amount));
|
||||
$spent = $expenses > floatval($repetition->amount) ? 0 : $expenses;
|
||||
$overspent = $expenses > floatval($repetition->amount) ? $expenses - floatval($repetition->amount) : 0;
|
||||
$allEntries->push(
|
||||
[$budget->name . ' (' . $repetition->startdate->format('j M Y') . ')',
|
||||
$left,
|
||||
$spent,
|
||||
$overspent
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$noBudgetExpenses = $repository->getWithoutBudgetSum($start, $end);
|
||||
$allEntries->push(['(no budget)', 0, $noBudgetExpenses]);
|
||||
$allEntries->push(['(no budget)', 0, 0, $noBudgetExpenses]);
|
||||
|
||||
foreach ($allEntries as $entry) {
|
||||
if ($entry[2] > 0) {
|
||||
$left = $entry[1] - $entry[2];
|
||||
if ($left > 0) {
|
||||
$chart->addRow($entry[0], $left, null);
|
||||
} else {
|
||||
if ($left < 0) {
|
||||
$chart->addRow($entry[0], null, $left);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$chart->addRow($entry[0], $entry[1], $entry[2], $entry[3]);
|
||||
// if ($entry[2] > 0) {
|
||||
// $left = $entry[1] - $entry[2];
|
||||
// if ($left > 0) {
|
||||
// $chart->addRow($entry[0], $left, null);
|
||||
// } else {
|
||||
// if ($left < 0) {
|
||||
// $chart->addRow($entry[0], null, $left);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
$chart->generate();
|
||||
|
@ -3,7 +3,8 @@ google.setOnLoadCallback(drawChart);
|
||||
|
||||
function drawChart() {
|
||||
googleLineChart('chart/home/account', 'accounts-chart');
|
||||
googleColumnChart('chart/home/budgets', 'budgets-chart');
|
||||
//googleColumnChart('chart/home/budgets', 'budgets-chart');
|
||||
googleStackedColumnChart('chart/home/budgets', 'budgets-chart');
|
||||
googleColumnChart('chart/home/categories', 'categories-chart');
|
||||
googlePieChart('chart/home/bills', 'bills-chart');
|
||||
getBoxAmounts();
|
||||
|
Loading…
Reference in New Issue
Block a user