There are two ways of customizing the out-of-the-box experience of Visio Services solutions:
-
Creating custom data providers using server-side code
-
Enhancing the interactivity of your dashboards that include the
Visio Web Access Web Part by manipulating the different Visio diagram
objects programmatically using browser client-side code
The following two sections detail the options that developers have for writing code against Visio Services.
Note
You can also create client application-level add-ins for Visio.
However, such solutions that are data driven within Visio, if they are
not using the Data Linking feature, may be data driven when displayed
in Visio Services.
Server-side customizations
Custom data providers can be created to allow data linking to
external sources where an out-of-the-box data connector is not
provided. In SharePoint 2013, where BCS and External Lists can be used
with Visio Services, the need to develop custom data providers should
be less than in SharePoint Server 2010. Of course, you cannot build and
deploy custom data providers in a multitenant solution, such as Office
365.
Custom data providers require the development of a custom .NET
assembly that implements the Visio Services Data Provider Interface,
Microsoft.Office.Visio.Server.Addon-DataHandler. Once created, the
assembly needs to be deployed into the global assembly cache (GAC) on
each server in the SharePoint farm. The custom data provider then needs
to be added within the SharePoint Central Administration website as a
Visio Graphics Service trusted data provider.
Visio Services JavaScript mashup APIs
You
can enable rich interactivity on your Web Part page by manipulating the
different Visio diagram objects programmatically. A typical example of
this type of interactivity is to show custom visual overlays when the
person viewing the diagram pauses over a particular shape. You should
use these APIs when:
-
Functionality is needed that cannot be handled by web part
connections. Web part connections do not provide the user experience
that is expected today.
-
Using JavaScript or HTML 5 canvas provides extra visualization to your diagram.
Before your solution can interact programmatically with a Visio
drawing on the Web Part page, you must add a Visio Web Access Web Part.
This automatically adds the Visio Services JavaScript API to the page.
This API is an embedded resource in the dynamic-link library (DLL), not
on the file system.
Create a JavaScript (.js) file that contains the code you want to
interact with the Visio drawing and save it to the same SharePoint
library where the Visio diagrams are stored. Next, add a web part to
the page that can be used to link the .js file to the page. Typically,
a Content Editor Web Part is used to link the .js file, but you can use
the HTML Script command.
The mashup API has a basic hierarchy that consists of four main classes:
-
Vwa.VwaControl
. Use this class to control Visio objects at the Visio
drawing level, where the drawings are those contained in the file
displayed associated with the Visio Web Access Web Part. You can access
the web part properties, assign which diagram in the file to display,
iterate and display a page in a multipage diagram, manage user
interaction with the drawing by adding or removing event handlers, and
also show and hide custom HTML error messages. When a diagram is
visible, the only page object that can be accessed is the page that is
displayed in the web part. The JavaScript cannot iterate through all
page objects – there are developer tricks that can be used to load each
page and cache the page objects and then iterate through the page
objects in the cache.
-
Vwa.Page
. Use this class to access a page object within the
Visio drawing and not the web page. You can change the zoom center,
zoom percentage, change the currently selected shape, and get a
reference to the collection of shapes in the currently displayed page.
-
Vwa.ShapeCollection
. Use
this class to iterate through all the shapes on a page. Some diagrams
may take a while to display; therefore, before iterating through all
the shapes in a shape collection object, you need to wait for the
diagram complete event.
-
Vwa.Shape
. Use this class to manage a single shape, such as
drawing a colored rectangle around the bounding box of the shape—known
as highlighting or overlaying the shape with a particular shape (for
example, a pushpin icon placed on top of a map).
Visio 2010 Premium introduced an extension to the Visio Type Library
called the Validation API. On the Ribbon Process tab, there are
commands in the Validation group that provide access to the visible
parts of the Validation API. Users can click Check Diagram to analyze a
diagram to verify that the diagram is properly constructed and complies
with a set of rules. If there are any errors or issues with various
aspects of the diagram, such as layout, connectivity, data values, or
formatting, then they are listed in the Issues Window.
In Visio 2013 Professional, templates with built-in rules include
Basic Flowchart, Cross-Functional Flowchart, Business Process Modeling
Notation (BPMN), Six Sigma, and SharePoint workflows. These templates
can be used to create diagram, ensuring diagram consistency against
industry-standard diagram rules, or custom rules designed for a
particular company or government regulations, such as Sarbanes–Oxley
(SOX), BASEL II, and quantity assurance (QA).