summaryrefslogtreecommitdiff
path: root/assets/js/components/chart-project-cumulative-flow.js
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-11-21 23:16:18 -0500
committerFrederic Guillot <fred@kanboard.net>2016-11-21 23:16:18 -0500
commitb9ab163344f1ed3a2232c7d273b20d86c25a2735 (patch)
tree042a9bba744d172a75823349805b0e96ac14c220 /assets/js/components/chart-project-cumulative-flow.js
parent25272afa9b383adbf22e1c7631f0b1f841fa8d0f (diff)
Move chart task time column to components
Diffstat (limited to 'assets/js/components/chart-project-cumulative-flow.js')
-rw-r--r--assets/js/components/chart-project-cumulative-flow.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/assets/js/components/chart-project-cumulative-flow.js b/assets/js/components/chart-project-cumulative-flow.js
new file mode 100644
index 00000000..aa150397
--- /dev/null
+++ b/assets/js/components/chart-project-cumulative-flow.js
@@ -0,0 +1,49 @@
+KB.component('chart-project-cumulative-flow', function (containerElement, options) {
+
+ this.render = function () {
+ var metrics = options.metrics;
+ var columns = [];
+ var groups = [];
+ var categories = [];
+ var inputFormat = d3.time.format("%Y-%m-%d");
+ var outputFormat = d3.time.format(options.dateFormat);
+
+ for (var i = 0; i < metrics.length; i++) {
+
+ for (var j = 0; j < metrics[i].length; j++) {
+
+ if (i == 0) {
+ columns.push([metrics[i][j]]);
+
+ if (j > 0) {
+ groups.push(metrics[i][j]);
+ }
+ }
+ else {
+
+ columns[j].push(metrics[i][j]);
+
+ if (j == 0) {
+ categories.push(outputFormat(inputFormat.parse(metrics[i][j])));
+ }
+ }
+ }
+ }
+
+ KB.el(containerElement).add(KB.el('div').attr('id', 'chart').build());
+
+ c3.generate({
+ data: {
+ columns: columns,
+ type: 'area-spline',
+ groups: [groups]
+ },
+ axis: {
+ x: {
+ type: 'category',
+ categories: categories
+ }
+ }
+ });
+ };
+});