All new stufs!

This commit is contained in:
Sander Dorigo
2014-10-29 10:30:52 +01:00
parent 8ad0d7af93
commit 2f9c383004
19 changed files with 1114 additions and 10 deletions

View File

@@ -1,8 +1,5 @@
google.load('visualization', '1.0', {'packages': ['corechart']});
/*
If this method has not been defined (yet) it will error out.
*/
function googleLineChart(URL, container) {
$.getJSON(URL).success(function (data) {
/*
@@ -10,16 +7,114 @@ function googleLineChart(URL, container) {
*/
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.LineChart(document.getElementById(container));
/*
Draw it:
Draw it:
*/
chart.draw(gdata, defaultLineChartOptions);
}).fail(function () {
$('#' + container).addClass('google-chart-error');
});
}
function googleBarChart(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.BarChart(document.getElementById(container));
/*
Draw it:
*/
chart.draw(gdata, defaultBarChartOptions);
}).fail(function () {
$('#' + container).addClass('google-chart-error');
});
}
function googleColumnChart(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, defaultColumnChartOptions);
}).fail(function () {
$('#' + container).addClass('google-chart-error');
});
}
function googlePieChart(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.PieChart(document.getElementById(container));
/*
Draw it:
*/
chart.draw(gdata, defaultPieChartOptions);
}).fail(function () {
$('#' + container).addClass('google-chart-error');
});

View File

@@ -1,3 +1,59 @@
var defaultLineChartOptions = {
curveType: 'function',
legend: {
position: 'none'
},
lineWidth: 1,
chartArea: {
left: 50,
top: 10,
width: '85%',
height: '80%'
},
height: 400,
vAxis: {format: '\u20AC #'}
};
var defaultBarChartOptions = {
height: 400,
hAxis: {format: '\u20AC #'},
chartArea: {
left: 75,
top: 10,
width: '100%',
height: '90%'
},
legend: {
position: 'none'
}
};
var defaultColumnChartOptions = {
height: 400,
chartArea: {
left: 50,
top: 10,
width: '85%',
height: '80%'
},
vAxis: {format: '\u20AC #'},
legend: {
position: 'none'
}
};
var defaultPieChartOptions = {
chartArea: {
left: 0,
top: 0,
width: '100%',
height: '100%'
},
height:200,
legend: {
position: 'none'
}
};

View File

@@ -7,6 +7,9 @@ google.setOnLoadCallback(drawChart);
function drawChart() {
console.log(1);
googleLineChart('chart/home/account', 'accounts-chart');
googleBarChart('chart/home/budgets','budgets-chart');
googleColumnChart('chart/home/categories','categories-chart');
googlePieChart('chart/home/recurring','recurring-chart')
}