mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-22 06:23:12 -06:00
Optimised chart generation.
This commit is contained in:
parent
e4e2921f3e
commit
cbe52b5089
@ -65,11 +65,6 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator
|
|||||||
'labels' => [],
|
'labels' => [],
|
||||||
'datasets' => [],
|
'datasets' => [],
|
||||||
];
|
];
|
||||||
foreach ($entries as $entry) {
|
|
||||||
if ($entry[1] != 0 || $entry[2] != 0 || $entry[3] != 0) {
|
|
||||||
$data['labels'][] = $entry[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// dataset: left
|
// dataset: left
|
||||||
// dataset: spent
|
// dataset: spent
|
||||||
// dataset: overspent
|
// dataset: overspent
|
||||||
@ -78,9 +73,10 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator
|
|||||||
$overspent = [];
|
$overspent = [];
|
||||||
foreach ($entries as $entry) {
|
foreach ($entries as $entry) {
|
||||||
if ($entry[1] != 0 || $entry[2] != 0 || $entry[3] != 0) {
|
if ($entry[1] != 0 || $entry[2] != 0 || $entry[3] != 0) {
|
||||||
$left[] = round($entry[1], 2);
|
$data['labels'][] = $entry[0];
|
||||||
$spent[] = round($entry[2], 2);
|
$left[] = round($entry[1], 2);
|
||||||
$overspent[] = round($entry[3], 2);
|
$spent[] = round($entry[2], 2);
|
||||||
|
$overspent[] = round($entry[3], 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ use FireflyIII\Models\Budget;
|
|||||||
use FireflyIII\Models\LimitRepetition;
|
use FireflyIII\Models\LimitRepetition;
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
use FireflyIII\Support\CacheProperties;
|
use FireflyIII\Support\CacheProperties;
|
||||||
use Grumpydictator\Gchart\GChart;
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Navigation;
|
use Navigation;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
@ -84,7 +83,6 @@ class BudgetController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Shows the amount left in a specific budget limit.
|
* Shows the amount left in a specific budget limit.
|
||||||
*
|
*
|
||||||
* @param GChart $chart
|
|
||||||
* @param BudgetRepositoryInterface $repository
|
* @param BudgetRepositoryInterface $repository
|
||||||
* @param Budget $budget
|
* @param Budget $budget
|
||||||
* @param LimitRepetition $repetition
|
* @param LimitRepetition $repetition
|
||||||
@ -170,9 +168,7 @@ class BudgetController extends Controller
|
|||||||
|
|
||||||
$left = max(bcsub($repetition->amount, $expenses), 0); // limited at zero.
|
$left = max(bcsub($repetition->amount, $expenses), 0); // limited at zero.
|
||||||
$overspent = max(bcsub($expenses, $repetition->amount), 0); // limited at zero.
|
$overspent = max(bcsub($expenses, $repetition->amount), 0); // limited at zero.
|
||||||
$date = $repetition->startdate->formatLocalized($this->monthAndDayFormat);
|
$name = $budget->name;
|
||||||
//$name = $budget->name . ' (' . $date . ')';
|
|
||||||
$name = $budget->name;
|
|
||||||
|
|
||||||
// $spent is maxed to the repetition amount:
|
// $spent is maxed to the repetition amount:
|
||||||
$spent = $expenses > $repetition->amount ? $repetition->amount : $expenses;
|
$spent = $expenses > $repetition->amount ? $repetition->amount : $expenses;
|
||||||
|
Loading…
Reference in New Issue
Block a user