Legend Object

The Legend object is the base object for top-level legends, vector map legends, post map legends, and symbology legends. Legend objects are not directly usable; they only serve as a base object that defines common legend functionality. All the properties and methods below are available for any object derived from the legend object.

Derived from: Shape object (All methods and properties of Shape apply to this object.)

The following table provides the properties of the Legend object:

Property

Description

FrameFill

Returns the fill format object for the frame. It is a read-only property

FrameLine

Returns the line format object for the frame. It is a read-only property.

FrameStyle

Returns/sets the frame style.

Margins

Returns/sets the margins in page units.

Title

Returns/sets the legend title.

TitleFont

Returns the title font format object. It is a read-only property

Example

The following script demonstrates how the VectorLegend object is used in reference to the VectorLayer object.

Sub Main

 

'Declares SurferApp as an object

Dim SurferApp As Object

 

'Creates an instance of the Surfer Application object and assigns it

'to the variable named "SurferApp"

Set SurferApp = CreateObject("Surfer.Application")

 

'Makes Surfer visible

SurferApp.Visible = True

 

'Declares Plot as an object

Dim Plot As Object

 

'Creates a plot document in Surfer and assigns it to the variable

'named "Plot"

Set Plot = SurferApp.Documents.Add(srfDocPlot)

 

'Declares Shapes as an object

Dim Shapes As Object

 

'Assigns the Shapes collection to the variable named "Shapes"

Set Shapes = Plot.Shapes

 

'Declares MapFrame as an object

Dim MapFrame As Object

 

'Creates a vector map and assigns the map coordinate system to the

'variable named "MapFrame"

Set MapFrame = Shapes.AddVectorMap(GridFileName1:=SurferApp.Path+"\Samples\demogrid.grd")

 

'Declares VectorLayer as an object

Dim VectorLayer As Object

 

'Assigns the vector map properties to the variable named "VectorLayer"

Set VectorLayer = MapFrame.Overlays(1)

 

'Displays the vector map legend

VectorLayer.ShowLegend = True

 

'Declares VectorLegend as an object

Dim VectorLegend As Object

 

'Assigns the vector map legend properties to the variable named

'"VectorLegend"

Set VectorLegend = VectorLayer.Legend

 

End Sub