Hide and collapse x-Axis when no data available

I would like to create a graph using chart.js where the x-Axis shows only those ticks for whose there is data available. Of course I could do some preprocessing of the data and eliminate those labels and corresponding 0-values in the data. But once the graph is displayed, i would like to hide/show some datasets and i want the graph to collapse eliminating the zero-values.

All datasets visible:

Graph with all four years of data

Two datasets hidden, some months disappeared from x-Axis:

Graph with only two datasets visible

(To get this picture, i cheated the input data in Excel)

I haven’t found any axis property that would achieve this. Ticks can be shown or hidden, but can the space on the axis collapse so there is no gap?
Is there any way to do it with a callback on each hide/show of a dataset?

I need this as a “workaround solution” for my other question here