mstzn
mstzn

Reputation: 2931

How to set fixed width for labels in chartjs

I have one dataset with multiple labels in my bar chart. When bar chart has more labels, width of label shrink for each.

I want to set fixed width for every window in my chart. For example dark stick for every label should be same fixed width size no matter how many window exists.

enter image description here

Thank in advance.

Upvotes: 1

Views: 6884

Answers (1)

Denys Levshenkov
Denys Levshenkov

Reputation: 284

Is it a request to have the vertical axis have a fixed width?

There is a way to do this:

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

Upvotes: 2

Related Questions