I am having an issue with the setTimeSpan function where my new time range will flash on the chart for a moment, and then be replaced by the earliest start date, and latest end date of my data.
setTimeSpan is the right API, just for the initial display - it's more efficient to set the start / end directly on your gantt config. In your test case, nothing is configured on the Gantt timeline - this puts it into a mode where it reads start/end from the data to show project contents.
Okay thanks, that fixes this issue, but now there's another error. When I set startDate and endDate on the gantt object and then call setTimeSpan with a date range before my initial start and end I see this error:
Uncaught Error: Invalid start/end dates. Start date must less than end date. Start date: Fri Jan 01 2021 00:00:00 GMT-0500 (Eastern Standard Time). End date: Fri Jan 01 2021 00:00:00 GMT-0500 (Eastern Standard Time).
at TimeAxis.internalOnReconfigure (webpack-internal:///./node_modules/@bryntum/gantt/gantt.module.js:555)
at TimeAxis.reconfigure (webpack-internal:///./node_modules/@bryntum/gantt/gantt.module.js:555)
at TimeAxis.setTimeSpan (webpack-internal:///./node_modules/@bryntum/gantt/gantt.module.js:555)
at Object.setEndDate (webpack-internal:///./node_modules/@bryntum/gantt/gantt.module.js:570)
at Object.changeEndDate (webpack-internal:///./node_modules/@bryntum/gantt/gantt.module.js:570)
at Object.set (webpack-internal:///./node_modules/@bryntum/gantt/gantt.module.js:498)
at applyPropValue (webpack-internal:///./node_modules/@bryntum/gantt-react/WrapperHelper.js:140)
at eval (webpack-internal:///./node_modules/@bryntum/gantt-react/WrapperHelper.js:556)
at Array.forEach (<anonymous>)
at shouldComponentUpdate (webpack-internal:///./node_modules/@bryntum/gantt-react/WrapperHelper.js:551)
For example, I set startDate to Jan 1 2021 and endDate to Dec 31 2021 and then try calling setTimeSpan with the range Nov 1 2020 - Dec 1 2020.
Looks like setTimeSpan checks the validity of the new date range before it's completely set.