Some extended code for the category report.

This commit is contained in:
James Cole
2016-11-12 06:48:38 +01:00
parent 32b5a84a0c
commit 6d60d64a82
12 changed files with 716 additions and 20 deletions

View File

@@ -8,6 +8,8 @@
/* globals $, Chart, currencySymbol,mon_decimal_point ,accounting, mon_thousands_sep, frac_digits */
var allCharts = {};
/*
Make some colours:
*/
@@ -29,7 +31,6 @@ var colourSet = [
[240, 98, 146],
[0, 121, 107],
[194, 24, 91]
];
var fillColors = [];
@@ -234,6 +235,11 @@ function lineChart(URL, container, options) {
function areaChart(URL, container, options) {
"use strict";
if ($('#' + container).length === 0) {
console.log('No container called ' + container + ' was found.');
return;
}
$.getJSON(URL).done(function (data) {
var ctx = document.getElementById(container).getContext("2d");
var newData = {};
@@ -358,14 +364,30 @@ function stackedColumnChart(URL, container, options) {
function pieChart(URL, container, options) {
"use strict";
if ($('#' + container).length === 0) {
console.log('No container called ' + container + ' was found.');
return;
}
$.getJSON(URL).done(function (data) {
var ctx = document.getElementById(container).getContext("2d");
new Chart(ctx, {
type: 'pie',
data: data,
options: defaultPieOptions
});
if (allCharts.hasOwnProperty(container)) {
console.log('Will draw updated pie chart');
allCharts[container].data.datasets = data.datasets;
allCharts[container].data.labels = data.labels;
allCharts[container].update();
} else {
// new chart!
console.log('Will draw new pie chart');
var ctx = document.getElementById(container).getContext("2d");
allCharts[container] = new Chart(ctx, {
type: 'pie',
data: data,
options: defaultPieOptions
});
}
}).fail(function () {
$('#' + container).addClass('general-chart-error');