Page 1 of 1

[REACT] Time dimension switch, similar to calendar function

Posted: Wed May 18, 2022 5:36 pm
by zhang

Can gantt charts switch time dimensions, like calendar views, by week, month, season, year? Or can the same functionality be implemented in some other form?


Re: [REACT] Time dimension switch, similar to calendar function

Posted: Wed May 18, 2022 10:15 pm
by mats

Can you please share some screenshots of the type of views you are looking for?


Re: [REACT] Time dimension switch, similar to calendar function

Posted: Thu May 19, 2022 1:53 am
by zhang

The link below is a screenshot of other Gantt chart products, and the areas marked in red are the ones I want. Can it be done?

https://sm.ms/image/5rIG9LiAkjEB86H


Re: [REACT] Time dimension switch, similar to calendar function

Posted: Fri May 20, 2022 7:23 am
by alex.l

Gantt has ViewPresets. It's set of zoom levels with some pre-defined set of headers. You can specify your own set or choose from pre-defined. Together with desired visible date range for timeAxis (startDate/endDate), I assume you will have that you want.
Links to docs:
https://bryntum.com/docs/gantt/api/Gantt/view/Gantt#config-viewPreset
https://bryntum.com/docs/gantt/api/Scheduler/preset/ViewPreset
https://bryntum.com/docs/gantt/api/Scheduler/preset/PresetManager
https://bryntum.com/docs/gantt/api/Scheduler/view/TimelineBase#function-setTimeSpan


Re: [REACT] Time dimension switch, similar to calendar function

Posted: Fri May 20, 2022 7:20 pm
by zhang

Which method can change the default viewpreset? I can't find the corresponding method in the document


Re: [REACT] Time dimension switch, similar to calendar function

Posted: Fri May 20, 2022 8:31 pm
by mats

Re: [REACT] Time dimension switch, similar to calendar function

Posted: Sat May 21, 2022 5:22 am
by zhang

I may not be making myself clear, but I want the following effect:
By default viewPreset is weekandYear
When I click today, viewPreset is Hourandday
https://sm.ms/image/lnwbQihST2YzvOj


Re: [REACT] Time dimension switch, similar to calendar function

Posted: Sat May 21, 2022 11:20 am
by zhang

Or something like this:
Viewpreset is still WeekandYear when the user clicks "Today", but it rolls the current time back into visual range by default
https://sm.ms/image/Zdn5tCXAFSYMaBy


Re: [REACT] Time dimension switch, similar to calendar function

Posted: Mon May 23, 2022 9:45 am
by alex.l

By default viewPreset is weekandYear
When I click today, viewPreset is Hourandday

What problems you have to get that behaviour?
See example above how to change viewPreset:

gantt.viewPreset = 'dayAndWeek'

How to get scheduler instance?

There is misunderstanding because you code example we posted. You don't need scheduler instance since you use Gantt. instance in your code is that you need. The Gantt is based on the Scheduler, so mixin from Scheduler also available in Gantt.

Viewpreset is still WeekandYear when the user clicks "Today", but it rolls the current time back into visual range by default

Did you try https://bryntum.com/docs/gantt/api/Scheduler/view/TimelineBase#function-setTimeSpan ?
Or maybe
https://bryntum.com/docs/gantt/api/Scheduler/view/mixin/TimelineScroll#function-scrollToDate
https://bryntum.com/docs/gantt/api/Scheduler/view/mixin/TimelineScroll#function-scrollToNow