After reading up more on React functional component, and hooks, I realise that gantt.init should have been inside useEffect instead (correct me if I’m wrong). So I placed it there, and now the toolbar is showing but the chart becomes 0 height.
Hello Joseph,
Thank you for sharing your project.
I don’t specialize in React so I won’t be able to tell you how it should work.
But I can suggest that you can specify Gantt height in CSS:
#gantt{
height: 500px;
}
When Gantt height is 100% it checks the parent height parameter. When there is no parent, that parameter is 0.
From your example, I can see and understand clearly, but when I tried it on my project, it just doesn’t work as I intended.
If you pull again my latest commit to my GitHub, I have set html, body to 100%. Added a #toolbar with a height of 100px then I want the chart to take the rest of the height. So I tried a couple of way; setting 100%, or auto does not work. It will collapse to 0px height. The only way it works is that if I use px to specify the height.
Hello Joseph,
Looks like, it happens because React requires more complex structure than a regular HTML page.
You can add the following rule to the custom.css file:
#gantt {
height: 100%;
}
Then you need to wrap Gantt into a div that will have 100% width and height and absolute positioning:
Hello Joseph,
Looks like, it happens because there is margin for the body element. So when Gantt stretches its width to 100% of the page, it doesn’t fit the screen. If you remove the margin, the second scrollbar disappears: