Shane Geist
Shane Geist

Reputation: 31

Using JQPlot, how can I place the legend outside the chart in a specific location?

I am using the following to successfully place the legend outside my JQPlot line chart:

legend: {
   show: true,
   location: 'sw',
   placement: 'outside'
},

However, this places the legend too close to the chart, in line with my yaxis labeling. I need to move it further to the left. Is there a way to do this?

Upvotes: 3

Views: 13872

Answers (3)

DilanG
DilanG

Reputation: 1225

You have to use it like this. marginLeft : "300px"

legend: { 
    show: true, 
    location: 'sw', 
    placement: 'outside',
    marginLeft: "300px"
}

Upvotes: 1

willily
willily

Reputation: 116

A bit late, sure, but I got it! You should use placement: 'outsideGrid' instead of placement: 'outside' as 'outsideGrid' will shrink the graph area for the legend not to be mixed with it.

Upvotes: 7

zs2020
zs2020

Reputation: 54543

Checkout the marginTop, marginRight, marginBottom, marginLeft properties for Legend.

You should be able to do:

legend: { 
    show: true, 
    location: 'sw', 
    placement: 'outside',
    marginLeft: 300
}

Upvotes: 4

Related Questions