summaryrefslogtreecommitdiff
path: root/assets/js/components
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2017-02-11 19:42:17 -0500
committerFrederic Guillot <fred@kanboard.net>2017-02-11 19:42:17 -0500
commitc5caff7ef79f1440ff26c84eed2dbc8254122f36 (patch)
treee6dbd39514d1210d43615f2ef1516c613019058f /assets/js/components
parent2c4509641103fa94a31c89e0e9f1a2d6088e57b1 (diff)
Fix CFD chart (stack wrongly ordered)
Diffstat (limited to 'assets/js/components')
-rw-r--r--assets/js/components/chart-project-burndown.js19
-rw-r--r--assets/js/components/chart-project-cumulative-flow.js25
2 files changed, 23 insertions, 21 deletions
diff --git a/assets/js/components/chart-project-burndown.js b/assets/js/components/chart-project-burndown.js
index abcab925..d94b3550 100644
--- a/assets/js/components/chart-project-burndown.js
+++ b/assets/js/components/chart-project-burndown.js
@@ -8,25 +8,24 @@ KB.component('chart-project-burndown', function (containerElement, options) {
var outputFormat = d3.time.format(options.dateFormat);
for (var i = 0; i < metrics.length; i++) {
-
for (var j = 0; j < metrics[i].length; j++) {
+ var currentValue = metrics[i][j];
if (i === 0) {
- columns.push([metrics[i][j]]);
+ if (j > 0) {
+ columns.push([currentValue]);
+ }
} else {
- columns[j + 1].push(metrics[i][j]);
-
if (j > 0) {
+ columns[j].push(currentValue);
- if (columns[0][i] === undefined) {
+ if (typeof columns[0][i] === 'undefined') {
columns[0].push(0);
}
- columns[0][i] += metrics[i][j];
- }
-
- if (j === 0) {
- categories.push(outputFormat(inputFormat.parse(metrics[i][j])));
+ columns[0][i] += currentValue;
+ } else {
+ categories.push(outputFormat(inputFormat.parse(currentValue)));
}
}
}
diff --git a/assets/js/components/chart-project-cumulative-flow.js b/assets/js/components/chart-project-cumulative-flow.js
index 7b258230..9a8e6659 100644
--- a/assets/js/components/chart-project-cumulative-flow.js
+++ b/assets/js/components/chart-project-cumulative-flow.js
@@ -9,21 +9,19 @@ KB.component('chart-project-cumulative-flow', function (containerElement, option
var outputFormat = d3.time.format(options.dateFormat);
for (var i = 0; i < metrics.length; i++) {
-
for (var j = 0; j < metrics[i].length; j++) {
+ var currentValue = metrics[i][j];
if (i === 0) {
- columns.push([metrics[i][j]]);
-
if (j > 0) {
- groups.push(metrics[i][j]);
+ groups.push(currentValue);
+ columns.push([currentValue]);
}
} else {
-
- columns[j].push(metrics[i][j]);
-
- if (j === 0) {
- categories.push(outputFormat(inputFormat.parse(metrics[i][j])));
+ if (j > 0) {
+ columns[j - 1].push(currentValue);
+ } else {
+ categories.push(outputFormat(inputFormat.parse(currentValue)));
}
}
}
@@ -33,9 +31,14 @@ KB.component('chart-project-cumulative-flow', function (containerElement, option
c3.generate({
data: {
- columns: columns,
+ // Example: [["Column1", 1, 2, 3], ["Column2", 1, 2, 3]]
+ // Note: values are reversed to make sure the columns are stacked in the right order
+ columns: columns.reverse(),
type: 'area-spline',
- groups: [groups]
+ groups: [groups],
+
+ // Note: Use specified order otherwise C3js reorder series
+ order: null
},
axis: {
x: {