mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-22 20:16:22 +00:00
Charts "columnChart" and "stackedColumnChart" now support beforeDraw() which will check the data to see if the chart should be drawn. This cleans up the front page for new users and empty months.
This commit is contained in:
@@ -34,14 +34,37 @@ function drawChart() {
|
||||
"use strict";
|
||||
areaChart('chart/account/frontpage', 'accounts-chart');
|
||||
pieChart('chart/bill/frontpage', 'bills-chart');
|
||||
stackedColumnChart('chart/budget/frontpage', 'budgets-chart');
|
||||
columnChart('chart/category/frontpage', 'categories-chart');
|
||||
columnChart('chart/account/expense', 'expense-accounts-chart');
|
||||
stackedColumnChart('chart/budget/frontpage', 'budgets-chart', {beforeDraw: beforeDrawIsEmpty});
|
||||
columnChart('chart/category/frontpage', 'categories-chart', {beforeDraw: beforeDrawIsEmpty});
|
||||
columnChart('chart/account/expense', 'expense-accounts-chart', {beforeDraw: beforeDrawIsEmpty});
|
||||
|
||||
|
||||
getBoxAmounts();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a chart container if there is nothing for the chart to draw.
|
||||
*
|
||||
* @param data
|
||||
* @param options
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function beforeDrawIsEmpty(data, options) {
|
||||
"use strict";
|
||||
|
||||
// check if chart holds data.
|
||||
if (data.labels.length === 0) {
|
||||
// remove the chart container + parent
|
||||
console.log(options.container + ' appears empty. Removed.');
|
||||
$('#' + options.container).parent().parent().remove();
|
||||
|
||||
// return false so script stops.
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function getBoxAmounts() {
|
||||
"use strict";
|
||||
var boxes = ['in', 'out', 'bills-unpaid', 'bills-paid'];
|
||||
|
Reference in New Issue
Block a user