mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
New charts + tests.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user