imovator
Posts: 6
Joined: Mon Jul 04, 2022 1:21 am

Can't adjust chart aspect ratio?

hello.
I am drawing a chart using highcharts-vue and I have a question.

Official API Sample
https://jsfiddle.net/wuvt1873/1/

In the sample above, it says that the height can be adjusted with a ratio, but the width cannot be adjusted in the same way.
Is there any way to adjust the width by proportion?
hubert.k
Posts: 1164
Joined: Mon Apr 11, 2022 11:48 am

Re: Can't adjust chart aspect ratio?

Hello imovator!
Welcome to our forum and thanks for contacting us with your question!

By using a height property you can set every aspect ratio, which you would like to. As you can read in API documentation chart.width is an explicit width for the chart. By default (when null) the width is calculated from the offset width of the containing element. For example, in the demo below, you can a 4/3 aspect ratio.

Demo: https://jsfiddle.net/BlackLabel/go427cwL/

Feel free to ask any further questions.
Kind regards!
Hubert Kozik
Highcharts Developer
imovator
Posts: 6
Joined: Mon Jul 04, 2022 1:21 am

Re: Can't adjust chart aspect ratio?

thank you
It is implemented as a responsive web, and it comes out well when I adjust the ratio of the sample.
hubert.k
Posts: 1164
Joined: Mon Apr 11, 2022 11:48 am

Re: Can't adjust chart aspect ratio?

imovator,
If you set the aspect ratio using height property and using width as responsive 100% it will also work. I have prepared a demo for you with aspect ratio 4/3 and width set to 100% in Vue.js, please check it below.

Demo: https://codesandbox.io/s/highcharts-vue ... ked-4v89ph

Kind regards!
Hubert Kozik
Highcharts Developer

Return to “Highcharts Usage”