Skip to content
Advertisement

Make google chart responsive

Im using google charts in a project but im having a hard time to make them responsive.

Iǘe seen other examples on responsive charts but I cant seem to get it to work in my case. All my charts gets rendered and after that their sizes do not change.

If someone can make this chart responsive id appreciate it. Thank you:

JavaScript

Fiddle for the chart: Fiddle

If it could take up a percentage width of a parent it would be great

Advertisement

Answer

The solution was already given online elsewhere.

You need to call your drawChart() function whenever the window is resized to get the desired behaviour. The website flopreynat.com exactly describes this problem and solution (codepen). It describes how this can be done using JQuery:

JavaScript

Using just Javascript, this answer on Stack Exchange by Sohnee describes how to trigger functions upon a resize event:

JavaScript

All credit to both authors of the links above.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement