Height Legend Height

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

How can I set the height of the legend so that it does not need navigation? Api has no legend.height property

+6
source share
3 answers

I thought that perhaps the maxHeight property maxHeight do this, but would not be able to change the height.

It seemed to me that I would bother with the y property and found a script that seems to work very well. You can customize it as you wish.

  legend:{ align: 'right', verticalAlign:'middle', width: 200, itemWidth: 100, y: 85 }, 
+5
source

Highcharts calculates the height of the legend based on the elements of the legend inside it. if it overflows the height of the chart, it can cause a problem.

in the legend, you can limit the height using maxHeight, but if the label height is exceeded, maxHeight controls will appear. so it’s better to calculate the required height yourself and give it maxHeight to avoid the navigation controls,

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

hope this might work.

+1
source

Highcharts seems to start navigation when the calculated legend height exceeds a certain value. Thus, you can increase the height of the graph, if this is an option.

 <div id="container" style="min-width: 310px; height: 450px; margin: 0 auto"></div> 
0
source

Source: https://habr.com/ru/post/955942/


All Articles