Pie charts script for OmniGraffle
Frustrated by a lack of simple software for drawing easily editable pie-charts from simple data, I wrote a simple Applescript for the excellent OmniGraffle drawing package to do just that.
Pie charts are a bad way of displaying information. Consider using a bar chart instead, which allows easier comparison of values than the angular plotting of variables.
Take the example shown here. It's easy to tell that Sleep is half, and kinda easy to see that Play is probably about a quarter. It's impossible to tell without a protractor how much is Work or Eat, although (in this case) you can see that Eat is less than Work. It's difficult even to tell if Eat is more or less than half of the size of Work. Then again, they do look very... Use with caution, in limited situations.
Latest version: Adds labels on little stalks to the slices! (2006-02-20)
- Download pie_chart.zip (8 KB).
- Install the script.
- In OmniGraffle open a new document and select > Pie chart.
- In the window that appears enter the appropriate data, separated by spaces. It doesn't have to be whole numbers, but it will freak out if your put in negatives. Also, it doesn't necessarily have to add up to 100.
- Hit OK... tada! (Version 1.3 of this script produces the labels for slices on lines, so will look a little different from the images here.)
Tips and other uses
What you have now is pretty neat, but can easily be made to look a lot better with some obvious (and some less obvious) tricks.
Change the fill colour of the pie slices.
Rotate the chart if you need to. Select all the slices, then either Command-drag one of the blue control boxes or twiddle the twiddly thing in the Geometry inspector palette. The positioning of the numbers tends to get a little confused when you do this. Some form of sanity can be restored by clicking on the text alignment thingy in the Text Position inspector.
Scale the chart. Again, select all the slices, then drag the blue control points around. Holding down shift while doing this preserves the aspect ratio.
Space out the slices. Slightly sneaky this one. Setting the stroke colour of the slices to the same as the background, then changing the stroke thickness changes the apparent gap between the slices.
New in v1.3! Labels and lines are automatically added. Obviously the labels are just numbers, so you will probably want to change them to be something more meaningful.
New in v1.1! The script now automatically adds a magnet half way around the arc of each pie slice. This makes lines from labels or other shapes naturally attach themselves in a much more sensible fashion.
And if you've got a lot of time to kill, and a limited palette...
- Some people have noticed that the script may not run when selected from the menu when using OmniGraffle 3.1.2, and only works when opened from the Finder. This was due to a change in the way Script Editor and OmniGraffle work together. Using OmniGraffle 3.2 or later fixes the problem.
- When using the latest version of OmniGraffle 3.2, release candidate 1 the text entered does not appear in the pie slices as it did in earlier versions. This is fixed in the final version of 3.2 or later.
- There is no error checking. As such, if you do anything out of the ordinary the script will almost certainly give strange—or no—results. Obvious things which come to mind which will confuse it are putting in negative numbers, or words. If you do do something funny, OmniGraffle will give you the option to edit the script. Feel free! Let me know if you come up with anything great.
- The data in pie charts is usually percentages, which add up to 100. If you put in some numbers which you think add up to 100, but you get it a bit wrong, and they don't, it'll still look quite good, and won't complain at you.
- Aligning the text in a slice to the centre of the shape has variable results. In nice shapes like halves or quarters it does as you would expect, but with various other sizes the text doesn't seem to sit anywhere near the middle. This isn't anything much to do with the script, and is just how OmniGraffle aligns things. Sometimes having some of the slices aligned to centre, and others aligned right with a large amount of padding can have good results.
- Multiple charts are always drawn in the same place. Best to move your chart once it's been drawn if you are doing more than one. Grouping the slices together makes this (and aligning multiple charts) much easier.
- The text can be very hard to edit—or even see!— in very small slices. Often trying to double-click on the slice to edit the text will just add more points to the shape instead. The trick to changing (or usually deleting it) is to zoom right in and click on it with the text tool.
Things to maybe get around to some nice day
- Allowing comma-separated data.
- Draw the slices already coloured.
- Maybe some error checking here and there might be a good idea.
- Make multiple charts not all draw one on top of the other.
- Allow a choice somewhere of having the numbers drawn in the slices, or on lines.
- Other suggestions and comments are more than welcome.
- Applescript sine function from the Applescript Guidebook [no longer online]
- Code for drawing OmniGraffle shapes initially very loosely borrowed from Fraser Speirs' very clever Table Builder script.
- Everyone who has provided feedback and suggestions. It's really these occasional e-mails that remind me to get around to fixing things that I've been meaning to do.
- 1.4 (2008-04-30)
- Script updated to work in Omnigraffle 5.0. No changes to the features.
- 1.3 (2006-02-20)
- Script now (in OmniGraffle 4.x only) draws little lines from the slices to the data. They're sometimes a little squint, but possibly better than nothing! Not sure if there should be two separate versions of the script to do this, or not do this. Comments appreciated.
- 1.2 (2005-06-03)
- Now works with both OmniGraffle 3.2 or later and with 4 beta 1 and hopefully later betas. When using version 4 the script uses Bezier curves instead of points which makes for more efficient (and accurate) slices.
- 1.1 (2005-04-19)
- Now adds a magnet to each pie slice, half way around its arc. This makes lines for labels stick to more sensible places.
- 1.0 (2005-02-23)
- Initial release. Apparently works with OmniGraffle versions 3.2 beta 1, 3.2 and 3.2.1. Should also work fine with corresponding Pro versions of OmniGraffle.