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 :D

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.

You can download the example for this tutorial here.

Getting Started:

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.

Moving on…

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.

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

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

Moving on…

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:

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

glue_points
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:

  1. ID – the numeric or text-based identifier for the shape
  2. Label – the label that you want to display, e.g. “home”, “about”, “contact”, etc.
  3. 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)

no_shape_data_prompt
Fig. 1 – The Shape Data prompt.

Click “yes” to bring up the Shape Data interface.

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

define_shape_data_dialog_properties
Fig. 3 – The result after adding custom properties.

This is how you can accomplish this:

  1. Prefix each of the above fields with “str_”, e.g “str_id” or for “ID” use “UID”
  2. 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”
  3. Provide a default value in the “Value” field, e.g. “[Page Name]”
  4. 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
  5. 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
  6. 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
  7. 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

data_graphic_dialog
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:

  1. There are several fields that are available to you, the one you’ll start with first is the “Data field”
  2. 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”
  3. 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
  4. 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”
  5. 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:

  1. Leave the “Show Value” property as “Yes”
  2. Leave the “Value Format” property as blank, it will automatically use the format you set earlier in the Shape Data dialog
  3. Leave the “Label Position” property with its default
  4. Delete the “[Default]” value from the “Label” property
  5. Set the “Border Property” value to “None”
  6. Leave both “Fill Type” and “Callout Offset” at “None”
  7. 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.

data_graphic_dialog_edit
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:

formatting_data_fields
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:

  1. Enable a custom double-click behaviour to the shape that will display the shape’s Shape Data dialog.
  2. 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:

  1. Right-click on your shape to bring up the context menu, and select Format>Behaviour
  2. 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.
  3. Deselect “Edit text of group”
  4. 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.
  5. Click “OK”

formatting_behaviour
Fig. 1 – Accessing the “Behaviour” dialog through the context menu.

formatting_behaviour_dialog
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:

  1. 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.
  2. 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.
  3. 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.
  4. Close the Shape Sheet window as we no longer need it.

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

Final Notes

Shape Data

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.

Data Graphics

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.

Conclusion

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.

You can download the example for this tutorial here.

farfromfearless

Comments on This Post:

  1. Raj
    Date: May 25, 2009
    Time: 6:28 pm

    Thanks for posting this article – it helped me get a quick custom shape done. I appreciate it. If you have done anything to change data in one shaped based on data from another shape, I would be interested in that.

    Thanks again.

  2. Chris Murphy
    Date: May 25, 2009
    Time: 6:34 pm

    Hi Raj, glad you found this posting useful — I had to figure a lot of this out from various sources online and on MSDN, so I hope others like yourself will find value in it.

  3. bedava indir
    Date: July 7, 2009
    Time: 8:11 am

    te?ekkür ederim.

  4. Strakos
    Date: August 8, 2009
    Time: 3:01 am

    http://www.forumfokurtu.com/

    We’ll everyone expected

  5. william
    Date: August 19, 2009
    Time: 9:17 pm

    thats a very nice software i would like to know more about this Visio software for my reference and conscesion of my works

  6. Cid
    Date: September 16, 2009
    Time: 6:17 pm

    Hi Chris,
    I hope you can guide me on this question re: Visio 2007 that I’m running into. When I go Save as a Web Page and “publish” a Visio doc and I checked off Details (shape data)and it sets the doc into html. Once in html why certain shapes display the details when I press Ctrl+click and some others don’t? I have not done anything differently from one shape to another. Only that these shapes are updated by an ODBC data. Thanks in advance!

  7. Visio Guy
    Date: September 23, 2009
    Time: 7:18 am

    @Cid

    Do you mean that shapes that actually have Shape Data aren’t displaying fields when you Ctrl+Click?

    If shapes don’t have any data, then they won’t display anything.

    Another suspect–shapes buried in groups–doesn’t foil the Save As Web. You can still Ctrl+Click these in the web page and see their data.

  8. John
    Date: September 24, 2009
    Time: 7:10 am

    very helpful, thank you for the article.

  9. anil
    Date: December 7, 2009
    Time: 10:01 am

    Hi Chris et al,

    Have copied a visio page containing created date in it.
    When I tried to change the created date, since it was showing as per the previously created page, I could not do so, am getting the same date. Please help me to change it.
    Regards,
    Anil

  10. Visio Produc…
    Date: March 11, 2010
    Time: 7:11 am

    [...] Shape Data can improve the task of updating and manage these shapes by automating the data-entry task. I won’t go into great detail here, but if you want more information about how to accomplish this, take a read through my tutorial: Creating a Reusable Shape with Visio Shape Data Support. [...]

  11. Chris Murphy
    Date: April 21, 2010
    Time: 4:33 pm

    It takes a little time, Visio can be A powerful tool for IA/UX folks–it’s taken me a little time to realize that I need to invest the time and effort into creating the assest and tools I need on Visio, otherwise I end up like others who shuffle around from tool to tool (not a very efficient practice). Would it be helpful if I wrote up a quick tutorial on how to build shapes for IA in Visio?

Add a Comment: