B.4. Changing Position of Legend Box

Click to view larger image

Changing the Position of the Legend Box

The position of the legend box can be adjusted if the default location is not what you want. Please note that the reference point is the center of the legend box.

// Legend Box can be moved with a specified new relative position
ILegend hLegend = chart.gethLegend();
float x = 0.2;
float y = 0.7;
hLegend.setPosition( new Position( x, y) ); 

Legend box size is dependent on the size of the text font & text strings. Therefore, you cannot set the legend box size directly, but you can get the size of the legend box. Here are some sample codes:

ILegend hLegend = chart.gethLegend()
float relWidth = hLegend.getRelativeWidth();
float relHeight = hLegend.getRelativeHeight(); 

To change the position of the legend in the Chart Designer, left click on the legend and drag it to the desired position on the canvas.