Extended reports

This commit is contained in:
Sander Dorigo
2014-11-07 22:06:30 +01:00
parent 139d985904
commit ab4f34a96b
6 changed files with 134 additions and 5 deletions

View File

@@ -89,6 +89,35 @@ function googleColumnChart(URL, container) {
});
}
function googleStackedColumnChart(URL, container) {
$.getJSON(URL).success(function (data) {
/*
Get the data from the JSON
*/
gdata = new google.visualization.DataTable(data);
/*
Format as money
*/
var money = new google.visualization.NumberFormat({decimalSymbol: ',', groupingSymbol: '.', prefix: '\u20AC '});
for (i = 1; i < gdata.getNumberOfColumns(); i++) {
money.format(gdata, i);
}
/*
Create a new google charts object.
*/
var chart = new google.visualization.ColumnChart(document.getElementById(container));
/*
Draw it:
*/
chart.draw(gdata, defaultStackedColumnChartOptions);
}).fail(function () {
$('#' + container).addClass('google-chart-error');
});
}
function googlePieChart(URL, container) {
$.getJSON(URL).success(function (data) {
/*

View File

@@ -12,7 +12,6 @@ var defaultLineChartOptions = {
height: '80%'
},
height: 400,
vAxis: {format: '\u20AC #'},
colors: ["#4285f4", "#db4437", "#f4b400", "#0f9d58", "#ab47bc", "#00acc1", "#ff7043", "#9e9d24", "#5c6bc0", "#f06292", "#00796b", "#c2185b"],
hAxis: {
textStyle: {
@@ -29,7 +28,8 @@ var defaultLineChartOptions = {
color: '#838383',
fontName: 'Roboto2',
fontSize: '12'
}
},
format: '\u20AC #'
}
@@ -65,6 +65,40 @@ var defaultColumnChartOptions = {
},
};
var defaultStackedColumnChartOptions = {
height: 400,
chartArea: {
left: 50,
top: 10,
width: '85%',
height: '80%'
},
vAxis: {format: '\u20AC #'},
legend: {
position: 'none'
},
isStacked: true,
colors: ["#4285f4", "#db4437", "#f4b400", "#0f9d58", "#ab47bc", "#00acc1", "#ff7043", "#9e9d24", "#5c6bc0", "#f06292", "#00796b", "#c2185b"],
vAxis: {
textStyle: {
color: '#838383',
fontName: 'Roboto2',
fontSize: '12'
},
format: '\u20AC #'
},
hAxis: {
textStyle: {
color: '#838383',
fontName: 'Roboto2',
fontSize: '12'
},
gridlines: {
color: 'transparent'
}
},
};
var defaultPieChartOptions = {
chartArea: {
left: 0,

View File

@@ -4,4 +4,5 @@ google.setOnLoadCallback(drawChart);
function drawChart() {
googleColumnChart('chart/reports/income-expenses/' + year, 'income-expenses-chart');
googleColumnChart('chart/reports/income-expenses-sum/' + year, 'income-expenses-sum-chart')
googleStackedColumnChart('chart/reports/budgets/' + year, 'budgets');
}