Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I move legend in Highcharts?

By default legend is displaying at the top-right side of the graph. I want to show it just above the graph. I've used the following code:

legend: {
    layout: 'vertical',
    align: 'left',
    x: 600,
    verticalAlign: 'top',
    y: 40,
    floating: true,
    backgroundColor: '#FFFFFF'
}

But it is not working for me. Am I doing anything wrong?

like image 670
PSR Avatar asked Jul 06 '13 05:07

PSR


People also ask

How do I change the legend position in Highcharts?

Set legend's layout, align and verticalAlign options as follows: legend: { layout: 'vertical', align: 'right', verticalAlign: 'middle', itemMarginTop: 10, itemMarginBottom: 10 }, By itemMarginTop/Bottom you can control the padding between the legend items.

How do I add extra legends in Highcharts?

So best is to add your extraText in data while JSON creating and provide it to highcharts. At chart , it will show in desired format using the the code I posted in answer/fiddle. putting static text for "Extra" won't work in real scenario, so use the code in fiddle jsfiddle.net/wjnnt28p/3.

What is legend in Highchart?

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.

What is legend layout?

Legends are a layout element that tell the map reader the meaning of the symbols used to represent features on the map. Legends can point to any map frame in the layout, but each legend can only reference a single map frame.


2 Answers

Like this:

legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'top',
            floating: true,
            backgroundColor: '#FFFFFF'
        },

http://api.highcharts.com/highcharts#legend.verticalAlign http://api.highcharts.com/highcharts#legend.align

like image 71
Sri-- Avatar answered Oct 05 '22 12:10

Sri--


Do you want to place legend above whole graph or just above plot? Is that what you need? http://jsfiddle.net/8Qm5a/

Anyway, if you need to place legend above the title, try to change marginTop of chart settings and set y settings in title options:

    chart: {
        marginTop: 100
    },

    title: {
        text: "test",
        y: 60
    },

http://jsfiddle.net/8Qm5a/1/

like image 27
Andrey Nelubin Avatar answered Oct 05 '22 12:10

Andrey Nelubin