gantt days

This commit is contained in:
STEINNI
2026-08-29 14:43:51 +00:00
parent 5a8f93e376
commit 4625067352
3 changed files with 57 additions and 13 deletions
+27 -3
View File
@@ -142,9 +142,10 @@ class BZgantt extends Buildoz {
const flow = { "nodes": [], "links": [] }
let curY = 0
let endIdx = 0
for(const task of this.tasks){
const startIdx = this.getDayIndex(firstDate, new Date(task.start))
const endIdx = this.getDayIndex(firstDate, new Date(task.end))
endIdx = this.getDayIndex(firstDate, new Date(task.end))
flow.nodes.push({
"nodeType": "bar",
"id": task.id,
@@ -163,11 +164,15 @@ class BZgantt extends Buildoz {
}
curY += this.rowHeight
}
return flow
return([flow, endIdx])
}
refresh(){
this.ul.innerHTML = ''
this.headerLi = document.createElement('li')
this.headerLi.classList.add('header')
this.ul.appendChild(this.headerLi)
for(const task of this.tasks){
const li = document.createElement('li')
li.textContent = task.name
@@ -183,7 +188,26 @@ class BZgantt extends Buildoz {
}
this.style.setProperty('--tasks-width', Math.ceil(maxWidth) + 'px')
const flow = this.buildFlow()
const [flow, endIdx] = this.buildFlow()
let dayDate = new Date(this.tasks[0].start)
for(let idx=0; idx<=endIdx; idx++){
const dayDiv = document.createElement('div')
dayDiv.classList.add('day')
dayDiv.style.left = `calc(var(--chart-left) + ${idx * this.dayWidth}px)`
dayDiv.style.width = this.dayWidth + 'px'
dayDiv.innerHTML = '&nbsp;' + dayDate.getDate()
if(dayDate.toISOString().substring(0,10) == (new Date()).toISOString().substring(0,10)) dayDiv.classList.add('today')
dayDiv.setAttribute('title', new Intl.DateTimeFormat('fr-FR', {
timeZone: 'Europe/Paris',
day: '2-digit',
month: '2-digit',
year: '2-digit'
}).format(dayDate))
dayDate.setDate(dayDate.getDate() + 1)
this.headerLi.appendChild(dayDiv)
}
this.graflow.loadFlow({
"nodesFile": this.nodesfile,
"flow": flow