Visio.ShapeView class

Represents the ShapeView class.

Extends

Remarks

[ API set: 1.1 ]

Properties

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

highlight

Represents the highlight around the shape.

Methods

addOverlay(OverlayType, Content, OverlayHorizontalAlignment, OverlayVerticalAlignment, Width, Height)

Adds an overlay on top of the shape.

addOverlay(OverlayTypeString, Content, OverlayHorizontalAlignmentString, OverlayVerticalAlignmentString, Width, Height)

Adds an overlay on top of the shape.

load(options)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

removeOverlay(OverlayId)

Removes particular overlay or all overlays on the Shape.

set(properties, options)

Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type.

set(properties)

Sets multiple properties on the object at the same time, based on an existing loaded object.

setMockData(data)

Set mock data

setText(Text)

The purpose of SetText API is to update the text inside a Visio Shape in run time. The updated text retains the existing formatting properties of the shape's text.

showOverlay(overlayId, show)

Shows particular overlay on the Shape.

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Visio.ShapeView object is an API object, the toJSON method returns a plain JavaScript object (typed as Visio.Interfaces.ShapeViewData) that contains shallow copies of any loaded child properties from the original object.

Property Details

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

context: RequestContext;

Property Value

highlight

Represents the highlight around the shape.

highlight: Visio.Highlight;

Property Value

Remarks

[ API set: 1.1 ]

Examples

Visio.run(session, function (ctx) {
    const activePage = ctx.document.getActivePage();
    const shape = activePage.shapes.getItem(0);
    shape.view.highlight = { color: "#E7E7E7", width: 100 };
    return ctx.sync();
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

Method Details

addOverlay(OverlayType, Content, OverlayHorizontalAlignment, OverlayVerticalAlignment, Width, Height)

Adds an overlay on top of the shape.

addOverlay(OverlayType: Visio.OverlayType, Content: string, OverlayHorizontalAlignment: Visio.OverlayHorizontalAlignment, OverlayVerticalAlignment: Visio.OverlayVerticalAlignment, Width: number, Height: number): OfficeExtension.ClientResult<number>;

Parameters

OverlayType
Visio.OverlayType

An Overlay Type. Can be 'Text', 'Image' or 'Html'.

Content

string

Content of Overlay.

OverlayHorizontalAlignment
Visio.OverlayHorizontalAlignment

Horizontal Alignment of Overlay. Can be 'Left', 'Center', or 'Right'.

OverlayVerticalAlignment
Visio.OverlayVerticalAlignment

Vertical Alignment of Overlay. Can be 'Top', 'Middle', 'Bottom'.

Width

number

Overlay Width.

Height

number

Overlay Height.

Returns

Remarks

[ API set: 1.1 ]

Examples

Visio.run(session, function (ctx) {
    const activePage = ctx.document.getActivePage();
    const shape = activePage.shapes.getItem(0);
    const overlayId = shape.view.addOverlay("Image", "Visio Online", "Center", "Middle", 50, 50);
    return ctx.sync();
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

addOverlay(OverlayTypeString, Content, OverlayHorizontalAlignmentString, OverlayVerticalAlignmentString, Width, Height)

Adds an overlay on top of the shape.

addOverlay(OverlayTypeString: "Text" | "Image" | "Html", Content: string, OverlayHorizontalAlignmentString: "Left" | "Center" | "Right", OverlayVerticalAlignmentString: "Top" | "Middle" | "Bottom", Width: number, Height: number): OfficeExtension.ClientResult<number>;

Parameters

OverlayTypeString

"Text" | "Image" | "Html"

An Overlay Type. Can be 'Text', 'Image' or 'Html'.

Content

string

Content of Overlay.

OverlayHorizontalAlignmentString

"Left" | "Center" | "Right"

Horizontal Alignment of Overlay. Can be 'Left', 'Center', or 'Right'.

OverlayVerticalAlignmentString

"Top" | "Middle" | "Bottom"

Vertical Alignment of Overlay. Can be 'Top', 'Middle', 'Bottom'.

Width

number

Overlay Width.

Height

number

Overlay Height.

Returns

Remarks

[ API set: 1.1 ]

load(options)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(options?: Visio.Interfaces.ShapeViewLoadOptions): Visio.ShapeView;

Parameters

options
Visio.Interfaces.ShapeViewLoadOptions

Provides options for which properties of the object to load.

Returns

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNames?: string | string[]): Visio.ShapeView;

Parameters

propertyNames

string | string[]

A comma-delimited string or an array of strings that specify the properties to load.

Returns

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): Visio.ShapeView;

Parameters

propertyNamesAndPaths

{ select?: string; expand?: string; }

propertyNamesAndPaths.select is a comma-delimited string that specifies the properties to load, and propertyNamesAndPaths.expand is a comma-delimited string that specifies the navigation properties to load.

Returns

removeOverlay(OverlayId)

Removes particular overlay or all overlays on the Shape.

removeOverlay(OverlayId: number): void;

Parameters

OverlayId

number

An Overlay Id. Removes the specific overlay id from the shape.

Returns

void

Remarks

[ API set: 1.1 ]

Examples

Visio.run(session, function (ctx) {
    const activePage = ctx.document.getActivePage();
    const shape = activePage.shapes.getItem(0);
    shape.view.removeOverlay(1);
    return ctx.sync();
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

set(properties, options)

Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type.

set(properties: Interfaces.ShapeViewUpdateData, options?: OfficeExtension.UpdateOptions): void;

Parameters

properties
Visio.Interfaces.ShapeViewUpdateData

A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called.

options
OfficeExtension.UpdateOptions

Provides an option to suppress errors if the properties object tries to set any read-only properties.

Returns

void

set(properties)

Sets multiple properties on the object at the same time, based on an existing loaded object.

set(properties: Visio.ShapeView): void;

Parameters

properties
Visio.ShapeView

Returns

void

setMockData(data)

Set mock data

setMockData(data: Visio.Interfaces.ShapeViewData): void;

Parameters

Returns

void

setText(Text)

The purpose of SetText API is to update the text inside a Visio Shape in run time. The updated text retains the existing formatting properties of the shape's text.

setText(Text: string): void;

Parameters

Text

string

Text parameter is the updated text to display on the shape.

Returns

void

Remarks

[ API set: 1.1 ]

showOverlay(overlayId, show)

Shows particular overlay on the Shape.

showOverlay(overlayId: number, show: boolean): void;

Parameters

overlayId

number

The overlay ID in context.

show

boolean

Whether to show the overlay.

Returns

void

Remarks

[ API set: 1.1 ]

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Visio.ShapeView object is an API object, the toJSON method returns a plain JavaScript object (typed as Visio.Interfaces.ShapeViewData) that contains shallow copies of any loaded child properties from the original object.

toJSON(): Visio.Interfaces.ShapeViewData;

Returns