ハイチャートでは、縦に積み上げられた 2 つの列で凡例を表示することは可能ですか?
凡例項目を表示する最善の方法を見つけようとしています。現時点では、凡例項目がすべて重なり合っています。
チャートには最大 4 つのシリーズが表示されます。
これにアプローチする方法がよくわかりません.useHTMLのオプションが表示されますが、HTMLをどうするかの例が見つからないようです.
http://jsbin.com/oyicuc/9/edit
どんなアドバイスもとても役に立ちます、ありがとう。
ハイチャートでは、縦に積み上げられた 2 つの列で凡例を表示することは可能ですか?
凡例項目を表示する最善の方法を見つけようとしています。現時点では、凡例項目がすべて重なり合っています。
チャートには最大 4 つのシリーズが表示されます。
これにアプローチする方法がよくわかりません.useHTMLのオプションが表示されますが、HTMLをどうするかの例が見つからないようです.
http://jsbin.com/oyicuc/9/edit
どんなアドバイスもとても役に立ちます、ありがとう。
itemWidth パラメータを使用しようとしましたか?
ご覧ください
http://jsfiddle.net/B9L2b/1266/
legend: {
width: 200,
itemWidth: 100
},
http://api.highcharts.com/highcharts#legend.itemWidth
編集:
width:600,
itemWidth:300,
itemStyle: {
width:280
}
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
}
}
おそらく、凡例の「labelFormater」を使用できます。
http://api.highcharts.com/highcharts#legend.labelFormatter
次に、テーブルを作成して、必要に応じて凡例テキストを配置できます。
ドキュメントページの例を見てください。