Visio.ShapeView class

Represents the ShapeView class.

[ API set: 1.1 ]

Extends

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.

[ API set: 1.1 ]

Methods

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

Adds an overlay on top of the shape.

[ API set: 1.1 ]

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

Adds an overlay on top of the shape.

[ 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(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.

[ API set: 1.1 ]

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

showOverlay(overlayId, show)

Shows particular overlay on the Shape.

[ 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.

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.

[ API set: 1.1 ]

highlight: Visio.Highlight;

Property Value

Examples

Visio.run(session, function (ctx) {
    var activePage = ctx.document.getActivePage();
    var 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.

[ API set: 1.1 ]

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

Examples

Visio.run(session, function (ctx) {
    var activePage = ctx.document.getActivePage();
    var shape = activePage.shapes.getItem(0);
    var 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, OverlayHorizontalAlignment, OverlayVerticalAlignment, Width, Height)

Adds an overlay on top of the shape.

[ API set: 1.1 ]

addOverlay(OverlayTypeString: "Text" | "Image" | "Html", Content: string, OverlayHorizontalAlignment: "Left" | "Center" | "Right", OverlayVerticalAlignment: "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.

OverlayHorizontalAlignment

"Left" | "Center" | "Right"

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

OverlayVerticalAlignment

"Top" | "Middle" | "Bottom"

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

Width

number

Overlay Width.

Height

number

Overlay Height.

Returns

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.

[ API set: 1.1 ]

removeOverlay(OverlayId: number): void;

Parameters

OverlayId

number

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

Returns

void

Examples

Visio.run(session, function (ctx) {
    var activePage = ctx.document.getActivePage();
    var 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

Remarks

This method has the following additional signature:

set(properties: Visio.ShapeView): 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

showOverlay(overlayId, show)

Shows particular overlay on the Shape.

[ API set: 1.1 ]

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

Parameters

overlayId

number

overlay id in context

show

boolean

to show or hide

Returns

void

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