1 namespace('kivi.ChartReport', function(ns) {
6 ns.background_colors = function() { return [
7 'rgba(255, 0, 0, 0.2)',
9 'rgba(0, 127, 0, 0.2)',
10 'rgba(0, 0, 191, 0.2)',
11 'rgba(191, 0, 0, 0.2)',
12 'rgba(0, 255, 0, 0.2)',
13 'rgba(0, 63, 0, 0.2)',
14 'rgba(0, 0, 127, 0.2)',
15 'rgba(127, 0, 0, 0.2)',
16 'rgba(0, 191, 0, 0.2)',
17 'rgba(0, 0, 255, 0.2)',
21 ns.border_colors = function() { return [
22 'rgba(255, 0, 0, 1.0)',
23 'rgba(63, 0, 0, 1.0)',
24 'rgba(0, 127, 0, 1.0)',
25 'rgba(0, 0, 191, 1.0)',
26 'rgba(191, 0, 0, 1.0)',
27 'rgba(0, 255, 0, 1.0)',
28 'rgba(0, 63, 0, 1.0)',
29 'rgba(0, 0, 127, 1.0)',
30 'rgba(127, 0, 0, 1.0)',
31 'rgba(0, 191, 0, 1.0)',
32 'rgba(0, 0, 255, 1.0)',
36 ns.chart = function() {
37 $(ns.data.datasets).each(function(idx, elt) {
38 $(elt).each(function(idx) {elt[idx] = kivi.parse_amount('' + elt[idx]);console.log(elt[idx]);});
42 for (let i = 0; i < ns.data.data_labels.length; i++) {
44 $(ns.data.datasets).each(function(idx, elt) {set.push(elt[i]);});
46 datasets.push({label: ns.data.data_labels[i],
48 backgroundColor: ns.background_colors()[i % ns.background_colors().length],
49 borderColor: ns.border_colors()[i % ns.border_colors().length],
55 const chart = new Chart(ctx, {
58 labels: ns.data.labels,
71 ns.debug = function() {
72 console.log("bb: labels: "); console.log(ns.data.labels);
73 console.log("bb: datasets: "); console.log(ns.data.datasets);
74 console.log("bb: data_labels: "); console.log(ns.data.data_labels);
78 kivi.ChartReport.debug();
79 kivi.ChartReport.chart();