Jason
Jason

Reputation: 13

Google Charts: Is there a way to re-render the chart when the screen changes sizes? (javascript only please)

I am trying to make a javascript google chart that renders and when I test responsiveness the chart does not move until I refresh the screen and the chart re-renders. Where I see this becoming a problem is turning an Ipad or phone to portrait or resizing of a window and the chart no longer being centered. Is there a way to re-render the Charts on the screen size changing?

Upvotes: 1

Views: 1312

Answers (1)

WhiteHat
WhiteHat

Reputation: 61275

sure, just need to re-draw when the the 'resize' event occurs,
something like...

window.addEventListener('resize', drawChart, false);

function drawChart() {
  chart.draw();
}

Upvotes: 2

Related Questions