mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-03 11:08:28 +00:00
Fix budget overview for #2593
This commit is contained in:
16
public/v1/js/ff/budgets/show.js
vendored
16
public/v1/js/ff/budgets/show.js
vendored
@@ -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');
|
||||
}
|
||||
|
||||
});
|
||||
|
1
public/v1/js/ff/charts.defaults.js
vendored
1
public/v1/js/ff/charts.defaults.js
vendored
@@ -97,6 +97,7 @@ var defaultChartOptions = {
|
||||
ticks: {
|
||||
callback: function (tickValue) {
|
||||
"use strict";
|
||||
// use first symbol or null:
|
||||
return accounting.formatMoney(tickValue);
|
||||
|
||||
},
|
||||
|
53
public/v1/js/ff/charts.js
vendored
53
public/v1/js/ff/charts.js
vendored
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user