Files
firefly-iii/public/assets/javascript/firefly/gcharts.js

190 lines
5.7 KiB
JavaScript
Raw Normal View History

google.load('visualization', '1.1', {'packages': ['corechart', 'bar', 'sankey', 'table']});
2014-11-22 07:30:46 +01:00
function googleLineChart(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: '.',
2014-12-24 06:10:39 +01:00
prefix: currencyCode + ' '
});
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:
*/
2014-11-22 07:30:46 +01:00
chart.draw(gdata, options || defaultLineChartOptions);
}).fail(function () {
$('#' + container).addClass('google-chart-error');
});
} else {
console.log('No container found called "' + container + '"');
}
2014-10-29 10:30:52 +01:00
}
2014-11-22 07:30:46 +01:00
function googleBarChart(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: '.',
2014-12-24 06:10:39 +01:00
prefix: currencyCode + ' '
});
for (i = 1; i < gdata.getNumberOfColumns(); i++) {
money.format(gdata, i);
}
/*
Create a new google charts object.
*/
var chart = new google.charts.Bar(document.getElementById(container));
/*
Draw it:
*/
2014-11-22 07:30:46 +01:00
chart.draw(gdata, options || defaultBarChartOptions);
}).fail(function () {
$('#' + container).addClass('google-chart-error');
});
} else {
console.log('No container found called "' + container + '"');
}
2014-10-29 10:30:52 +01:00
}
2014-11-22 07:30:46 +01:00
function googleColumnChart(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: '.',
2014-12-24 06:10:39 +01:00
prefix: currencyCode + ' '
});
for (i = 1; i < gdata.getNumberOfColumns(); i++) {
money.format(gdata, i);
}
/*
Create a new google charts object.
*/
var chart = new google.charts.Bar(document.getElementById(container));
/*
Draw it:
*/
2014-11-22 07:30:46 +01:00
chart.draw(gdata, options || defaultColumnChartOptions);
}).fail(function () {
$('#' + container).addClass('google-chart-error');
});
} else {
console.log('No container found called "' + container + '"');
}
2014-10-29 10:30:52 +01:00
}
2014-11-22 07:30:46 +01:00
function googleComboChart(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: '.',
2014-12-24 06:10:39 +01:00
prefix: currencyCode + ' '
});
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:
*/
2014-11-22 07:30:46 +01:00
chart.draw(gdata, options || defaultComboChartOptions);
}).fail(function () {
$('#' + container).addClass('google-chart-error');
});
} else {
console.log('No container found called "' + container + '"');
}
}
2014-11-22 07:30:46 +01:00
function googlePieChart(URL, container, options) {
if ($('#' + container).length == 1) {
$.getJSON(URL).success(function (data) {
/*
Get the data from the JSON
*/
gdata = new google.visualization.DataTable(data);
2014-10-30 18:06:29 +01:00
/*
Format as money
*/
var money = new google.visualization.NumberFormat({
decimalSymbol: ',',
groupingSymbol: '.',
2014-12-24 06:10:39 +01:00
prefix: currencyCode + ' '
});
for (i = 1; i < gdata.getNumberOfColumns(); i++) {
money.format(gdata, i);
}
2014-10-30 18:06:29 +01:00
/*
Create a new google charts object.
*/
var chart = new google.visualization.PieChart(document.getElementById(container));
2014-10-30 18:06:29 +01:00
/*
Draw it:
*/
2014-11-22 07:30:46 +01:00
chart.draw(gdata, options || defaultPieChartOptions);
}).fail(function () {
$('#' + container).addClass('google-chart-error');
});
} else {
console.log('No container found called "' + container + '"');
}
}