From 04a06ac6728b3eeefcfdd2468871dea0140c85e3 Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Mon, 30 Mar 2015 12:47:38 +0200 Subject: [PATCH] added experimental gantt diagram --- client/bower.json | 3 ++- client/index.html | 2 ++ src/pert-ui.coffee | 16 +++++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/client/bower.json b/client/bower.json index 19d429d..9e19030 100644 --- a/client/bower.json +++ b/client/bower.json @@ -17,6 +17,7 @@ ], "dependencies": { "vis": "~3.11.0", - "jquery": "~2.1.3" + "jquery": "~2.1.3", + "moment": "~2.9.0" } } diff --git a/client/index.html b/client/index.html index a08aa58..2b5d164 100644 --- a/client/index.html +++ b/client/index.html @@ -15,7 +15,9 @@ +
+ diff --git a/src/pert-ui.coffee b/src/pert-ui.coffee index 01f6543..0f10f35 100644 --- a/src/pert-ui.coffee +++ b/src/pert-ui.coffee @@ -1,8 +1,18 @@ $.get 'data', (d) -> # Serve the server data - list = d - console.log list - buildGraph list + buildTimeline d + buildGraph d + +toDates = (list, startDay) -> + list.map (i) -> + r = content: ""+i.id, id: i.id + if i.startDay? then r.start = moment(startDay).add(i.startDay, 'days').format 'YYYY-MM-DD' + if i.endDay? then r.end = moment(startDay).add(i.endDay, 'days').format 'YYYY-MM-DD' + return r + +buildTimeline = (data) -> + console.log toDates data.activities + timeline = new vis.Timeline (document.getElementById 'timeline'), (toDates data.activities), {} buildGraph = (data) -> nodes = data.days.map (x) -> {id: x, label: ""+x}