Blank space at the end in Gantt chart


I am getting too much blank space while rendering Gantt chart. Gantt chart is taking 100% height of page, but ideally its height should be auto. It should depends on the content of chart. css Height:auto property is not working. Attached snap for ref


There is an autosize configuration of Gantt that forces Gantt chart to automatically change its size to show all tasks without scrolling: ;
The gantt.config.autosize = "y" affects on the height of the Gantt container.
Please check the example in the following snippet:


Thanks for your response.

I have tried this property, but we are loosing scroll bar here.

My requirement is, If data is more than page size, then scroll bar should be automatically visible. And if data is less than page size then scroll bar will be hidden and gantt should consume only required height (depends on data) instead of full page.


Gantt doesn’t provide built-in functionality to do this. You can implement it in a custom solution. When you load/parse the data, you need to calculate the height of the Gantt container and compare it with your required height of the page.
You can calculate the height of Gantt container in the following way:

let containerHeight = gantt.config.scale_height + gantt.config.row_height * gantt.getVisibleTaskCount();

And you can use onBeforeDataRender handler, to set the required height of Gantt container before data is rendered on the page: ;
Please check the example of how it might be implemented:


Thanks for your reply. I have written custom solution to calculate height of gantt control and adjusted it according to container height.