First rendering draft

This commit is contained in:
knsv 2015-02-20 16:22:37 +01:00
parent 2512666f49
commit 1b016bd412
1 changed files with 281 additions and 333 deletions

View File

@ -1,91 +1,40 @@
var w = 1600;
var h = 800;
var gantt = require('./parser/gantt').parser;
gantt.yy = require('./ganttDb');
var d3 = require('./d3');
var svg = d3.selectAll(".svg")
module.exports.draw = function (text, id) {
gantt.yy.clear();
gantt.parse(text);
console.log(gantt.yy.getTasks());
var w = 1200;
var h = 400;
var svg = d3.select('#'+id)
.attr("width", w)
.attr("height", h);
/*var svg = d3.selectAll(".svg")
//.selectAll("svg")
.append("svg")
.attr("width", w)
.attr("height", h)
.attr("class", "svg");
.attr("class", "svg");*/
// http://codepen.io/anon/pen/azLvWR
var taskArray = [
{
task: "conceptualize",
type: "development",
startTime: "2013-1-28", //year/month/day
endTime: "2013-2-1",
details: "This actually didn't take any conceptualization"
},
{
task: "sketch",
type: "development",
startTime: "2013-2-1",
endTime: "2013-2-6",
details: "No sketching either, really"
},
{
task: "color profiles",
type: "development",
startTime: "2013-2-6",
endTime: "2013-2-9"
},
{
task: "HTML",
type: "coding",
startTime: "2013-2-2",
endTime: "2013-2-6",
details: "all three lines of it"
},
{
task: "write the JS",
type: "coding",
startTime: "2013-2-6",
endTime: "2013-2-9"
},
{
task: "advertise",
type: "promotion",
startTime: "2013-2-9",
endTime: "2013-2-12",
details: "This counts, right?"
},
{
task: "spam links",
type: "promotion",
startTime: "2013-2-12",
endTime: "2013-2-14"
},
{
task: "eat",
type: "celebration",
startTime: "2013-2-8",
endTime: "2013-2-13",
details: "All the things"
},
{
task: "crying",
type: "development",
startTime: "2013-2-13",
endTime: "2013-2-16"
},
];
var taskArray = gantt.yy.getTasks();
var dateFormat = d3.time.format("%Y-%m-%d");
// Set timescale
var timeScale = d3.time.scale()
.domain([d3.min(taskArray, function(d) {return dateFormat.parse(d.startTime);}),
d3.max(taskArray, function(d) {return dateFormat.parse(d.endTime);})])
.domain([d3.min(taskArray, function (d) {
return dateFormat.parse(d.startTime);
}),
d3.max(taskArray, function (d) {
return dateFormat.parse(d.endTime);
})])
.range([0, w - 150]);
var categories = [];
@ -102,7 +51,7 @@ categories = checkUnique(categories);
makeGant(taskArray, w, h);
var title = svg.append("text")
.text("Gantt Chart Process")
.text(gantt.yy.getTitle())
.attr("x", w / 2)
.attr("y", 25)
.attr("text-anchor", "middle")
@ -110,7 +59,6 @@ var title = svg.append("text")
.attr("fill", "#009FFC");
function makeGant(tasks, pageWidth, pageHeight) {
var barHeight = 20;
@ -264,7 +212,6 @@ function drawRects(theArray, theGap, theTopPad, theSidePad, theBarHeight, theCol
});
}
@ -355,3 +302,4 @@ function getCounts(arr) {
function getCount(word, arr) {
return getCounts(arr)[word] || 0;
}
};