Visio services in sharepoint 2013
-
Upload
biwug -
Category
Technology
-
view
1.156 -
download
4
Transcript of Visio services in sharepoint 2013
Visio Services in Sharepoint 2013
Thomas Browet
What is Visio Services
• Visio Services in SharePoint 2013 enables you to load, display, and interact programmatically with Visio files on SharePoint Server 2013 and Microsoft SharePoint Online.
Why Visio Services
• Visio diagrams can be rendered by Visio Services and viewed in a Web browser. This lets users view Visio documents without having Visio or the Visio Viewer installed on the local computer. This also allows diagrams to be viewed on mobile devices.• Basic exploration and navigation of these rendered diagrams are
supported within the Visio Web Access Web Part. Page designers can configure the user interface and functionality of the Web Part.• Visio Services can also refresh the data and recalculate the visuals of a
Visio diagram hosted on a SharePoint site. This enables published diagrams to refresh connections to various data sources (SQL, Excel, ….) and to update affected data graphics and text fields.
Agenda
• VISIO JSOM• Creating Visio Shapes with Data Binding• SharePoint, Visio and SVG
Visio JSOM
Visio JSOM
• What is it?• A JavaScript based object model for communicating with the
Visio Web Access web part
• What can you do with it?• Read shape data, hyperlinks, comments• Select shapes• Add highlights and overlays (HTML + HTML5)• Respond to mouse events• Change the pan and zoom settings• Navigate pages and diagrams ( drill down )
VWA Javascript Object Model
getActivePage()
setActivePage()
getShapes()
getItemById() getItemAtIndex()
diagramComplete
shapeMouseEnter
shapeMouseLeave
selectionChanged
diagramError
getSelectedShape()setSelectedShape()
VWA Control
Page
Shapes
Shape
getShapeData()getHyperlinks()
Shape
Getting started
Web Part PageVisio Web
Access Web Part
Content Editor Web Part
Document Library
File containing JScript
Visio Diagram
Hooking to add_load()
• When the page is loaded you want to call your function that retrieves the instance of the VWA web part
• This reference is needed to hook events and access VWA objects within the hosted diagram
• Alternate load methods that do not work with VWA• window.attachEvent("onload", vwaOnPageLoad);• window.addEventListener("DOMContentLoaded", vwaOnPageLoad, false);• $(document).ready(vwaOnPageLoad); // jQuery
Get the VWA web part instance
• Getting the VWA Instance
Or Find the VWA web part instance via code
Handle the diagramcomplete event
• Connecting handlers to events
Handling the selection changed event• Additional Handlers once the diagram has been rendered• removeHandler before adding it again
At this point the JSOM is initialized and the specified diagram is rendered in the VWA web part
function onShapeSelectionChanged(source, shapeId){ var vwaPage = vwaControl.getActivePage(); var vwaShapes = vwaPage.getShapes(); var vwaShape = vwaShapes.getItemById(shapeId);
var data = vwaShape.getShapeData();
for (var j = 0; j < data.length; j++) { if (data[j].label == "Step") { alert(data[j].value); } }}
Handling the selection changed event
Access Shape Data
• VWAShape.getShapeData()• returns an array of objects corresponding to shape data items associated with
a shape
• data[4].label;• data[4].value; // .formattedValue
Managing Highlights
• Highlights allow you to outline a shape( draws a rectangle around the shape bounds)• Shape Methods
• addHighlight• http://msdn.microsoft.com/en-us/library/ff394531.aspx
• removeHighlight• http://msdn.microsoft.com/en-us/library/ff394510.aspx
• Note - Only a single highlight rectangle is allowed per shape nextShape.addHighlight(4, "red");
Pixel width
Color, Hex or Name
Managing Overlays• Overlays allow you to define custom highlights/graphics• Shape Methods
• addOverlay• http://msdn.microsoft.com/en-us/library/ff394546.aspx
• removeOverlay• http://msdn.microsoft.com/en-us/library/ff394409.aspx
• Multiple overlays are allowed
• Defined using HTML• even HTML5 elements like Canvas!
Handling additional events
• Additional VWA events• http://msdn.microsoft.com/en-us/library/ff394574.aspx• Follows model for Excel Web Access ( EWA )
Event VwaControl Methods Description
Diagram Complete addHandler() / removeHandler() Triggered when the diagram is loaded, refreshed, or changed
Diagram Error addHandler() / removeHandler() Occurs when a request to render the diagram fails
Shape Mouse Enter addHandler() / removeHandler() Triggered when the mouse pointer is moved into the bounding box of the shape
Shape Mouse Leave addHandler() / removeHandler() Triggered when the mouse pointer is moved out of the bounding box of the shape
Shape Selection Changed addHandler() / removeHandler() Occurs when the shape that is currently selected on the page changes
Deployment
• Manual• Upload Visio files• Upload JS/HTML files for Content Editor web parts
• Or paste source directly into HTML Form web parts
• Site Template• Paths may need to be updated for the specified VDW files for the VWA web parts
Drawing URL property
• WSP• Included as part of a SharePoint solution package
• Empty SharePoint Project or a Visual Web Part
Debugging• Debug your scripts using browser developer tools• In browser, press F12 to display the developer tools
• Click on the Script tab to access script debugging features• Browse your code, set breakpoints, then reload the page to start debugging on the client
Script logging in IE developer tools
• function tryConsole(){
if (typeof console != "undefined"){ console.log("hello world"); }
}
• http://blogs.msdn.com/b/cdnwebdevs/archive/2011/05/26/console-log-say-goodbye-to-javascript-alerts-for-debugging.aspx
In summary…
• JavaScript API• Allow developers to build rich dashboard applications using javascript, html, etc.• Incorporate additional functionality using HTML and Silverlight overlays
• Events from these overlays can call additional functions
• Incorporate VWA API scenarios into other SharePoint development projects• Site Pages• Robust Dashboards• Visual Web Parts
• Want to see how the dev team did it• C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\
LAYOUTS\VisioWebAccess\workflowstatus.js
Demo
Creating Visio Shapes with Data Binding
Enable developer mode in visio
Create a shape from the shape library
Editing with Shapesheet
Binding data value
Changing data value
DataBinding the color of the shape
Playing with the value
Saving the shape
• Once finished you can drag and drop your shape to a stencil• So user can use your shape and it’s
shape data easily.• You can now easily bind these data
value to SQL Server or an Excel File.
SharePoint, Visio and SVG
Why did we use this ?
• We had to build :• An interactive map of an hospital campus. With a menu that allows to hide
and show buildings or highlight roads.
• Problem : VISIO JSOM, can’t dynamically hide Shapes or change it’s data value.
SVG
• So we had an idea, why not use SVG.• Visio can export SVG.• Wikipedia says :
Scalable Vector Graphics (SVG) is an XML-based vector image format for two-dimensional graphics that has support for interactivity and animation. The SVG specification is an open standard developed by the World Wide Web Consortium (W3C) since 1999.
SVG images and their behaviors are defined in XML text files. This means that they can be searched, indexed, scripted, and, if need be, compressed. As XML files, SVG images can be created and edited with any text editor, but it is often more convenient to create them with drawing programs such as Inkscape.
All major modern web browsers—including Mozilla Firefox, Internet Explorer 9and 10, Google Chrome, Opera, and Safari—have at least some degree ofsupport for SVG and can render the markup directly.
Inserting a SVG in SharePoint
• Different ways to add a SVG• Object tag in sharepoint are not allowed.• Embed tag, don’t allow us to browse the SVG DOM.
• Solution : • Load the SVG through an ajax call.
Demo
Thank You