7

ハイチャートでは、縦に積み上げられた 2 つの列で凡例を表示することは可能ですか?

凡例項目を表示する最善の方法を見つけようとしています。現時点では、凡例項目がすべて重なり合っています。

チャートには最大 4 つのシリーズが表示されます。

これにアプローチする方法がよくわかりません.useHTMLのオプションが表示されますが、HTMLをどうするかの例が見つからないようです.

http://jsbin.com/oyicuc/9/edit

どんなアドバイスもとても役に立ちます、ありがとう。

4

3 に答える 3

16

itemWidth パラメータを使用しようとしましたか?

ご覧ください

http://jsfiddle.net/B9L2b/1266/

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

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

編集:

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

width:600,
        itemWidth:300,
        itemStyle: {
          width:280
        }

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

于 2013-03-18T14:56:27.907 に答える
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/

于 2018-07-26T07:29:51.443 に答える
0

おそらく、凡例の「labelFormater」を使用できます。

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

次に、テーブルを作成して、必要に応じて凡例テキストを配置できます。

ドキュメントページの例を見てください。

于 2013-03-18T10:17:09.070 に答える