Our state of the art Gantt chart


Post by aatrash89 »

Dear,

viewtopic.php?t=30587&hilit=clear+baselines&start=10

I am writing to follow up on the ticket we opened previously regarding the issues we are experiencing with the clear baselines.

We have encountered another issue related to the set baselines. When I set Baseline 3 for the first time without having Baselines 1 and 2 set previously, Bryntum automatically sets Baselines 1 and 2 to 3. This issue is very important to us, and we would greatly appreciate any updates you may have on the resolution process.


Post by ghulam.ghous »

Hey,

I am writing to follow up on the ticket we opened previously regarding the issues we are experiencing with the clear baselines.

That is a feature request and nobody else has requested it yet. So it is unlikely that it will get resolved soon. You can sponsor the development, if you want to fast track it.

Can you please describe the steps to replicate this behaviour on our end in our online demo? How you are setting the baselines?


Post by aatrash89 »

Dear,

please find the video below , and i used this code to set baseline from a menu selection .

function handleBaselineClick(index, gantt) {
   
if (gantt && gantt.taskStore) { // Store the selected baseline index globally or in a shared state window.selectedBaselineIndex = index; // Example: Using a global variable // Refresh the grid to update renderers with the new baseline index gantt.refresh(); // Trigger refresh (or use gantt.someGrid.refresh() if specific grid needs updating) // Optionally, set the baseline in the task store new Promise((resolve, reject) => { try { gantt.taskStore.setBaseline(index); // Example API for setting the baseline resolve(); } catch (error) { reject(error); } }).catch(error => { console.error("Error setting baseline:", error); }); } else { console.error("Gantt or taskStore is undefined"); } }
Attachments
bandicam 2024-12-09 10-21-46-121.mp4
(294.96 KiB) Downloaded 10 times
baselines menu.png
baselines menu.png (7.53 KiB) Viewed 156 times

Post by aatrash89 »

That is a feature request and nobody else has requested it yet. So it is unlikely that it will get resolved soon. You can sponsor the development, if you want to fast track it.

what about clear baseline ?


Post by ghulam.ghous »

what about clear baseline ?

That response was about the ticket https://github.com/bryntum/support/issues/10191 which is related to clearing baselines.

please find the video below , and i used this code to set baseline from a menu selection .

I do not see any data related to baselines. Please add your code in to this online demo https://bryntum.com/products/gantt/examples/advanced/ and please provide us clear steps to reproduce this issue. What is the initial value of index in the above code snippet?


Post by aatrash89 »

this is the menu:

   menu: [
       {
           text: userLang === 'ar-JO' ? arJO.toolbar?.baseline1 : enUS.toolbar?.baseline1,
           menu: [
               {
                   text: userLang === 'ar-JO' ? arJO.toolbar?.setBaseline : enUS.toolbar?.setBaseline,
                   onItem: () => handleBaselineClick(1, gantt) // Set Baseline 1
               },
               {
                   text: userLang === 'ar-JO' ? arJO.toolbar?.clearBaseline : enUS.toolbar?.clearBaseline,
                   onItem: () => handleClearBaselineClick(1, gantt) // Clear Baseline 1
               }
           ]
       },
       {
           text: userLang === 'ar-JO' ? arJO.toolbar?.baseline2 : enUS.toolbar?.baseline2,
           menu: [
               {
                   text: userLang === 'ar-JO' ? arJO.toolbar?.setBaseline : enUS.toolbar?.setBaseline,
                   onItem: () => handleBaselineClick(2, gantt) // Set Baseline 2
               },
               {
                   text: userLang === 'ar-JO' ? arJO.toolbar?.clearBaseline : enUS.toolbar?.clearBaseline,
                   onItem: () => handleClearBaselineClick(2, gantt) // Clear Baseline 2
               }
           ]
       },
       {
           text: userLang === 'ar-JO' ? arJO.toolbar?.baseline3 : enUS.toolbar?.baseline3,
           menu: [
               {
                   text: userLang === 'ar-JO' ? arJO.toolbar?.setBaseline : enUS.toolbar?.setBaseline,
                   onItem: () => handleBaselineClick(3, gantt) // Set Baseline 3
               },
               {
                   text: userLang === 'ar-JO' ? arJO.toolbar?.clearBaseline : enUS.toolbar?.clearBaseline,
                   onItem: () => handleClearBaselineClick(3, gantt) // Clear Baseline 3
               }
           ]
       },
       {
           text: userLang === 'ar-JO' ? arJO.toolbar?.baseline4 : enUS.toolbar?.baseline4,
           menu: [
               {
                   text: userLang === 'ar-JO' ? arJO.toolbar?.setBaseline : enUS.toolbar?.setBaseline,
                   onItem: () => handleBaselineClick(4, gantt) // Set Baseline 3
               },
               {
                   text: userLang === 'ar-JO' ? arJO.toolbar?.clearBaseline : enUS.toolbar?.clearBaseline,
                   onItem: () => handleClearBaselineClick(4, gantt) // Clear Baseline 3
               }
           ]
       },
       {
           text: userLang === 'ar-JO' ? arJO.toolbar?.baseline5 : enUS.toolbar?.baseline5,
           menu: [
               {
                   text: userLang === 'ar-JO' ? arJO.toolbar?.setBaseline : enUS.toolbar?.setBaseline,
                   onItem: () => handleBaselineClick(5, gantt) // Set Baseline 3
               },
               {
                   text: userLang === 'ar-JO' ? arJO.toolbar?.clearBaseline : enUS.toolbar?.clearBaseline,
                   onItem: () => handleClearBaselineClick(5, gantt) // Clear Baseline 3
               }
           ]
       },

   ]

and when i select from menu to set or clear ,
the set / clear baseline functions as below :

// Helper function to handle setting baseline
function handleBaselineClick(index, gantt) {
    console.log("handleBaselineClick", index);

if (gantt && gantt.taskStore) {
    // Store the selected baseline index globally or in a shared state
    window.selectedBaselineIndex = index; // Example: Using a global variable

    // Refresh the grid to update renderers with the new baseline index
    gantt.refresh(); // Trigger refresh (or use gantt.someGrid.refresh() if specific grid needs updating)

    // Optionally, set the baseline in the task store
    new Promise((resolve, reject) => {
        try {
            gantt.taskStore.setBaseline(index); // Example API for setting the baseline
            resolve();
        } catch (error) {
            reject(error);
        }
    }).catch(error => {
        console.error("Error setting baseline:", error);
    });
} else {
    console.error("Gantt or taskStore is undefined");
}
}

// Helper function to handle clear baseline

function handleClearBaselineClick(index, gantt) {
    console.log(`Clearing baseline ${index}`);

if (gantt && gantt.taskStore) {
    gantt.suspendRefresh();

    const tasksToUpdate = [];
    const zeroBasedIndex = index - 1; // Convert to zero-based index

    gantt.taskStore.forEach(task => {
        if (task && task.baselines && typeof task.baselines.allCount === 'number') {
            if (zeroBasedIndex < task.baselines.allCount) {
                const baselineToRemove = task.baselines.getAt(zeroBasedIndex);
                if (baselineToRemove) {
                    task.baselines.remove(baselineToRemove);
                    console.log(`Baseline ${index} removed for task:`, task);
                    tasksToUpdate.push(task);
                } else {
                    console.warn(`Baseline at index ${zeroBasedIndex} not found for task:`, task);
                }
            } else {
                console.warn(`Baseline index ${zeroBasedIndex} out of range for task:`, task);
            }
        } else {
            console.warn(`Invalid task or baselines for task:`, task);
        }
    });

    if (tasksToUpdate.length > 0) {
        gantt.project.commitAsync()
            .then(() => {
                console.log(`Successfully removed baseline ${index} for all tasks.`);
            })
            .catch(error => {
                console.error(`Failed to remove Baseline ${index}:`, error);
            });
    } else {
        console.log(`No tasks needed updating for baseline ${index}.`);
    }

    gantt.resumeRefresh();
} else {
    console.error("Gantt or taskStore is undefined");
}
}

the video show only the scenario and how the baselines filled .
Did I answer your question?


Post by ghulam.ghous »

Hello,

Yes you did answer my question but there are few things that didn't work on my end. There are lot of undefined things in the code you shared for menu.

I do get the idea. But let's take a step back and try to understand what you are trying to achieve. You are using setBaseline method to set the baseline. But this method sets the baseline for all the records on the taskStore. I have tried this behaviour in our online demo https://bryntum.com/products/gantt/examples/baselines/

And I was able to set baseline 3 without any issues:

Screen Recording 2024-12-09 at 1.19.42 PM.mov
(18.09 MiB) Downloaded 10 times

Did I missed something?


Post by aatrash89 »

Hey ghulam.ghous,
the issue appear

When I set Baseline 3 for the first time without having Baselines 1 and 2 set previously, Bryntum automatically sets Baselines 1 and 2 to 3.


Post by ghulam.ghous »

Ok. I have attached another clip below. The startDate for the baseLine 3 is initially 13 and then it changes to 14 after setting the setBaseline being called on store. Are you referring to this behaviour? Please can you describe bit more what do you mean by this: Bryntum automatically sets Baselines 1 and 2 to 3.

Screen Recording 2024-12-09 at 2.49.10 PM.mov
(8.62 MiB) Downloaded 11 times

Post by aatrash89 »

I wanted to clarify something regarding the baselines in our project and the case i face. If there are no existing baselines, is it possible to set baseline 3, even if baseline 1 and 2 have not been established?

my case is when i have no baselines before , can you review the video attached above please?


Post Reply