Chart.js: Unable to change the aspect ratio option on a chart that is already rendered

Created on 13 May 2019  Â·  2Comments  Â·  Source: chartjs/Chart.js

Expected Behavior

Updating the chart aspect ratio option and calling update() should change the graphs aspect ratio.

Current Behavior

The aspect ratio does not change

Steps to Reproduce (for bugs)

Click the button, the graph title will correctly update but the aspect ratio does not.
https://codepen.io/gmattgreenfield/pen/pmENqP

Context

Users are able to set dashboard cards as 50%, 75% or 100% of the page width. I want to change the aspect ratio based on the width they choose and have it update in real time.

Environment

  • Chart.js version: latest
  • Browser name and version: all
bug

Most helpful comment

You can work around that by setting aspectRatio directly on chart (instead of options) and calling resize
https://codepen.io/kurkle/pen/GaWLpg

All 2 comments

You can work around that by setting aspectRatio directly on chart (instead of options) and calling resize
https://codepen.io/kurkle/pen/GaWLpg

@kurkle - thank you very much for the work around.

Was this page helpful?
0 / 5 - 0 ratings