mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Chart for piggy banks
This commit is contained in:
parent
8c254554eb
commit
fb0d463040
@ -473,6 +473,29 @@ class GoogleChartController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
public function piggyBankHistory(\Piggybank $piggybank)
|
||||
{
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('Date', 'date');
|
||||
$chart->addColumn('Balance', 'number');
|
||||
$sum = 0;
|
||||
|
||||
$set = \DB::table('piggybank_events')
|
||||
->where('piggybank_id',$piggybank->id)
|
||||
->groupBy('date')
|
||||
->get(['date',DB::Raw('SUM(`amount`) AS `sum`')]);
|
||||
|
||||
foreach($set as $entry) {
|
||||
$chart->addRow(new Carbon($entry->date), floatval($entry->sum));
|
||||
}
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RecurringTransaction $recurring
|
||||
*/
|
||||
|
@ -113,4 +113,13 @@
|
||||
@stop
|
||||
|
||||
@section('scripts')
|
||||
<script type="text/javascript">
|
||||
var piggyBankID = {{{$piggybank->id}}};
|
||||
</script>
|
||||
|
||||
<!-- load the libraries and scripts necessary for Google Charts: -->
|
||||
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
||||
{{HTML::script('assets/javascript/firefly/gcharts.options.js')}}
|
||||
{{HTML::script('assets/javascript/firefly/gcharts.js')}}
|
||||
{{HTML::script('assets/javascript/firefly/piggybanks.js')}}
|
||||
@stop
|
||||
|
@ -1,6 +1,10 @@
|
||||
$(function () {
|
||||
$('.addMoney').on('click', addMoney);
|
||||
$('.removeMoney').on('click', removeMoney);
|
||||
|
||||
if (typeof(googleLineChart) == 'function' && typeof(piggyBankID) != 'undefined') {
|
||||
googleLineChart('chart/piggyhistory/' + piggyBankID, 'piggybank-history');
|
||||
}
|
||||
});
|
||||
|
||||
function addMoney(e) {
|
||||
|
Loading…
Reference in New Issue
Block a user