ChartJs โ€“ width scale of chart area and label area

๐Ÿ‘:-1

May be following settings will work for you. Set responsive to true and maintainAspectRatio to false in the chart options and set style as like as max-height: 300px (more or less); width: auto; in canvas.

...
var config = {
  type: 'doughnutLabels',
  data: {
    ...
  },
  options: {    
    ...    
    responsive: true, //IMPORTANT        
    maintainAspectRatio: false, //IMPORTANT
    ...
    legend: {
      ...
      position: 'right',
      ...
      labels: {   
        ...  
        fontColor: '#d5d6d6',      
        fontSize: this.isMobileWidth ? 10 : 16,
        ...
      }
    },
    animation: {
      animateScale: true,
      animateRotate: true
    }        
  }
};
... 

Leave a comment