Chart cleanup

This commit is contained in:
Sander Dorigo 2014-11-02 21:24:50 +01:00
parent ef39f31ea1
commit 03729aa5ae
4 changed files with 30 additions and 12 deletions

View File

@ -231,8 +231,7 @@ class GoogleChartController extends BaseController
/** @var \TransactionJournal $journal */ /** @var \TransactionJournal $journal */
foreach ($journals as $journal) { foreach ($journals as $journal) {
if ($journal->transactionType->type == 'Withdrawal') { if ($journal->transactionType->type == 'Withdrawal') {
$amount = floatval($journal->transactions[1]->amount); $amount = $journal->getAmount();
$amount = $amount < 0 ? $amount * -1 : $amount;
$category = $journal->categories()->first(); $category = $journal->categories()->first();
if (!is_null($category)) { if (!is_null($category)) {
if (isset($data[$category->name])) { if (isset($data[$category->name])) {
@ -321,8 +320,7 @@ class GoogleChartController extends BaseController
$unpaid['items'][] = $entry->name; $unpaid['items'][] = $entry->name;
$unpaid['amount'] += (($entry->amount_max + $entry->amount_min) / 2); $unpaid['amount'] += (($entry->amount_max + $entry->amount_min) / 2);
} else { } else {
$amount = floatval($journal->transactions[0]->amount); $amount = $journal->getAmount();
$amount = $amount < 0 ? $amount * -1 : $amount;
$paid['items'][] = $journal->description; $paid['items'][] = $journal->description;
$paid['amount'] += $amount; $paid['amount'] += $amount;
} }

View File

@ -17,6 +17,7 @@
{{HTML::style('assets/stylesheets/metisMenu/metisMenu.min.css')}} {{HTML::style('assets/stylesheets/metisMenu/metisMenu.min.css')}}
{{HTML::style('assets/stylesheets/sbadmin/sb.css')}} {{HTML::style('assets/stylesheets/sbadmin/sb.css')}}
{{HTML::style('assets/stylesheets/fa/css/font-awesome.min.css')}} {{HTML::style('assets/stylesheets/fa/css/font-awesome.min.css')}}
<link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
@yield('styles') @yield('styles')
<!--[if lt IE 9]> <!--[if lt IE 9]>

View File

@ -1,4 +1,4 @@
google.load('visualization', '1.1', {'packages': ['corechart', 'sankey', 'table']}); google.load('visualization', '1.1', {'packages': ['corechart', 'bar','sankey', 'table']});
function googleLineChart(URL, container) { function googleLineChart(URL, container) {
$.getJSON(URL).success(function (data) { $.getJSON(URL).success(function (data) {
@ -48,7 +48,7 @@ function googleBarChart(URL, container) {
/* /*
Create a new google charts object. Create a new google charts object.
*/ */
var chart = new google.visualization.BarChart(document.getElementById(container)); var chart = new google.charts.Bar(document.getElementById(container));
/* /*
Draw it: Draw it:
@ -78,8 +78,7 @@ function googleColumnChart(URL, container) {
/* /*
Create a new google charts object. Create a new google charts object.
*/ */
var chart = new google.visualization.ColumnChart(document.getElementById(container)); var chart = new google.charts.Bar(document.getElementById(container));
/* /*
Draw it: Draw it:
*/ */

View File

@ -12,13 +12,32 @@ var defaultLineChartOptions = {
height: '80%' height: '80%'
}, },
height: 400, height: 400,
vAxis: {format: '\u20AC #'} vAxis: {format: '\u20AC #'},
colors: ["#4285f4", "#db4437", "#f4b400", "#0f9d58", "#ab47bc", "#00acc1", "#ff7043", "#9e9d24", "#5c6bc0", "#f06292", "#00796b", "#c2185b"],
hAxis: {
textStyle: {
color: '#838383',
fontName: 'Roboto',
fontSize: '12'
},
gridlines: {
color: 'transparent'
}
},
vAxis: {
textStyle: {
color: '#838383',
fontName: 'Roboto',
fontSize: '12'
}
}
}; };
var defaultBarChartOptions = { var defaultBarChartOptions = {
height: 400, height: 400,
bars: 'horizontal',
hAxis: {format: '\u20AC #'}, hAxis: {format: '\u20AC #'},
chartArea: { chartArea: {
left: 75, left: 75,
@ -29,7 +48,7 @@ var defaultBarChartOptions = {
legend: { legend: {
position: 'none' position: 'none'
} },
}; };
var defaultColumnChartOptions = { var defaultColumnChartOptions = {
@ -43,7 +62,7 @@ var defaultColumnChartOptions = {
vAxis: {format: '\u20AC #'}, vAxis: {format: '\u20AC #'},
legend: { legend: {
position: 'none' position: 'none'
} },
}; };
var defaultPieChartOptions = { var defaultPieChartOptions = {
@ -56,7 +75,8 @@ var defaultPieChartOptions = {
height: 200, height: 200,
legend: { legend: {
position: 'none' position: 'none'
} },
colors: ["#4285f4", "#db4437", "#f4b400", "#0f9d58", "#ab47bc", "#00acc1", "#ff7043", "#9e9d24", "#5c6bc0", "#f06292", "#00796b", "#c2185b"]
}; };
var defaultSankeyChartOptions = { var defaultSankeyChartOptions = {