Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highstock: When legend under the chart has many items, the chart height is small. How can I fix the height?

In my app users can add/remove as many series they want to the HighStock component using a piece of UI I wrote. However, when a user adds multiple time-series and the legend is under the chart, it shrinks the chart's height (in favor of the legend). This way the overall height remains constant.

However, I'm interested in having the plotting area keeping the same height and still have the legend be under it, changing the overall height if needed.

code Here's a fiddle to demo the issue.

Ideas?

like image 789
GilNahmias Avatar asked Sep 16 '13 22:09

GilNahmias


People also ask

How do I change height in Highcharts?

use chart. setSize(width, height, doAnimation = true); in your actual resize function to set the height and width dynamically.

How to position Highcharts?

Most Highcharts elements displayed on a chart can be positioned using x and y values relative to the top left corner and using the align and verticalAlign options. The align option can have the values 'left' , 'right' and 'center' . The verticalAlign option can have the values 'top' , 'bottom' and 'middle' .

What is legend in Highcharts?

The legend displays the series in a chart with a predefined symbol and the name of the series. Series can be disabled and enabled from the legend.

How do I hide the Highchart watermark?

credits: { enabled: false }, that will remove the "Highcharts.com" text from the bottom of the chart.


1 Answers

set maxHeight property. this will fix the maximum height of legend and gives navigation to legend.

maxHeight: 100,

here is the fiddle http://jsfiddle.net/9vZ8F/2/

instead if you remove

layout:'vertical'

legend will not occupy much space here is a fiddle for it http://jsfiddle.net/9vZ8F/1/

Hope this is useful to you.

like image 74
Strikers Avatar answered Sep 27 '22 22:09

Strikers