Fixed lots of chart references.

This commit is contained in:
James Cole
2015-05-16 09:57:31 +02:00
parent a0cb1b9d9e
commit d22a6c019c
10 changed files with 75 additions and 63 deletions

View File

@@ -31,7 +31,7 @@ class BillController extends Controller
* *
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
*/ */
public function bill(GChart $chart, BillRepositoryInterface $repository, Bill $bill) public function single(GChart $chart, BillRepositoryInterface $repository, Bill $bill)
{ {
$chart->addColumn(trans('firefly.date'), 'date'); $chart->addColumn(trans('firefly.date'), 'date');
@@ -62,7 +62,7 @@ class BillController extends Controller
* *
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
*/ */
public function bills(GChart $chart, BillRepositoryInterface $repository, AccountRepositoryInterface $accounts) public function frontpage(GChart $chart, BillRepositoryInterface $repository, AccountRepositoryInterface $accounts)
{ {
$chart->addColumn(trans('firefly.name'), 'string'); $chart->addColumn(trans('firefly.name'), 'string');
$chart->addColumn(trans('firefly.amount'), 'number'); $chart->addColumn(trans('firefly.amount'), 'number');

View File

@@ -27,7 +27,7 @@ class BudgetController extends Controller
* *
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
*/ */
public function home(GChart $chart, BudgetRepositoryInterface $repository) public function frontpage(GChart $chart, BudgetRepositoryInterface $repository)
{ {
$chart->addColumn(trans('firefly.budget'), 'string'); $chart->addColumn(trans('firefly.budget'), 'string');
$chart->addColumn(trans('firefly.left'), 'number'); $chart->addColumn(trans('firefly.left'), 'number');

View File

@@ -4,6 +4,7 @@ namespace FireflyIII\Http\Controllers\Chart;
use Carbon\Carbon; use Carbon\Carbon;
use Crypt;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Category; use FireflyIII\Models\Category;
use FireflyIII\Models\LimitRepetition; use FireflyIII\Models\LimitRepetition;
@@ -14,7 +15,6 @@ use Navigation;
use Preferences; use Preferences;
use Response; use Response;
use Session; use Session;
use Crypt;
/** /**
* Class CategoryController * Class CategoryController
@@ -33,7 +33,7 @@ class CategoryController extends Controller
* *
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
*/ */
public function home(GChart $chart, CategoryRepositoryInterface $repository) public function frontpage(GChart $chart, CategoryRepositoryInterface $repository)
{ {
$chart->addColumn(trans('firefly.category'), 'string'); $chart->addColumn(trans('firefly.category'), 'string');
$chart->addColumn(trans('firefly.spent'), 'number'); $chart->addColumn(trans('firefly.spent'), 'number');
@@ -56,7 +56,35 @@ class CategoryController extends Controller
} }
/** /**
* Show an overview for a category. * @param GChart $chart
* @param CategoryRepositoryInterface $repository
* @param Category $category
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function month(GChart $chart, CategoryRepositoryInterface $repository, Category $category)
{
$start = clone Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth());
$chart->addColumn(trans('firefly.period'), 'date');
$chart->addColumn(trans('firefly.spent'), 'number');
while ($start <= $end) {
$spent = $repository->spentOnDaySum($category, $start);
$chart->addRow(clone $start, $spent);
$start->addDay();
}
$chart->generate();
return Response::json($chart->getData());
}
/**
* Show an overview for a category for all time, per month/week/year.
* *
* @param GChart $chart * @param GChart $chart
* @param CategoryRepositoryInterface $repository * @param CategoryRepositoryInterface $repository
@@ -64,7 +92,7 @@ class CategoryController extends Controller
* *
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
*/ */
public function overview(GChart $chart, CategoryRepositoryInterface $repository, Category $category) public function all(GChart $chart, CategoryRepositoryInterface $repository, Category $category)
{ {
// oldest transaction in category: // oldest transaction in category:
$start = $repository->getFirstActivityDate($category); $start = $repository->getFirstActivityDate($category);
@@ -79,11 +107,11 @@ class CategoryController extends Controller
$end = new Carbon; $end = new Carbon;
while ($start <= $end) { while ($start <= $end) {
$currentEnd = Navigation::endOfPeriod($start, $range->data); $currentEnd = Navigation::endOfPeriod($start, $range);
$spent = $repository->spentInPeriod($category, $start, $currentEnd); $spent = $repository->spentInPeriod($category, $start, $currentEnd);
$chart->addRow(clone $start, $spent); $chart->addRow(clone $start, $spent);
$start = Navigation::addPeriod($start, $range->data, 0); $start = Navigation::addPeriod($start, $range, 0);
} }
$chart->generate(); $chart->generate();
@@ -93,35 +121,6 @@ class CategoryController extends Controller
} }
/**
* @param GChart $chart
* @param CategoryRepositoryInterface $repository
* @param Category $category
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function period(GChart $chart, CategoryRepositoryInterface $repository, Category $category)
{
$start = clone Session::get('start', Carbon::now()->startOfMonth());
$chart->addColumn(trans('firefly.period'), 'date');
$chart->addColumn(trans('firefly.spent'), 'number');
$end = Session::get('end', Carbon::now()->endOfMonth());
while ($start <= $end) {
$spent = $repository->spentOnDaySum($category, $start);
$chart->addRow(clone $start, $spent);
$start->addDay();
}
$chart->generate();
return Response::json($chart->getData());
}
/** /**
* @param GChart $chart * @param GChart $chart
* @param CategoryRepositoryInterface $repository * @param CategoryRepositoryInterface $repository

View File

@@ -36,7 +36,7 @@ class PiggyBankController extends Controller
* *
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
*/ */
public function piggyBankHistory(GChart $chart, PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank) public function history(GChart $chart, PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
{ {
$chart->addColumn(trans('firefly.date'), 'date'); $chart->addColumn(trans('firefly.date'), 'date');
$chart->addColumn(trans('firefly.balance'), 'number'); $chart->addColumn(trans('firefly.balance'), 'number');

View File

@@ -273,27 +273,39 @@ Route::group(
/** /**
* Google Chart Controller * ALL CHART Controllers
*/ */
Route::get('/chart/account/{account}', ['uses' => 'GoogleChartController@accountBalance']); // accounts:
Route::get('/chart/account/frontpage', ['uses' => 'Chart\AccountController@frontpage']);
Route::get('/chart/account/{account}', ['uses' => 'Chart\AccountController@single']);
// bills:
Route::get('/chart/bill/frontpage', ['uses' => 'Chart\BillController@frontpage']);
Route::get('/chart/bill/{bill}', ['uses' => 'Chart\BillController@single']);
// budgets:
Route::get('/chart/budget/frontpage', ['uses' => 'Chart\BudgetController@frontpage']);
Route::get('/chart/budget/{budget}/{limitrepetition}', ['uses' => 'Chart\BudgetController@budgetLimit']);
// categories:
Route::get('/chart/category/frontpage', ['uses' => 'Chart\CategoryController@frontpage']);
Route::get('/chart/category/{category}/month', ['uses' => 'Chart\CategoryController@month']); // should be period.
Route::get('/chart/category/{category}/all', ['uses' => 'Chart\CategoryController@all']);
// piggy banks:
Route::get('/chart/piggyBank/{piggyBank}', ['uses' => 'Chart\PiggyBankController@history']);
Route::get('/chart/home/account', ['uses' => 'GoogleChartController@allAccountsBalanceChart']);
Route::get('/chart/home/budgets', ['uses' => 'GoogleChartController@allBudgetsHomeChart']);
Route::get('/chart/home/categories', ['uses' => 'GoogleChartController@allCategoriesHomeChart']);
Route::get('/chart/home/bills', ['uses' => 'GoogleChartController@billsOverview']);
Route::get('/chart/budget/{budget}/{limitrepetition}', ['uses' => 'GoogleChartController@budgetLimitSpending']);
Route::get('/chart/reports/income-expenses/{year}/{shared?}', ['uses' => 'GoogleChartController@yearInExp'])->where( Route::get('/chart/reports/income-expenses/{year}/{shared?}', ['uses' => 'GoogleChartController@yearInExp'])->where(
['year' => '[0-9]{4}', 'shared' => 'shared'] ['year' => '[0-9]{4}', 'shared' => 'shared']
); );
Route::get('/chart/reports/income-expenses-sum/{year}/{shared?}', ['uses' => 'GoogleChartController@yearInExpSum'])->where( Route::get('/chart/reports/income-expenses-sum/{year}/{shared?}', ['uses' => 'GoogleChartController@yearInExpSum'])->where(
['year' => '[0-9]{4}', 'shared' => 'shared'] ['year' => '[0-9]{4}', 'shared' => 'shared']
); );
Route::get('/chart/bills/{bill}', ['uses' => 'GoogleChartController@billOverview']);
Route::get('/chart/piggy-history/{piggyBank}', ['uses' => 'GoogleChartController@piggyBankHistory']);
Route::get('/chart/category/{category}/period', ['uses' => 'GoogleChartController@categoryPeriodChart']);
Route::get('/chart/category/{category}/overview', ['uses' => 'GoogleChartController@categoryOverviewChart']);
/** /**
* Help Controller * Help Controller

View File

@@ -1,7 +1,7 @@
$(document).ready(function () { $(document).ready(function () {
if (typeof(googleComboChart) === 'function' && typeof(billID) !== 'undefined') { if (typeof(googleComboChart) === 'function' && typeof(billID) !== 'undefined') {
googleComboChart('chart/bills/' + billID, 'bill-overview'); googleComboChart('chart/bill/' + billID, 'bill-overview');
} }
} }
); );

View File

@@ -1,8 +1,8 @@
$(function () { $(function () {
if (typeof categoryID !== 'undefined') { if (typeof categoryID !== 'undefined') {
googleColumnChart('chart/category/' + categoryID + '/overview', 'componentOverview'); googleColumnChart('chart/category/' + categoryID + '/all', 'all');
googleColumnChart('chart/category/' + categoryID + '/period', 'periodOverview'); googleColumnChart('chart/category/' + categoryID + '/month', 'month');
} }

View File

@@ -2,11 +2,12 @@ google.setOnLoadCallback(drawChart);
function drawChart() { function drawChart() {
googleLineChart('chart/home/account', 'accounts-chart'); googleLineChart('chart/account/frontpage', 'accounts-chart');
//googleColumnChart('chart/home/budgets', 'budgets-chart'); googlePieChart('chart/bill/frontpage', 'bills-chart');
googleStackedColumnChart('chart/home/budgets', 'budgets-chart'); googleStackedColumnChart('chart/budget/frontpage', 'budgets-chart');
googleColumnChart('chart/home/categories', 'categories-chart'); googleColumnChart('chart/category/frontpage', 'categories-chart');
googlePieChart('chart/home/bills', 'bills-chart');
getBoxAmounts(); getBoxAmounts();
} }

View File

@@ -3,7 +3,7 @@ $(function () {
$('.removeMoney').on('click', removeMoney); $('.removeMoney').on('click', removeMoney);
if (typeof(googleLineChart) === 'function' && typeof(piggyBankID) !== 'undefined') { if (typeof(googleLineChart) === 'function' && typeof(piggyBankID) !== 'undefined') {
googleLineChart('chart/piggy-history/' + piggyBankID, 'piggy-bank-history'); googleLineChart('chart/piggyBank/' + piggyBankID, 'piggy-bank-history');
} }
$('#sortable tbody').sortable( $('#sortable tbody').sortable(

View File

@@ -6,10 +6,10 @@
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<i class="fa fa-calendar fa-fw"></i> <i class="fa fa-calendar fa-fw"></i>
{{ 'overview'|_ }} {{ 'overview'|_ }} (month)
</div> </div>
<div class="panel-body"> <div class="panel-body">
<div id="periodOverview"></div> <div id="month"></div>
</div> </div>
</div> </div>
</div> </div>
@@ -17,10 +17,10 @@
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<i class="fa fa-calendar-o fa-fw"></i> <i class="fa fa-calendar-o fa-fw"></i>
{{ 'overview'|_ }} {{ 'overview'|_ }} (all)
</div> </div>
<div class="panel-body"> <div class="panel-body">
<div id="componentOverview"></div> <div id="all"></div>
</div> </div>
</div> </div>
</div> </div>