diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index a2828c4556..2b8f17f3dc 100644 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -111,7 +111,8 @@ class AccountController extends BaseController return Response::jsoN($return); } - public function transactions(Account $account) { + public function transactions(Account $account) + { /* * TODO get the JSON helper to get transactions or something. */ @@ -123,7 +124,7 @@ class AccountController extends BaseController * * @return \Illuminate\View\View */ - public function sankey($account) + public function sankeyOut($account) { /* @@ -162,7 +163,7 @@ class AccountController extends BaseController $from = $to; $category = $entry->categories()->first(); if ($category) { - $to = $category->name . ' (cat)'; + $to = ' ' . $category->name; } else { $to = '(no category)'; } @@ -211,16 +212,18 @@ class AccountController extends BaseController } } - ksort($filtered); - /* - * Collect amounts to give the labels the proper + * Take out the keys: */ + foreach ($filtered as $key => $entry) { + $result[] = [$entry['from'],$entry['to'],$entry['amount']]; + } + /* * Loop it again to add the amounts. */ - return View::make('accounts.sankey', compact('filtered')); + return Response::json($result); } diff --git a/app/routes.php b/app/routes.php index aaa77b637e..52d8c728e9 100644 --- a/app/routes.php +++ b/app/routes.php @@ -142,7 +142,7 @@ Route::group(['before' => 'auth'], function () { Route::get('/accounts/edit/{account}',['uses' => 'AccountController@edit','as' => 'accounts.edit']); Route::get('/accounts/delete/{account}',['uses' => 'AccountController@delete','as' => 'accounts.delete']); Route::get('/accounts/show/{account}',['uses' => 'AccountController@show','as' => 'accounts.show']); - Route::get('/accounts/sankey/{account}',['uses' => 'AccountController@sankey','as' => 'accounts.sankey']); + Route::get('/accounts/sankey/{account}/out',['uses' => 'AccountController@sankeyOut','as' => 'accounts.sankey.out']); // budget controller: Route::get('/budgets/date',['uses' => 'BudgetController@indexByDate','as' => 'budgets.index.date']); diff --git a/app/views/accounts/sankey.blade.php b/app/views/accounts/sankey.blade.php index b1a29aae7c..1246408a11 100644 --- a/app/views/accounts/sankey.blade.php +++ b/app/views/accounts/sankey.blade.php @@ -29,12 +29,10 @@ google.setOnLoadCallback(drawChart); // Set chart options var options = { - width: 600, - sankey: { link: { color: { fill: '#9fa8da', fillOpacity: 0.8 } }, - node: { color: { fill: '#a61d4c' }, - label: { color: '#871b47' } } + node: { color: { fill: '#000' }, + label: { color: '#000' } } } }; diff --git a/app/views/accounts/show.blade.php b/app/views/accounts/show.blade.php index e066edc09e..ed164b3028 100644 --- a/app/views/accounts/show.blade.php +++ b/app/views/accounts/show.blade.php @@ -7,7 +7,7 @@ {{{$account->name}}}
-
+
@@ -61,11 +61,36 @@ + + +
+
+
+
+ Out +
+
+
+
+
+
+
+
+
+ In +
+
+ +
+
+
+
+
- Transaction + Transactions
@@ -122,18 +147,7 @@
-
-
-
-
- Transaction -
-
-
-
-
-
{{--
@@ -153,12 +167,9 @@ @section('scripts') {{HTML::script('assets/javascript/datatables/jquery.dataTables.min.js')}} {{HTML::script('assets/javascript/datatables/dataTables.bootstrap.js')}} -{{HTML::script('assets/javascript/datatables/transactions.js')}} {{HTML::script('assets/javascript/highcharts/highcharts.js')}} {{HTML::script('assets/javascript/firefly/accounts.js')}} @stop \ No newline at end of file diff --git a/public/assets/javascript/firefly/accounts.js b/public/assets/javascript/firefly/accounts.js index a6ba2bdb98..33d0b22040 100644 --- a/public/assets/javascript/firefly/accounts.js +++ b/public/assets/javascript/firefly/accounts.js @@ -2,12 +2,10 @@ $(function () { if ($('#accountTable').length == 1) { drawDatatable(); } - //if ($('#accountTransactionsTable').length == 1) { - // drawTransactionsForAccount(); - //} - if ($('#transactionByAccountTable').length == 1) { - renderTransactionsFromURL(URL, container); + if ($('#overviewChart').length == 1) { + drawOverviewChart(); } + }); function drawDatatable() { @@ -62,11 +60,11 @@ function drawDatatable() { } -function drawTransactionsForAccount() { +function drawOverviewChart() { $.getJSON('chart/home/account/' + accountID).success(function (data) { var options = { chart: { - renderTo: 'accountTransactionsTable', + renderTo: 'overviewChart', type: 'spline' }, @@ -128,84 +126,6 @@ function drawTransactionsForAccount() { enabled: false } }; - $('#accountTransactionsTable').highcharts(options); + $('#overviewChart').highcharts(options); }); } - -//$(function () { -//if($('#chart').length == 1) { -// /** -// * get data from controller for home charts: -// */ -// $.getJSON('chart/home/account/' + accountID).success(function (data) { -// var options = { -// chart: { -// renderTo: 'chart', -// type: 'spline' -// }, -// -// series: data.series, -// title: { -// text: null -// }, -// yAxis: { -// allowDecimals: false, -// labels: { -// formatter: function () { -// if(this.value >= 1000 || this.value <= -1000) { -// return '\u20AC ' + (this.value / 1000) + 'k'; -// } -// return '\u20AC ' + this.value; -// -// } -// }, -// title: {text: null} -// }, -// xAxis: { -// type: 'datetime', -// dateTimeLabelFormats: { -// day: '%e %b', -// week: '%e %b' -// }, -// title: { -// text: null -// } -// }, -// legend: {enabled:false}, -// tooltip: { -// formatter: function () { -// return this.series.name + ': \u20AC ' + Highcharts.numberFormat(this.y,2); -// } -// }, -// plotOptions: { -// line: { -// shadow: true -// }, -// series: { -// cursor: 'pointer', -// negativeColor: '#FF0000', -// threshold: 0, -// lineWidth: 1, -// marker: { -// radius: 0 -// }, -// point: { -// events: { -// click: function (e) { -// alert('click!'); -// } -// } -// } -// } -// }, -// credits: { -// enabled: false -// } -// }; -// $('#chart').highcharts(options); -// }); -//} -// -// -// -//}); \ No newline at end of file