Highcharts set legend height

2019-04-29 01:18发布

Given the following fiddle, http://jsfiddle.net/JoelStransky/5QCmG/1

How would I set the legend height so that it doesn't need the navigation? The api doesn't have a legend.height property

3条回答
看我几分像从前
2楼-- · 2019-04-29 01:51

I thought maybe the maxHeight property would do it but couldn't get the height to change.

I thought I would mess around with the y property and found a scenario that seems to work pretty good. You can tweak it as you see fit.

 legend:{
            align: 'right',
            verticalAlign:'middle',
            width: 200,
            itemWidth: 100,
            y: 85
        },
查看更多
狗以群分
3楼-- · 2019-04-29 01:53

Highcharts calculates the height of the legend depending on legend items inside it. if this overflows the chart height then that may cause the issue.

in legend you can restrict the height using the maxHeight, but if the legend height overflows the maxHeight navigation controls appear. so better calculate the required height by yourself and give it to maxHeight to avoid navigation controls,

maxHeight: (no. of legend Items or series count) * line height of each item/2

hope this may work.

查看更多
唯我独甜
4楼-- · 2019-04-29 02:07

It seems Highcharts triggers the navigation when the calculated legend height exceeds certain value. So you can increase the height of your chart if it's the option.

<div id="container" style="min-width: 310px; height: 450px; margin: 0 auto"></div>
查看更多
登录 后发表回答