Hello, I'm Chris Murphy — I specialize in creating engaging, user-centric interactive experiences.
Creating a Reusable Shape with Visio Shape Data Support
An in-depth tutorial on how to leverage Visio's datagraphics features for building efficient, multipurpose shapes for use in your diagrams and documents.
I’ve been quite busy over the past week having to rebuild many of my site planning documents from scratch. In the course of delving deeper into the workings and features of Visio, I’ve ended up with a small collection of really useful tips that I thought I would share here. The most useful one to date has been the creation of Visio shapes with Data Graphics support.
Note: this should really be a screen cast – next time
Custom IA Shapes with a Dialog/Prompt
One of the primary building blocks of any information architecture is the shape that represents a page concept. There are some great stencils out there for Visio that other designers have put together, but you’ll find that maintaining these shapes (when on page) can be laborious given how Visio constructs its geometry.
One of the time savers that can be leveraged is the use of “Shape Data” to add custom information to a shape, and “Shape Graphics” to display the custom information. One other feature that can be leveraged is the customization of “Shape Sheet” information to provide dialog support.
What is a Data Graphic?
Microsoft Office Visio 2007 Professional offers new ways for businesses to visualize information. New data connectivity, data linking, and data refresh features enable users to more easily connect to external data and associate it with specific shapes in a drawing, and to more easily refresh the data manually or automatically. The Data Graphics feature presents linked data and other shape information graphically in a diagram. Together, these capabilities make it faster and easier to communicate important information for making decisions and taking actions.Source: MSDN – Office Developer Center
In short: Data Graphics provide visualization capabilities to represent data in a meaningful way.
Software: I’m working with a copy of Visio 2007, and so some of the concepts might be labelled differently in older versions of the software. Consult your product documentation if need help finding the features.
Step 1: Preparing the shape
You can approach this step in one of two ways: start from scratch or attempt to modify an existing shape (as long as its not leveraging Data Graphics already).
For the purpose of this tutorial, we’ll be starting from scratch, but that doesn’t mean that you can’t skip this step and apply the later principles to your existing shapes.
Creating the shape
You’re going to need a shape. The most basic shape you may want to use is a rectangle to represent a page (the orientation is up to you). Start off by drawing a simple rectangle using Visio’s drawing tools. I have my page units set to inches, so a simple 1”x .7” rectangle is what I’ll make.
You can apply some basic effects to the shape such as rounded corners. For this one, I’ll use a .5pt corner radius.
Fig. 1 – The basic shape.
Now, the thing about Visio shapes is that you can automatically input text by typing while the the object is selected. This is the default behaviour for nearly all Visio stencils that I have come across.
Fig. 2 – Inputting text.
For the most part this is a good thing, but for what we want to create, it’s important we avoid this behavior. The layout of the labels is important for legibility, urging some clever designers to create complex shapes that will group a number of text fields arranged to display bits of info for the shape. This is where things tend to become unmanageable.
Adding Glue Points
You may not be familiar with Visio “Glue Points”, but you’re certainly familiar with how they work. “Glue Points” are those tiny dots that look like shape handles on a given shape. These dots are anchor points for objects to connect to each other.
You can add glue points to your shape by using the Connection Point tool located on your toolbar here:
Fig. 3 – The “Connection Point Tool”.
Note: Ctrl+Click anywhere within the shape to add a new glue point.
Once you’ve done that, your shape is pretty much ready to go.
Fig. 4 – The result after adding glue points.
Step 2: Adding Shape Data
As stated before, Shape Data is little more than additional information that can be dynamically added to a given shape. In this case we want to add some basic information to our shape that we would normally enter by hand.
Here are the fields:
- ID – the numeric or text-based identifier for the shape
- Label – the label that you want to display, e.g. “home”, “about”, “contact”, etc.
- Type – This is something we’ll save for another tutorial, add it for now
You can access the Shape Data dialog by first selecting the shape you created in Step 1, and going to your menu under Data>Shape Data. The alternate way of accessing the interface is by right-clicking to show the context menu (on the shape) and navigating to Data>Shape Data.
You’ll be presented with a prompt if there is no Shape Data available (there shouldn’t be)
Fig. 1 – The Shape Data prompt.
Click “yes” to bring up the Shape Data interface.
Fig. 2 – The Shape Data dialog.
Now that you have the interface up, start by entering the fields (mentioned above). What you’ll notice that there are two similar fields: “Label” and “Name”. What’s the difference? The “Label” is what will be displayed on the shape (and referenced in a later step), and the “Name” is what you’ll need to use if you’re programming with Visio.
Fig. 3 – The result after adding custom properties.
This is how you can accomplish this:
- Prefix each of the above fields with “str_”, e.g “str_id” or for “ID” use “UID”
- Ensure that each of these items has a “Type” set to string. You can customize the format as you see fit by clicking on the button beside “Format”
- Provide a default value in the “Value” field, e.g. “[Page Name]”
- Provide a brief message in the “Prompt” field – remember, you’re the one that’ll be prompted, so I suggest that you not annoy yourself needlessly
- The “Sort Key” will accept either a, b, c or 1, 2, 3 – the idea being that you set the properties in the order you’d prefer them to appear
- Lastly, check the “Ask on drop” checkbox – this is what will force a prompt to be displayed when you add the shape to your sheet, duplicate, or when you copy/paste it
- Hit “Okay” when you’re done
That’s it for the adding custom Shape Data to your shape. Now the trickery comes in when we’re attempting to display the data on our shape. Enter Data Graphics.
Step 3: Applying Data Graphics to a Shape
Ok. This is the point where things get a little interesting as later steps will require a little manual labour to format the data and lay it out a little better that what Visio automatically creates for you.
This is how you can accomplish this:
1. Select your shape, and go to your main menu and select Data>Display Data on Shapes”. Alternately you can right-click to bring up the context menu and select Data>Edit Data Graphic…
2. And new panel should have appeared on the right hand side of your Visio working area (default). This is the Data Graphics panel where you’ll create the labels to be displayed on your shape
3. Select “New Data Graphic…” under “Create a new data graphic”
4. A new dialog window will appear
Fig. 1 – the New Data Graphic dialog.
Now that you have the dialog up, you’ll notice that there’s nothing there. That’s what you want. Follow the instructions to “Click ‘new item’ to display data on shapes”. You’ll find that drop down menu on the top left of the dialog window.
When you display the menu, you’ll have several options that are available to you. For the purpose of what we’re creating, you’ll only want to select the first item. The rest, you can experiment with on your own.
The item will invoke a new prompt (Microsoft is obsessed with this).
This is how you can accomplish this:
- There are several fields that are available to you, the one you’ll start with first is the “Data field”
- If you recall earlier when you were setting the key/value pairs in the Shape Data dialog, you should notice the same items available to you when you click on the drop down menu. Select “ID”
- Turn your attention to the “Callout” field – this is where you can specify a style for the label. I suggest that you stick with a Text callout due to the nature of what we’re building. Experiment with the other types when you have a chance
- Next, let’s look at the “Callout position”. You’ll notice that the two drop downs: “horizontal”, and “vertical” fields are greyed out. Uncheck “Use default position”
- You should now have access to the two fields. Set the horizontal position to “center” and leave the vertical position where it is
This next part can be a bit confusing the first time around, but follow these steps:
- Leave the “Show Value” property as “Yes”
- Leave the “Value Format” property as blank, it will automatically use the format you set earlier in the Shape Data dialog
- Leave the “Label Position” property with its default
- Delete the “[Default]” value from the “Label” property
- Set the “Border Property” value to “None”
- Leave both “Fill Type” and “Callout Offset” at “None”
- Click “OK” to set your changes
You should be back to the “New Data Graphic” dialog. Now that you’ve done the first one, rinse and repeat for the other fields.
Note: When you come to the “Type” field, set the “Show Value” property as “No”.
Click the “OK” button to apply the Data Graphic to your shape.
Fig. 2 – The result after the Data Graphic fields have been set.
Step 4: Formatting Your New Labels
We now have an opportunity to adjust the layout of our new Data Graphic’s labels. If you’ve followed the steps above, you’ll have accomplished something that approximates this:
Fig. 3 – The result after formatting the fields.
If you recall the alignment we left in Step 3, you’ll see that reflected in the orientation of the labels. It’s not pretty, but if you’re partial to that, feel free to keep the alignment and move on to the last step. If however, you are like me, you’ll want to make some minor tweaks.
Click on the object until you’re able to select the text field containing one of the fields. Once you’ve selected the field, you can format it as you wish (color, fonts, font size, etc.). It’s likely that you’ll want to adjust the alignment at the very least (centered).
Rinse and repeat for the the “Label” field.
You should now have a Visio shape that you can quickly set the properties for when you add it to your pages and diagrams.
Note: There is one caveat though, and you’ll have to balance this with what you’re getting in return: you may find that having constant prompts will annoy you especially if you need to work quickly or you’re not the type of user to have your pinkie you the “esc” key. You can avoid this by not enabling an automatic prompt, I’ll leave that to you to decide.
Step 5: Adjusting the Behaviour of the Shape
This last (and final) step is the most crucial aspect of making a truly (re)usable Visio shape. It’s important because it will allow the author or designer to quickly make modifications to the Shape Data without having to manually click through the shape’s various objects.
We’re going to tackle this in two ways:
- Enable a custom double-click behaviour to the shape that will display the shape’s Shape Data dialog.
- Restrict the default editing and formatting features of shape to preserve the Data Graphics we’ve attached to the shape.
Restricting Editing and Formatting
All Visio shapes share common properties that you can customize in order to get the behaviour you want from it. If you recall from earlier in the article where we were first creating the shape, it was easy to simply double-click and start entering text. In this case, what we want to do is restrict some of the normal behaviour of the shape, and not allow the author to input text directly onto the shape. We also want to restrict the author from modifying the internal layout of the shape and the Data Graphics.
Follow these quick steps to accomplish the desired behaviour:
- Right-click on your shape to bring up the context menu, and select Format>Behaviour
- The “Behaviour” tab will contain all the common behaviour properties of the shape; turn your attention to the “Group Behaviour” options on the bottom right portion of the dialog.
- Deselect “Edit text of group”
- Under the “Selection” property, change the setting to “Group Only” – this will restrict the selection of nested shapes and make the overall shape appear as if it is the only selectable shape.
- Click “OK”
Fig. 1 – Accessing the “Behaviour” dialog through the context menu.
Fig. 2 – The “Behaviour” dialog after properties have been set.
Enabling Custom Double-click Behaviour
If you took some time in the to explore the behaviour dialog, you’ll have noticed the “Double-click” tab. That particular set of properties allows you to attach some typical behaviours to the shape, but you’ll also notice that the “Custom” option is greyed out. We want to be able to set this, but Visio will not allow us to do it through the dialog.
Note: It took me about 3 days to figure this out, not having really delved too deeply into Visio’s Shape Sheet capabilities, so hopefully someone will read this post and save someone else like me a little grief.
The “Custom” option is greyed out for reason, and it appears that customization means delving into the murky depths of Visio’s “Shape Sheets”. It’s not as bad as I make it out (I’m still harbouring a little frustration), and it’s a relatively painless task to complete.
Follow these quick instructions to accomplish this time-saving behaviour:
- Right-click on your shape and select “Show Shape Sheet”. This will bring up a new window which you will find chock full various property sheets.
- Scroll to the bottom of the list until you find one property sheet labelled “Events” – this is crucial.
Note: If you cannot see an “Events” sheet, that means it’s hidden. To show the “Events” sheet, simply right-click somewhere in the grey area outside of the various property sheets, and select “View Sections” from the context menu. You’ll find a collection of checkboxes that indicate the different sheets. Find the “Event” sheet and enable it by selecting the checkbox. Hit “OK” to return back to the Shape Sheet window.
- In the “Events” sheet, locate a property labelled “EventDblClick” – this is where we instruct the shape what to do when we double-click on it. Enter the following value (case sensitive): “=DOCMD(1312)” (replace everything in the field including the equal sign, but do not include the quotes). Hit the Enter button to accept the changes.
- Close the Shape Sheet window as we no longer need it.
Fig. 3 – The “Events” property sheet.
If you’ve followed the instructions above, you should expect to see the Shape Data dialog window pop up. Test this behaviour on your customized shape by double-clicking.
That’s it. You now have a shape that you can make your diagram work a little more productive.
There are many other purposes for which Shape Data can be leveraged. If you recall one of the properties that I specified early on was “type”. I’ll save that for a later posting, but if you search Google for the term “Visio multi-shape”, you’ll get an idea of what I’ll be covering next.
The one thing I likely did not articulate in this article was that Data Graphics can be reused and re-applied to other shapes that you might want to display similar Shape Data. The caveat being that you’ll have to re-format the fields for each one again. You can create new Data Graphics as you need them, but be sure to keep your document as clean as possible of unnecessary clutter. You can do this by going to File>Remove Hidden Information. I’ll leave the rest for you to figure out.
Events & Behaviours
There are many other behaviours that you can attach to shape events, and double-click is just one of those. For more information about Visio’s DOCMD() macro, check out the MSDN documentation here.
This won’t make you a better UX designer by any means, but it can certainly help you save some time so you can focus on what’s important. Take some time to consider some of the other customization features you can apply to your shape, but remember: as is often the case, simplicity is the goal.