highcharts / highcharts-vue

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

width set to 100% not working

jonasalberttan opened this issue · comments

I don't if this is a bug or not. But when I tried to set the width to 100% in the chartOptions, it was not working.

chart: {
type: "line",
events: {},
height: 100,
width: "100%",
},

Meanwhile, I tried to set the width to null and it is now working.

width: null,

Hi @jonasalberttan, thanks!

This is not related to the Highcharts-Vue wrapper, but to Highcharts.

From the API I deduce that you can use percentage-strings for the chart.height option, but not to chart.width:

(altough I understand that this is not very clearly described.)

So, the solution could be:

  1. Set width to null so that the width is automatically calculated based on the parent container & set the parent container to a fixed-width in %
  2. Set width to fixed number of px: https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/chart/width/

Let me know if that helps!

Closing as it is not a Highcharts-Vue bug.