Search code examples
highchartsaxisgantt-chart

Highcharts Gantt fixed width of the left axis as a table column


I use Highcharts (Gantt module) to generate a Gantt Resources Management chart with a left axis as a table. It works very well but, for a specific alignement reason with other charts, I need to fix the width of this left axis column (with a larger width than the longest label inside). How can I achieve that ?

I tried a width: 250, setting in the Y-axis or in the gridColumns/label settings but it doesn't change anything.

An example of chart can be viewed here : https://jsfiddle.net/vegaelce/ryfmzxpe/3/ In this sample, I'de like the "resource" columns to have a fixed width of 250 pixels (for instance).


Solution

  • There is no direct way to set the column's width. Reported feature request: https://github.com/highcharts/highcharts/issues/20277

    However, the width of the column is adjusted to its content, so you can increase an individual label's width. For example:

    labels: {
      useHTML: true,
      formatter: function () {
        if (this.value === "Group A") {
          return `<div style="width: 250px;">${this.value}</div>`;
        }
    
        return this.value;
      }
    }
    

    Live demo: https://jsfiddle.net/BlackLabel/z8kfb0p2/

    API Reference: https://api.highcharts.com/highcharts/yAxis.labels