Resizable Charts

Is it possible to make Vaadin Charts resize??

It seems as though they’re perfectly capable of growing into space, but not shrinking back down. Even setting the UI to markAsDirtyRecursive on window resize re-draws everything but the charts themselves.


Your observation is right. In some scenarios Charts do not play well in CSS FlexBox. There are couple of workarounds

Wrap your chart in Div

That trick helps e.g. when Charts are in Board

See here:

In some other scenarios it is even worse and you need to force the Charts reflow by JavaScript call

    	getUI().ifPresent(ui -> ui.getPage().executeJavaScript("Array.from(window.document.getElementsByTagName('vaadin-chart')).forEach( el => el.__reflow());"));        	        	

See example here:

Is this only viable for Vaadin Flow? I’m using V8 and it seems to have the same problem. They grow into free space, but won’t shrink back down again