mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Finished category report.
This commit is contained in:
@@ -66,57 +66,6 @@ function colorizeData(data) {
|
||||
return newData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param URI
|
||||
* @param container
|
||||
* @param chartType
|
||||
* @param options
|
||||
* @param colorData
|
||||
*/
|
||||
function drawAChart(URI, container, chartType, options, colorData) {
|
||||
if ($('#' + container).length === 0) {
|
||||
console.log('No container called ' + container + ' was found.');
|
||||
return;
|
||||
}
|
||||
|
||||
// var result = true;
|
||||
// if (options.beforeDraw) {
|
||||
// result = options.beforeDraw(data, {url: URL, container: container});
|
||||
// }
|
||||
// if (result === false) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
$.getJSON(URI).done(function (data) {
|
||||
|
||||
if (colorData) {
|
||||
data = colorizeData(data);
|
||||
}
|
||||
|
||||
if (allCharts.hasOwnProperty(container)) {
|
||||
console.log('Will draw updated ' + chartType + ' chart');
|
||||
allCharts[container].data.datasets = data.datasets;
|
||||
allCharts[container].data.labels = data.labels;
|
||||
allCharts[container].update();
|
||||
} else {
|
||||
// new chart!
|
||||
console.log('Will draw new ' + chartType + 'chart');
|
||||
var ctx = document.getElementById(container).getContext("2d");
|
||||
allCharts[container] = new Chart(ctx, {
|
||||
type: chartType,
|
||||
data: data,
|
||||
options: options
|
||||
});
|
||||
}
|
||||
|
||||
}).fail(function () {
|
||||
console.log('Failed to draw ' + chartType + ' in container ' + container);
|
||||
$('#' + container).addClass('general-chart-error');
|
||||
});
|
||||
console.log('URL for ' + chartType + ' chart : ' + URL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to draw a line chart:
|
||||
* @param URI
|
||||
@@ -182,3 +131,60 @@ function pieChart(URI, container) {
|
||||
drawAChart(URI, container, chartType, options, colorData);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param URI
|
||||
* @param container
|
||||
* @param chartType
|
||||
* @param options
|
||||
* @param colorData
|
||||
*/
|
||||
function drawAChart(URI, container, chartType, options, colorData) {
|
||||
if ($('#' + container).length === 0) {
|
||||
console.log('No container called ' + container + ' was found.');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$.getJSON(URI).done(function (data) {
|
||||
|
||||
|
||||
if (data.labels.length === 0) {
|
||||
console.log(chartType + " chart in " + container + " has no data.");
|
||||
// remove the chart container + parent
|
||||
var holder = $('#' + container).parent().parent();
|
||||
if (holder.hasClass('box')) {
|
||||
// remove box
|
||||
holder.remove();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (colorData) {
|
||||
data = colorizeData(data);
|
||||
}
|
||||
|
||||
if (allCharts.hasOwnProperty(container)) {
|
||||
console.log('Will draw updated ' + chartType + ' chart');
|
||||
allCharts[container].data.datasets = data.datasets;
|
||||
allCharts[container].data.labels = data.labels;
|
||||
allCharts[container].update();
|
||||
} else {
|
||||
// new chart!
|
||||
console.log('Will draw new ' + chartType + 'chart');
|
||||
var ctx = document.getElementById(container).getContext("2d");
|
||||
allCharts[container] = new Chart(ctx, {
|
||||
type: chartType,
|
||||
data: data,
|
||||
options: options
|
||||
});
|
||||
}
|
||||
|
||||
}).fail(function () {
|
||||
console.log('Failed to draw ' + chartType + ' in container ' + container);
|
||||
$('#' + container).addClass('general-chart-error');
|
||||
});
|
||||
console.log('URL for ' + chartType + ' chart : ' + URL);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,10 @@ $(function () {
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// trigger list thing
|
||||
listLengthInitial();
|
||||
|
||||
});
|
||||
|
||||
function currencySelect(e) {
|
||||
@@ -108,3 +112,30 @@ accounting.settings = {
|
||||
decimal: "."
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function listLengthInitial() {
|
||||
"use strict";
|
||||
$('.overListLength').hide();
|
||||
$('.listLengthTrigger').unbind('click').click(triggerList)
|
||||
}
|
||||
|
||||
function triggerList(e) {
|
||||
"use strict";
|
||||
var link = $(e.target);
|
||||
var table = link.parent().parent().parent().parent();
|
||||
console.log('data-hidden = ' + table.attr('data-hidden'));
|
||||
if (table.attr('data-hidden') === 'no') {
|
||||
// hide all elements, return false.
|
||||
table.find('.overListLength').hide();
|
||||
table.attr('data-hidden', 'yes');
|
||||
link.text(showFullList);
|
||||
return false;
|
||||
}
|
||||
// show all, return false
|
||||
table.find('.overListLength').show();
|
||||
table.attr('data-hidden', 'no');
|
||||
link.text(showOnlyTop);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -43,29 +43,6 @@ function drawChart() {
|
||||
getBoxAmounts();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Removes a chart box 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'];
|
||||
|
||||
@@ -27,32 +27,6 @@ function triggerInfoClick() {
|
||||
$('.firefly-info-button').unbind('click').click(clickInfoButton);
|
||||
}
|
||||
|
||||
function listLengthInitial() {
|
||||
"use strict";
|
||||
$('.overListLength').hide();
|
||||
$('.listLengthTrigger').unbind('click').click(triggerList)
|
||||
}
|
||||
|
||||
function triggerList(e) {
|
||||
"use strict";
|
||||
var link = $(e.target);
|
||||
var table = link.parent().parent().parent().parent();
|
||||
console.log('data-hidden = ' + table.attr('data-hidden'));
|
||||
if (table.attr('data-hidden') === 'no') {
|
||||
// hide all elements, return false.
|
||||
table.find('.overListLength').hide();
|
||||
table.attr('data-hidden', 'yes');
|
||||
link.text(showFullList);
|
||||
return false;
|
||||
}
|
||||
// show all, return false
|
||||
table.find('.overListLength').show();
|
||||
table.attr('data-hidden', 'no');
|
||||
link.text(showOnlyTop);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function clickInfoButton(e) {
|
||||
"use strict";
|
||||
// find all data tags, regardless of what they are:
|
||||
|
||||
Reference in New Issue
Block a user