Some formatting, cleanup, and a new chart.

This commit is contained in:
James Cole
2014-11-18 09:37:54 +01:00
parent 7e8f5c9548
commit eebac2a66d
10 changed files with 87 additions and 28 deletions

View File

@@ -1,5 +1,8 @@
google.load('visualization', '1.1', {'packages': ['corechart', 'bar', 'sankey', 'table']});
/*
TODO manage the combination of default options AND custom options.
*/
function googleLineChart(URL, container) {
if ($('#' + container).length == 1) {
$.getJSON(URL).success(function (data) {
@@ -150,6 +153,43 @@ function googleStackedColumnChart(URL, container) {
}
}
function googleComboChart(URL, container) {
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: '\u20AC '
});
for (i = 1; i < gdata.getNumberOfColumns(); i++) {
money.format(gdata, i);
}
/*
Create a new google charts object.
*/
var chart = new google.visualization.ComboChart(document.getElementById(container));
/*
Draw it:
*/
chart.draw(gdata, defaultComboChartOptions);
}).fail(function () {
$('#' + container).addClass('google-chart-error');
});
} else {
console.log('No container found called "' + container + '"');
}
}
function googlePieChart(URL, container) {
if ($('#' + container).length == 1) {
$.getJSON(URL).success(function (data) {