From cbe52b5089317f672f51b66ec8c0d7c7c39b37f9 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 28 Jun 2015 08:33:23 +0200 Subject: [PATCH] Optimised chart generation. --- .../Chart/Budget/ChartJsBudgetChartGenerator.php | 12 ++++-------- app/Http/Controllers/Chart/BudgetController.php | 6 +----- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php b/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php index 149c3e797f..bb256648c3 100644 --- a/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php +++ b/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php @@ -65,11 +65,6 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator 'labels' => [], 'datasets' => [], ]; - foreach ($entries as $entry) { - if ($entry[1] != 0 || $entry[2] != 0 || $entry[3] != 0) { - $data['labels'][] = $entry[0]; - } - } // dataset: left // dataset: spent // dataset: overspent @@ -78,9 +73,10 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator $overspent = []; foreach ($entries as $entry) { if ($entry[1] != 0 || $entry[2] != 0 || $entry[3] != 0) { - $left[] = round($entry[1], 2); - $spent[] = round($entry[2], 2); - $overspent[] = round($entry[3], 2); + $data['labels'][] = $entry[0]; + $left[] = round($entry[1], 2); + $spent[] = round($entry[2], 2); + $overspent[] = round($entry[3], 2); } } diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php index ffc9d82320..f84e19d2e4 100644 --- a/app/Http/Controllers/Chart/BudgetController.php +++ b/app/Http/Controllers/Chart/BudgetController.php @@ -9,7 +9,6 @@ use FireflyIII\Models\Budget; use FireflyIII\Models\LimitRepetition; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use FireflyIII\Support\CacheProperties; -use Grumpydictator\Gchart\GChart; use Illuminate\Support\Collection; use Navigation; use Preferences; @@ -84,7 +83,6 @@ class BudgetController extends Controller /** * Shows the amount left in a specific budget limit. * - * @param GChart $chart * @param BudgetRepositoryInterface $repository * @param Budget $budget * @param LimitRepetition $repetition @@ -170,9 +168,7 @@ class BudgetController extends Controller $left = max(bcsub($repetition->amount, $expenses), 0); // limited at zero. $overspent = max(bcsub($expenses, $repetition->amount), 0); // limited at zero. - $date = $repetition->startdate->formatLocalized($this->monthAndDayFormat); - //$name = $budget->name . ' (' . $date . ')'; - $name = $budget->name; + $name = $budget->name; // $spent is maxed to the repetition amount: $spent = $expenses > $repetition->amount ? $repetition->amount : $expenses;