Chart.js: [FEATURE] ability to set the axis label's width

Created on 23 Aug 2018  路  6Comments  路  Source: chartjs/Chart.js

Feature request.

When having multiple line charts stacked on top of each other, they can't line up if you have varying digits on the Y Axis.

It would be useful if you could set the width of the labels on the Y Axis.

duplicate enhancement

Most helpful comment

Work around but not ideal

options: { scales: { yAxes: [{ afterFit: function(scaleInstance) { scaleInstance.width = 100; // sets the width to 100px } }] } }

All 6 comments

Work around but not ideal

options: { scales: { yAxes: [{ afterFit: function(scaleInstance) { scaleInstance.width = 100; // sets the width to 100px } }] } }

Duplicate of #4340

The workaround doesn't seem to work with v3. Is it possible that afterFit callback has been removed?

This prints the instance of the scale with v2.93 but nothing with v3.

  scales: {
    yAxes: [{
      afterFit: instance => console.log(instance)
    }]
  }

@dbauszus-glx did you find a working solution for v3?

@lessless I have not. Any help is welcome.

@dbauszus-glx this is kind of hacky, but I was able to fix the left axis width by setting the maximum axis width to zero and the left padding for the chart layout to 100:

scales: {
    yAxes: [{
        afterSetDimensions: function(axes) {
            axes.maxWidth = 0;
            console.log(axes.width);
        }
    }]
}
layout: {
    padding: {
        left: 100
    }
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

HeinPauwelyn picture HeinPauwelyn  路  3Comments

akashrajkn picture akashrajkn  路  3Comments

JAIOMP picture JAIOMP  路  3Comments

lizbanach picture lizbanach  路  3Comments

frlinw picture frlinw  路  3Comments