Our state of the art Gantt chart


Post by Animal »

There's a slight bug in Gantt's startup which places what should be the center date at the right edge. I can fix that.

But the issue is that you have copy/pasted the "Advanced" example which was not designed to use infinite scroll, and seems to have a bug:

    onProjectStartDateChange(obj:any){
        this.gantt = this.ganttComponent.instance;
        if (!obj.oldValue) { // ignore initial set
            return;
        }

        this.gantt.startDate = DateHelper.add(obj.value, -1, 'week');

        (this.gantt.project as any).setStartDate(obj.value);
    }

this.gantt.startDate = sets the start point of the horizontal time axis.

Infinite scroll expands the scrollable range of the gantt so that it scrolls a lot before it needs to shift its viewport.

So on startup it looks like this:

Screenshot 2023-04-05 at 16.45.56.png
Screenshot 2023-04-05 at 16.45.56.png (119.63 KiB) Viewed 55 times

See how narrow the thumb is? The visible task bars are in the center, but there's a lot of space either side.

The gantt.startDate is Sun Jul 22 2018, way off to the left:

Screenshot 2023-04-05 at 16.53.57.png
Screenshot 2023-04-05 at 16.53.57.png (200.96 KiB) Viewed 55 times

(I meant 2019, not 2919, but the image is fixed now)

So when this is set, the range of the horizontal time axis stays the same. The same size time range is covered, but it starts at the project start. So it's way off left.

Do not set gantt.startDate.


Post by Animal »

You probably want this:

    onStartDateChange({ value, oldValue }) {
        if (value) {
            // Move one week before the project start to the left edge (block : 'start')
            gantt.scrollToDate(DateHelper.add(value, -1, 'week'), {
                block : 'start'
            });

            this.gantt.project.setStartDate(value);
        }
    }

Post by johanbrodin »

Thank you for the elaboration!

Testing more on 5.3.2 I could not trigger the bug on any more on "zoom to fit" and your code snip-it fixed the problem on the start date widget. So all to all a happy camper here and thank you for the good support!


Post Reply