[REACT] Time dimension switch, similar to calendar function
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?
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?
Can you please share some screenshots of the type of views you are looking for?
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?
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
Which method can change the default viewpreset? I can't find the corresponding method in the document
Just set:
scheduler.viewPreset = 'dayAndWeek'
https://bryntum.com/docs/scheduler/api/Scheduler/view/mixin/TimelineViewPresets#property-viewPreset
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
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
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