mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-07 06:33:57 -06:00
41 lines
857 B
PHP
41 lines
857 B
PHP
<?php
|
|
|
|
namespace FireflyIII\Generator\Chart\PiggyBank;
|
|
|
|
use Carbon\Carbon;
|
|
use Grumpydictator\Gchart\GChart;
|
|
use Illuminate\Support\Collection;
|
|
|
|
|
|
/**
|
|
* Class GooglePiggyBankChartGenerator
|
|
*
|
|
* @package FireflyIII\Generator\Chart\PiggyBank
|
|
*/
|
|
class GooglePiggyBankChartGenerator implements PiggyBankChartGenerator
|
|
{
|
|
|
|
/**
|
|
* @param Collection $set
|
|
*
|
|
* @return array
|
|
*/
|
|
public function history(Collection $set)
|
|
{
|
|
$chart = new GChart;
|
|
$chart->addColumn(trans('firefly.date'), 'date');
|
|
$chart->addColumn(trans('firefly.balance'), 'number');
|
|
|
|
$sum = '0';
|
|
bcscale(2);
|
|
|
|
foreach ($set as $entry) {
|
|
$sum = bcadd($sum, $entry->sum);
|
|
$chart->addRow(new Carbon($entry->date), $sum);
|
|
}
|
|
|
|
$chart->generate();
|
|
|
|
return $chart->getData();
|
|
}
|
|
} |