Small optimalizations.

This commit is contained in:
James Cole
2015-01-25 08:28:59 +01:00
parent a24c90eae8
commit 9327430484
8 changed files with 118 additions and 28 deletions

View File

@@ -113,6 +113,43 @@ function googleColumnChart(URL, container, options) {
}
}
function googleStackedColumnChart(URL, container, options) {
if ($('#' + container).length == 1) {
$.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: currencyCode + ' '
});
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, options || defaultStackedColumnChartOptions);
}).fail(function () {
$('#' + container).addClass('google-chart-error');
});
} else {
console.log('No container found called "' + container + '"');
}
}
function googleComboChart(URL, container, options) {
if ($('#' + container).length == 1) {
$.getJSON(URL).success(function (data) {

View File

@@ -96,20 +96,11 @@ var defaultStackedColumnChartOptions = {
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',
@@ -120,6 +111,14 @@ var defaultStackedColumnChartOptions = {
color: 'transparent'
}
},
vAxis: {
textStyle: {
color: '#838383',
fontName: 'Roboto2',
fontSize: '12'
},
format: '\u20AC #'
}
};
var defaultPieChartOptions = {

View File

@@ -4,10 +4,6 @@ if (typeof(google) != 'undefined') {
googleColumnChart('chart/reports/income-expenses/' + year, 'income-expenses-chart');
googleColumnChart('chart/reports/income-expenses-sum/' + year, 'income-expenses-sum-chart')
$.each($('.budgets'), function (i, v) {
var holder = $(v);
var id = holder.data('id');
googleColumnChart('chart/budget/' + id + '/spending/' + year, 'budgets-' + id);
});
googleStackedColumnChart('chart/budgets/spending/' + year, 'budgets');
}
}