New charts + tests.

This commit is contained in:
James Cole
2014-07-09 12:56:06 +02:00
parent 138044fb41
commit 5645f7a893
9 changed files with 301 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
function drawChart(id,URL,opt) {
function drawChart(id,URL,type,opt) {
$.getJSON(URL).success(function (data) {
$(id).removeClass('loading');
@@ -7,7 +7,17 @@ function drawChart(id,URL,opt) {
var money = new google.visualization.NumberFormat({decimalSymbol: ',', groupingSymbol: '.', prefix: '€ '});
money.format(gdata, 1);
var gID = id.substring(1);
var chart = new google.visualization.LineChart(document.getElementById(gID));
var chart;
switch(type) {
default:
case 'LineChart':
chart = new google.visualization.LineChart(document.getElementById(gID));
break;
case 'PieChart':
chart = new google.visualization.PieChart(document.getElementById(gID));
break;
}
chart.draw(gdata, opt);

View File

@@ -3,6 +3,7 @@ google.setOnLoadCallback(chartCallback);
function chartCallback() {
drawAccountChart();
drawExtraCharts();
}
function drawAccountChart() {
@@ -34,9 +35,26 @@ function drawAccountChart() {
// draw it!
drawChart('#' + holderID, URL, opt);
drawChart('#' + holderID, URL, 'LineChart', opt);
});
//var URL = 'chart/home';
//drawChart('#chart',URL,opt);
}
function drawExtraCharts() {
var opt = {
legend: {
position: 'none'
},
chartArea: {
width: 300,
height: 300
},
};
drawChart('#budgetChart', 'chart/home/budgets', 'PieChart', opt);
drawChart('#categoryChart', 'chart/home/categories','PieChart', opt);
drawChart('#beneficiaryChart', 'chart/home/beneficiaries','PieChart', opt);
}