So sorry for the delay, I really need to log in more, lol.
Not entierly sure why that is happinging. But it works fine on my current version of the script.
the update take more inputs from feilds on the page with the gannt chart to allow for adjsuting the Axis ticks based on the format descrbed here.
in the example below, “tick amount” holds the number and “tickScale” holds the day/week/month parts of the pattern Described in the link. along the way i must have halso fixed whatever was causing your issue
I hope this helps!
Gannt config
axis_format:: %m-%d-%y
axis tick
tickAmount:: 6
tickScale:: month
Gannt render
```dataviewjs
function textParser(taskText){//input text,return object
let du= taskText.indexOf("⏱️")
let durText = "";
if (du>0){
let i=taskText.slice(du).search(/\d+(d|w|m)/);
durText=taskText.substr(du+i, 3)
}
let miletext = taskText.indexOf("🚩") > -1 ? 1 : 0;
let d = taskText.indexOf("📅");
let DueText="";
if(d>=0){
let i=taskText.slice(d).search(/([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/);
DueText=taskText.substr(d+i,10);
}
let sch = taskText.indexOf("⏳");
let scheduledText="";
if(sch>0){
let i=taskText.slice(sch).search(/([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/);
scheduledText=taskText.substr(sch+i,10);
}
let st = taskText.indexOf("🛫");
let startText="";
if(st>0){
let i=taskText.slice(st).search(/([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/);
startText=taskText.substr(st+i,10);
}
let h = taskText.indexOf("⏫");
let m = taskText.indexOf("🔼");
let l =taskText.indexOf("🔽");
let PriorityText="";
if(h>0){
PriorityText="High";
}
if(m>0){
PriorityText="Medium";
}
if(l>0){
PriorityText="Low";
}
const emojisIndex= [d,sch,st,h,m,l,du]
const presentEmojiIndex= emojisIndex.filter(x => x > 0);
let nameText=taskText.slice(0,Math.min(...presentEmojiIndex)).trim();
//console.log(taskText,Math.min(...presentEmojiIndex))
return {
name: nameText,
due: DueText,
start:startText,
scheduled:scheduledText,
priority:PriorityText,
duration:durText,
miletext: miletext
}
}
function loopGantt (pageArray){
let querySections=``;
let today = new Date().toISOString().slice(0, 10)
for (let i = 0; i < pageArray.length; i++) {
let taskQuery=``;
var taskArray = pageArray[i].file.tasks;
//parse name, due, start, completion, scheduled,priority from task text to objects
var compObjs = pageArray[i].file.tasks.completed
var completionArray = [];
for (let s=0; s< compObjs.length;s++){
completionArray[s] =compObjs[s]}
var taskObjs=[];
for (let j=0; j< taskArray.length;j++){
taskObjs[j] = textParser(taskArray[j].text)
}
//determine the mermaid task parameters
for (let j=0; j< taskObjs.length;j++){
let theTask = taskObjs[j];
// create stats variable
function getLastLesserIndex(arr, currentIndex) {
let currentValue = arr[currentIndex];
for (let i = currentIndex - 1; i >= 0; i--) {
if (arr[i] < currentValue) {
return i;
}
}
return -1;
}
let SecNum = "sect" + (i+1)+ "-"
let taskNum= "task" + (j+1) +", "
let Ind = pageArray[i].file.tasks.position.start.col
let IndUp = getLastLesserIndex(Ind,j)
let aft = ""
if ((taskArray[j].parent != null) && (IndUp > 0)){aft+= "after "+ SecNum+ "task"+(IndUp+1)} else if(taskArray[j].parent != null) {aft+= "after "+ SecNum+ "task"+(j)} else {aft +="" }
var stats = ""
if (completionArray[j] == true ){
stats += "done, "
} else { stats+= "active, "}
// test stuff
var critStat = ""
if (theTask.priority === "High" ) {critStat = "crit"+ ", "} else { critStat = ""}
var start = ""
if (taskArray[j].parent != null) {start += aft +","} else{start+= theTask.start+","}
var end = ""
if(taskArray[j].duration = null) {end += theTask.duration}
else {end += theTask.due}
let mile = ""
if (taskObjs[j].miletext>0) {mile+= "milestone, "}
//
taskQuery+= theTask.name + ` : ` +mile+ critStat+ stats+ SecNum+taskNum+ start+ end+ theTask.duration+`\n\n`;
};
querySections+= `section `+pageArray[i].file.name+`\n\n`+taskQuery;
};
return querySections
}
let tick1 = dv.current().tickAmount // define first part of tick interval (number)
let tick2 = dv.current().tickScale // define the scale of axis tick (day, week, month, year)
const Mermaid = `gantt
title Gannt Charts (v0.5.5)
\n ` + `dateFormat YYYY-MM-DD` + ` \n ` +
`axisFormat `+ dv.current().axis_format + ` \n ` + `tickInterval ` + tick1 + tick2+
`\n `;
// set the path of your project folder below
dv.paragraph('```mermaid\n' + Mermaid + loopGantt(dv.pages('#gannt and [[]]'))+ '\n```');
// render gannt page with checkboxes
//digonstic rendiering. uncomment to get a render of the merimaid text and otehr diagnostic stuff
//dv.paragraph('```' + Mermaid + loopGantt(dv.pages('#gannt and [[]]'))+ '\n ```');

