Tallan's Technology Blog

Tallan's Top Technologists Share Their Thoughts on Today's Technology Challenges

Add Over 10 Slices To A Visio Pie Chart, And Bind Thickness to External Data

azimmer

This blog post will explain how to accomplish the seemingly easy task of adding over ten slices to a Visio pie chart. This is done using Visio 2013, but the steps using 2010 and 2007 should be very similar. Once all the slices are added to the pie chart, each individual slice will be bound to external data, giving them a dynamic thickness.

Lets start by creating a new basic Visio page and placing a regular pie chart on it, by going to More Shapes–> Business–> Charts and Graphs–> Chart Shapes.

Notice that Visio gives you the option of adding a maximum of ten slices. At this point, if you know your way around Visio a little bit you might be tempted to right-click on the pie chart and go to Data–>Define Shape Data and try to alter the “slices” property and add more “Pie” properties, which is exactly what I did at first. Unfortunately, this glimmer of hope is shot down when you realize the chart just ignores any properties after the tenth one. So you can’t get more than ten slices using shape data, what next? The Pie Slice shape in the Graph and Math Shapes looks promising, maybe you can go into the shape sheet and bind couple of slice shapes together. Long story short, the slice shape is not the same as the slice shapes that make up the original pie chart because of their extra “controls” table in the shape sheet which allows manually setting the thickness. Unfortunately this does not allow a way to set the thickness of the slice in the shape sheet.

So, how do we actually accomplish this?

The trick is to place a regular pie chart in our sheet, and then copy/paste an individual slice. You might notice you can’t move/rotate/manipulate this slice in any way right now. You will need to go into the shape sheet and turn off some protections associated with the shape.

Now copy and paste this modified slice again so you have two, and delete the original pie chart.

Binding the two together

At this point your sheet will look similar to this:

The goal now is to “glue” the slice on the left to the slice on the right, so it will be attached no matter the thickness and position of the right slice. After analyzing the shapesheets of some slices on the original pie chart, I found the relationship I needed. Assuming the slice on the right is “Pie chart.1034″ and the slice on the left is “Pie chart.1035″, the shapesheet of the lefthand slice will look as follows:

And your sheet should look something like this:

We have now successfully bound the two slices together. Any number of slices can be added using this method and just swapping out the slice name in the example with the slice name you would like to bind the current slice to.

Giving Each Slice A Dynamic Thickness

The next goal is to give each slice in our pie chart dynamic thickness. After much more shapesheet analyzing, I found that the cell that determines the thickness is column C, first row, in the scratch table (not the easiest thing to find). If you just want to have a static thickness, you can just set the value of this cell to a static percentage:

Just make sure all your values add up to one hundred percent for your chart will look a little funny. If you want to bind the thickness to external data, it is pretty similar. In my example I have budget data for 28 different sectors and total budget, which is just the total of the 28 sectors. Bind the corresponding external data to each slice, and then modify the cell from above. My equation looks like the one below, where Prop._VisDM_cy_ytd_expense is budget data from one of the 28 sectors, and Prop._VisDM_ytd2014_budget is the total of all the 28 sectors.

After I got each of my 28 slices glued to the one before it, I bound the thickness of each one to their corresponding external data. I left the first slice and the last slice unglued to each other so that if you make a mistake and your data doesn’t add up to 100%, or you forgot to bound a slice to data, you will know immediately because the first and last slice will either overlap or there will be a gap in the pie chart. If everything is done correctly it should always look like the first and last slice are glued together. My final product, after a little styling of course, is shown below. Obviously after too many slices your pie chart may start to look a little messy, but you can have at least 20 slices before this starts to happen.

This pie chart will change dynamically with the external data, and can even be used as a dynamic pie chart in Visio Services for SharePoint 2013. If you need a pie chart for a less advanced application than this, feel free to use the static pie chart model instead. Either way, rest assured that if you ever need a Visio pie chart with over ten slices, there is a way to do it. Hope this helps, thanks for reading.

2 Comments. Leave new

Excellent detective work! And a very nice and usable end result.

John Marshall
July 30, 2013 7:51 am

Close, but…
The pie chart is a grouped shape that consists of a main shape that contains information about the slices and ten slice shapes that refer back to the main shape. The correct way would be to add extra rows to the main and add slices to the group. You will have to use Developer Mode to change the protection so you can add to the group. Scott wrote two books on how to do it. 😉
It was a good analysis, but you will find if you work from the main shape, the interactions will be more obvious. The scratch sections are not the easiest things to understand.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

\\\