Today line for gantt chart

This commit is contained in:
knsv
2015-02-25 00:07:13 +01:00
parent 182729e015
commit 0955c4c428
7 changed files with 200 additions and 64 deletions

View File

@@ -58,4 +58,5 @@ body {
border-width: 10px;
border-bottom-color: #FA283D;
top: -20px;
}
}

View File

@@ -51,7 +51,8 @@ module.exports.draw = function (text, id) {
d3.max(taskArray, function (d) {
return d.endTime;
})])
.range([0, w - 150]);
.rangeRound([0, w - 150])
.nice(d3.time.monday);
var categories = [];
@@ -88,6 +89,7 @@ module.exports.draw = function (text, id) {
makeGrid(sidePadding, topPadding, pageWidth, pageHeight);
drawRects(tasks, gap, topPadding, sidePadding, barHeight, colorScale, pageWidth, pageHeight);
vertLabels(gap, topPadding, sidePadding, barHeight, colorScale);
drawToday(sidePadding, topPadding, pageWidth, pageHeight);
}
@@ -229,11 +231,37 @@ module.exports.draw = function (text, id) {
function makeGrid(theSidePad, theTopPad, w, h) {
var xAxis = d3.svg.axis()
.scale(timeScale)
.orient('bottom')
//.ticks(d3.time.days, 5)
.tickSize(-h + theTopPad + conf.gridLineStartPadding, 0, 0);
//.tickFormat(d3.time.format('%d %b'));
.scale(timeScale)
.orient('bottom')
.ticks(d3.time.weeks, 1)
.tickSize(-h + theTopPad + conf.gridLineStartPadding, 0, 0)
.tickFormat(d3.time.format.multi([
[".%L", function (d) {
return d.getMilliseconds();
}],
[":%S", function (d) {
return d.getSeconds();
}],
["%I:%M", function (d) {
return d.getMinutes();
}],
["%I %p", function (d) {
return d.getHours();
}],
["%a %d", function (d) {
return d.getDay() && d.getDate() != 2;
}],
["%b %d", function (d) {
return d.getDate() != 2;
}],
["%B", function (d) {
return d.getMonth();
}],
["%Y", function () {
return true;
}]
]))
;
var grid = svg.append('g')
.attr('class', 'grid')
@@ -286,6 +314,20 @@ module.exports.draw = function (text, id) {
}
function drawToday(theSidePad, theTopPad, w, h) {
var todayG = svg.append('g')
.attr('class', 'today')
var todayLine = todayG.append("line")
.attr("x1", timeScale(new Date('2014-01-13')) + theSidePad)
.attr("x2", timeScale(new Date('2014-01-13')) + theSidePad)
.attr("y1", conf.titleTopMargin)
.attr("y2", h-conf.titleTopMargin)
.attr('class', 'today')
;
}
//from this stackexchange question: http://stackoverflow.com/questions/1890203/unique-for-arrays-in-javascript
function checkUnique(arr) {
var hash = {}, result = [];