Removed most, if not all, references to Google Charts (the tables part).

This commit is contained in:
James Cole
2014-11-14 08:52:58 +01:00
parent b388dcc7d4
commit 96ab112b22
15 changed files with 10 additions and 861 deletions

View File

@@ -226,109 +226,4 @@ function googleSankeyChart(URL, container) {
} else {
console.log('No container found called "' + container + '"');
}
}
/**
* TODO fix this method so the layout is nice and dandy.
* @param URL
* @param container
*/
function googleTable(URL, container) {
if ($('#' + container).length == 1) {
$.getJSON(URL).success(function (data) {
/*
Get the data from the JSON
*/
var gdata = new google.visualization.DataTable(data);
/*
Create a new google charts object.
*/
var chart = new google.visualization.Table(document.getElementById(container));
/*
Do something with formatters:
*/
var x = gdata.getNumberOfColumns();
var columnsToHide = new Array;
var URLFormatter = new google.visualization.PatternFormat('<a href="{0}">{1}</a>');
var EditButtonFormatter = new google.visualization.PatternFormat('<div class="btn-group btn-group-xs"><a href="{0}" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a><a class="btn btn-xs btn-danger" href="{1}"><span class="glyphicon glyphicon-trash"></span></a></div>');
var money = new google.visualization.NumberFormat({
decimalSymbol: ',',
groupingSymbol: '.',
prefix: '\u20AC '
});
for (var i = 0; i < x; i++) {
var label = gdata.getColumnLabel(i);
/*
Format a string using the previous column as URL.
*/
if (label == 'Description' || label == 'From' || label == 'Name' || label == 'To' || label == 'Budget' || label == 'Category') {
URLFormatter.format(gdata, [i - 1, i], i);
columnsToHide.push(i - 1);
}
if (label == 'ID') {
EditButtonFormatter.format(gdata, [i + 1, i + 2], i);
columnsToHide.push(i + 1, i + 2);
}
/*
Format with buttons:
*/
/*
Format as money
*/
if (label == 'Amount' || label == 'Balance' || label == 'Minimum amount' || label == 'Maximum amount') {
money.format(gdata, i);
}
}
//var formatter = new google.visualization.PatternFormat('<a href="#">{1}</a>');
//formatter.format(gdata, [5, 6], 6);
//formatter.format(gdata, [7, 8], 8);
var view = new google.visualization.DataView(gdata);
// hide certain columns:
view.hideColumns(columnsToHide);
/*
Draw it:
*/
chart.draw(view, defaultTableOptions);
}).fail(function () {
$('#' + container).addClass('google-chart-error');
});
} else {
console.log('No container found called "' + container + '"');
}
}
/**
*
* @param URL
* @param container
*/
function googleTablePaged(URL, container) {
var query, options;
query = new google.visualization.Query(URL);
objContainer = document.getElementById(container);
options = {'pageSize': 5};
query.abort();
var tableQueryWrapper = new TableQueryWrapper(query, objContainer, options);
tableQueryWrapper.sendAndDraw();
}