Visio Services in
Sharepoint 2013
Thomas Browet
What is Visio Services
• Visio Services in SharePoint 2013 enables you to load, display, and
interact programmatically wit...
Why Visio Services
• Visio diagrams can be rendered by Visio Services and viewed in a Web
browser. This lets users view Vi...
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 ca...
VWA Javascript Object Model
VWA
Control

getActivePage()
setActivePage()

diagramComplete

Page

getShapes()

shapeMouseEn...
Getting started
Web Part Page

Document Library
Hooking to add_load()
• When the page is loaded you want to call your function that retrieves the instance of the
VWA web ...
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 addin...
Handling the selection changed event
function onShapeSelectionChanged(source, shapeId)
{
var vwaPage = vwaControl.getActiv...
Access Shape Data
• VWAShape.getShapeData()
• returns an array of objects corresponding to shape data items associated wit...
Managing Highlights
• Highlights allow you to outline a shape
( draws a rectangle around the shape bounds)
• Shape Methods...
Managing Overlays
• Overlays allow you to define custom highlights/graphics
• Shape Methods
• addOverlay
• http://msdn.mic...
Handling additional events
• Additional VWA events
• http://msdn.microsoft.com/en-us/library/ff394574.aspx
• Follows model...
Deployment
• Manual
• Upload Visio files
• Upload JS/HTML files for Content Editor web parts
• Or paste source directly in...
Debugging
• Debug your scripts using browser developer tools
• In browser, press F12 to display the developer tools

• Cli...
Script logging in IE developer tools
• function tryConsole()
{
if (typeof console != "undefined")
{
console.log("hello wor...
In summary…
• JavaScript API

• Allow developers to build rich dashboard applications using javascript, html, etc.
• Incor...
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...
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 ...
SVG
• So we had an idea, why not use SVG.
• Visio can export SVG.
• Wikipedia says :
Scalable Vector Graphics (SVG) is an ...
Inserting a SVG in SharePoint
• Different ways to add a SVG
• Object tag in sharepoint are not allowed.
• Embed tag, don’t...
Demo
Thank You
Upcoming SlideShare
Loading in …5
×

Visio services in sharepoint 2013

2,427 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,427
On SlideShare
0
From Embeds
0
Number of Embeds
33
Actions
Shares
0
Downloads
29
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Visio services in sharepoint 2013

  1. 1. Visio Services in Sharepoint 2013 Thomas Browet
  2. 2. 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.
  3. 3. 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.
  4. 4. Agenda • VISIO JSOM • Creating Visio Shapes with Data Binding • SharePoint, Visio and SVG
  5. 5. Visio JSOM
  6. 6. 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 )
  7. 7. VWA Javascript Object Model VWA Control getActivePage() setActivePage() diagramComplete Page getShapes() shapeMouseEnter Shapes shapeMouseLeave selectionChanged getItemById() getItemAtIndex() diagramError Shape Shape getSelectedShape() setSelectedShape() getShapeData() getHyperlinks()
  8. 8. Getting started Web Part Page Document Library
  9. 9. 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
  10. 10. Get the VWA web part instance • Getting the VWA Instance
  11. 11. Or Find the VWA web part instance via code
  12. 12. Handle the diagramcomplete event • Connecting handlers to events
  13. 13. 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
  14. 14. Handling the selection changed event 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); } } }
  15. 15. 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
  16. 16. 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 Pixel width • Note - Only a single highlight rectangle is allowed per shape nextShape.addHighlight(4, "red"); Color, Hex or Name
  17. 17. 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!
  18. 18. 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
  19. 19. 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
  20. 20. 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
  21. 21. 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/consolelog-say-goodbye-to-javascript-alerts-for-debugging.aspx
  22. 22. 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 FilesCommon FilesMicrosoft SharedWeb Server Extensions15TEMPLATELAYOUTSVisioWebAccessworkflowstatus.js
  23. 23. Demo
  24. 24. Creating Visio Shapes with Data Binding
  25. 25. Enable developer mode in visio
  26. 26. Create a shape from the shape library
  27. 27. Editing with Shapesheet
  28. 28. Binding data value
  29. 29. Changing data value
  30. 30. DataBinding the color of the shape
  31. 31. Playing with the value
  32. 32. 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.
  33. 33. SharePoint, Visio and SVG
  34. 34. 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.
  35. 35. 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.
  36. 36. 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.
  37. 37. Demo
  38. 38. Thank You

×