Optimised chart generation.

This commit is contained in:
James Cole 2015-06-28 08:33:23 +02:00
parent e4e2921f3e
commit cbe52b5089
2 changed files with 5 additions and 13 deletions

View File

@ -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);
}
}

View File

@ -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;