Can I toggle the histogram?

I have a gantt chart with a histogram. I’m trying to find a way to toggle the display of histogram on and off the page. I don’t see any examples of this, how can it be achieved?

So the only way I found was to change the layout = …myLayout. Is there another way to handle this?

The only way to toggle the histogram view is to switch between layout configurations. And you need to reinitialize Gantt to apply the changes.
Here is the snippet:

If you don’t want to have different layout configurations, you can modify the existing one:

Thank you, the toggle is perfect!

If I reinit the gantt to apply the changes. SHould I reinit all the events as well? I noticed addTaskLayer doesn’t fire anymore if I take the first approach.

You don’t need to detach all events and attach them again.
But you need to recreate the additional layer after Gantt is reinitialized:
Here is an example of how it works: