Toggle between line chart and bar chart

I’m rendering Bar chart and line chart at the same time on different div element when the page loads. I want to toggle between the charts. I have 2 buttons on top of the div element, that allow users to select between the bar chart or line chart.

When user selects Bar char it hides the line chart div by making the style.display = ‘none’ and thus only shows bar chart. But some times when user tries to toggle between them, chart doesn’t occupy the entire height and width of div element.

I’m using “responsive: true” at the time of creating those charts.

Is there any solution to this problem?. I don’t want to recreate the chart when user toggles between them.