Fix budget overview for #2593

This commit is contained in:
James Cole
2019-09-15 06:56:20 +02:00
parent 8776d47545
commit 18399a9b05
7 changed files with 169 additions and 59 deletions

View File

@@ -23,17 +23,15 @@
$(function () {
"use strict";
if (budgetLimitID > 0) {
lineChart(budgetChartUri, 'budgetOverview');
}
if (budgetLimitID === 0) {
columnChart(budgetChartUri, 'budgetOverview');
}
// other three charts:
if (budgetLimitID > 0) {
otherCurrencyLineChart(budgetChartUri, 'budgetOverview', currencySymbol);
pieChart(expenseCategoryUri, 'budget-cat-out');
pieChart(expenseAssetUri, 'budget-asset-out');
pieChart(expenseExpenseUri, 'budget-expense-out');
}
if (budgetLimitID === 0) {
columnChart(budgetChartUri, 'budgetOverview');
pieChart(expenseCategoryUri, 'budget-cat-out');
pieChart(expenseAssetUri, 'budget-asset-out');
pieChart(expenseExpenseUri, 'budget-expense-out');
}
});

View File

@@ -97,6 +97,7 @@ var defaultChartOptions = {
ticks: {
callback: function (tickValue) {
"use strict";
// use first symbol or null:
return accounting.formatMoney(tickValue);
},

View File

@@ -92,6 +92,57 @@ function lineChart(URI, container) {
drawAChart(URI, container, chartType, options, colorData);
}
/**
* Overrules the currency the line chart is drawn in.
*
* @param URI
* @param container
*/
function otherCurrencyLineChart(URI, container, currencySymbol) {
"use strict";
var colorData = true;
var newOpts = {
scales: {
xAxes: [
{
gridLines: {
display: false
},
ticks: {
// break ticks when too long.
callback: function (value, index, values) {
return formatLabel(value, 20);
}
}
}
],
yAxes: [{
display: true,
//hello: 'fresh',
ticks: {
callback: function (tickValue) {
"use strict";
// use first symbol or null:
return accounting.formatMoney(tickValue);
},
beginAtZero: true
}
}]
},
};
//var options = $.extend(true, newOpts, defaultChartOptions);
var options = $.extend(true, defaultChartOptions, newOpts);
console.log(options);
var chartType = 'line';
drawAChart(URI, container, chartType, options, colorData);
}
/**
* Function to draw a chart with double Y Axes and stacked columns.
*
@@ -305,7 +356,6 @@ function drawAChart(URI, container, chartType, options, colorData) {
return;
}
$.getJSON(URI).done(function (data) {
containerObj.removeClass('general-chart-error');
if (data.labels.length === 0) {
@@ -324,7 +374,6 @@ function drawAChart(URI, container, chartType, options, colorData) {
return;
}
if (colorData) {
data = colorizeData(data);
}