score:16

Accepted answer

have you tried to use itemwidth parameter?

please take look at

http://jsfiddle.net/b9l2b/1266/

 legend: {
    width: 200,
    itemwidth: 100
},

http://api.highcharts.com/highcharts#legend.itemwidth

edit:

http://jsbin.com/oyicuc/31/

width:600,
        itemwidth:300,
        itemstyle: {
          width:280
        }

http://api.highcharts.com/highstock#legend.itemstyle

score:0

maybe you could use the "labelformater" of the legend.

http://api.highcharts.com/highcharts#legend.labelformatter

then you could create a table and arrange the legend text as you wnat.

have a look at the example on the documentation page.

score:1

function renderelements() {
      if (this.legend) {
       this.legend.destroy();
      }
      //distance between 2 elements
      let itemdistance = this.legend.options.itemdistance;
      //the biggest element
      let maxitemwidth = this.legend.maxitemwidth;
      //make the width of the legend in the size of 2 largest elements + 
      //distance  
      let nextlegendwidth = (maxitemwidth * 2) + itemdistance;
      //container width
      let boxwidth = this.plotbox.width;
      //if the length of the 2 largest elements + the distance between them 
      //is less than the width of           container, we make 1 row, else 
      //set legend width 2 max elements + distance between
    if (boxwidth < nextlegendwidth) {
     this.legend.options.width = maxitemwidth;
    } else {
     this.legend.options.width = nextlegendwidth;
  }

  this.render()   
}

chart: {
    events: {
      load: renderelements,
      redraw: renderelements
  }
}

https://jsfiddle.net/jecrovb7/38/


Related Query

More Query from same tag