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