View Single Post
I've seen other AppleScript for creating pie charts in OmniGraffle that involved using trigonometry. The Adjustable Wedge object (in the Common stencil under shapes) lets you do it much more simply.

The code is below. I put a post describing it here:


- Joseph

tell application "OmniGraffle Professional 5"
set pieLoc to {50, 50}
set pieDiameter to 400
set wedgeValues to {24, 55, 77, 130, 37}
set wedgeColors to {{1, 0, 0}, {0, 1, 1}, {1, 0, 1}, {0, 0, 1}, {0, 1, 0}}
set wedgeStartAngle to 0

set wedges to {}

set sumOfWedgeValues to 0
repeat with wedgeValue in wedgeValues
set sumOfWedgeValues to sumOfWedgeValues + wedgeValue
end repeat

repeat with i from 1 to count of wedgeValues
set wedgeDegrees to ((item i of wedgeValues) / sumOfWedgeValues) * 360
set wedgeEndAngle to wedgeStartAngle + wedgeDegrees
tell canvas of front window
set wedge to make new shape at end of graphics with properties {name:"AdjustableWedge", size:{pieDiameter, pieDiameter}, origin:pieLoc, startAngle:wedgeStartAngle, endAngle:wedgeEndAngle, draws shadow:false, draws stroke:false, fill color:item i of wedgeColors}
end tell

set end of wedges to wedge

set wedgeStartAngle to wedgeEndAngle
end repeat

assemble wedges
end tell