mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 12:12:18 +00:00
Added some more charts
This commit is contained in:
@@ -5,6 +5,11 @@ namespace FireflyIII\Generator\Chart\Budget;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class ChartJsBudgetChartGenerator
|
||||
*
|
||||
* @package FireflyIII\Generator\Chart\Budget
|
||||
*/
|
||||
class ChartJsBudgetChartGenerator implements BudgetChartGenerator
|
||||
{
|
||||
|
||||
@@ -33,6 +38,45 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator
|
||||
*/
|
||||
public function frontpage(Collection $entries)
|
||||
{
|
||||
$data = [
|
||||
'count' => 2,
|
||||
'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
|
||||
$left = [];
|
||||
$spent = [];
|
||||
$overspent = [];
|
||||
$amount = [];
|
||||
$expenses = [];
|
||||
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);
|
||||
$amount[] = round($entry[4], 2);
|
||||
$expenses[] = round($entry[5], 2);
|
||||
//$data['count']++;
|
||||
}
|
||||
}
|
||||
|
||||
$data['datasets'][] = [
|
||||
'label' => 'Amount',
|
||||
'data' => $amount,
|
||||
];
|
||||
$data['datasets'][] = [
|
||||
'label' => 'Spent',
|
||||
'data' => $expenses,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user