in src/gantt.ts [2412:2494]
private taskDaysOffRender(
taskSelection: Selection<Task>,
taskConfigHeight: number): void {
const taskDaysOffColor: string = this.viewModel.settings.daysOff.fill;
const taskDaysOffShow: boolean = this.viewModel.settings.daysOff.show;
taskSelection
.selectAll(Selectors.TaskDaysOff.selectorName)
.remove();
if (taskDaysOffShow) {
let tasksDaysOff: Selection<TaskDaysOff, Task> = taskSelection
.selectAll(Selectors.TaskDaysOff.selectorName)
.data((d: Task) => {
let tasksDaysOff: TaskDaysOff[] = [];
if (!d.children && d.daysOffList) {
for (let i = 0; i < d.daysOffList.length; i++) {
let currentDaysOffItem = d.daysOffList[i];
let startOfLastDay = new Date(+d.end);
startOfLastDay.setHours(0, 0, 0);
if (currentDaysOffItem[0].getTime() < startOfLastDay.getTime()) {
tasksDaysOff.push({
id: d.index,
daysOff: d.daysOffList[i]
});
}
}
}
return tasksDaysOff;
});
const tasksDaysOffMerged = tasksDaysOff
.enter()
.append("path")
.merge(tasksDaysOff);
tasksDaysOffMerged.classed(Selectors.TaskDaysOff.className, true);
const getTaskRectDaysOffWidth = (task: TaskDaysOff) => {
let width = 0;
if (this.hasNotNullableDates) {
const startDate: Date = task.daysOff[0];
const startTime: number = startDate.getTime();
const endDate: Date = new Date(startTime + (task.daysOff[1] * MillisecondsInADay));
width = this.taskDurationToWidth(startDate, endDate);
}
return width;
};
const drawTaskRectDaysOff = (task: TaskDaysOff) => {
let x = this.hasNotNullableDates ? this.timeScale(task.daysOff[0]) : 0,
y = Gantt.getBarYCoordinate(task.id, taskConfigHeight) + (task.id + 1) * this.getResourceLabelTopMargin(),
height = Gantt.getBarHeight(taskConfigHeight),
radius = Gantt.RectRound,
width = getTaskRectDaysOffWidth(task);
if (width < radius) {
x = x - width / 2;
}
if (width < 2 * radius) {
return drawNotRoundedRectByPath(x, y, width, height);
}
return drawRoundedRectByPath(x, y, width, height, radius);
};
tasksDaysOffMerged
.attr("d", (task: TaskDaysOff) => drawTaskRectDaysOff(task))
.style("fill", taskDaysOffColor)
.attr("width", (task: TaskDaysOff) => getTaskRectDaysOffWidth(task));
tasksDaysOff
.exit()
.remove();
}
}