Controlling the Location of a Free Legend

How to:

When legend position is set to 'free', the xy property controls the location of the legend, where x:0, y:0 is the upper left corner of the draw area.


Top of page

x
Syntax: How to Control the Location of a Free Legend
legend: {
   xy: {x:number, y:number}
   }

where:

x: number

Is a number that defines the x/horizontal location of the legend. The default value is 320.

y: number

Is a number that defines the y/vertical location of the legend. The default value is 80.



Example: Controlling the Location of a Free Legend

The following request generates a free (floating) legend and moves it to x:100 and y:20:

GRAPH FILE WFLITE
SUM DISCOUNT_US GROSS_PROFIT_US REVENUE_US MSRP_US
BY PRODUCT_CATEGORY
ON GRAPH HOLD FORMAT JSCHART
ON GRAPH SET LOOKGRAPH VBAR
ON GRAPH SET STYLE *
INCLUDE=ENDEFLT,$
*GRAPH_JS
legend: {
    position: 'free',
    xy: {x:100, y:20}    
},
series: [
    {series: 0, color: 'lightgreen'},
    {series: 1, color: 'coral'},
    {series: 2, color: 'lightblue'},
    {series: 3, color: 'burlywood'} 
]
*END
ENDSTYLE
END

The output is:


Information Builders