Humble Pie is an AppleScript script that demonstrates the scripting ablility of Adobe Illustrator. Illustrator’s graphing capability is not accessible to scripting, so this script draws pie charts directly.
Humble Pie is saved as a compiled script, and is best run from Illustrator's script menu; it will run from the Script Editor, but much more slowly. It can be freely copied, modified, and used in other scripts, provided the source is acknowledged.
When run, it will ask you for a list of values (separated by spaces), or if it should instead use tab-delimited values on the clipboard (“Clip”). If you use the clipboard, you can have labels for the values; you want the clipboard to contain the equivalent of either a row of labels and a row of figures, or a column of labels and a column of figures (it’s designed to deal with data copied from a spreadsheet).
Humble Pie will then ask for the radius of the chart in points: enter a suitable number.
The chart will be created on its own layer (called “Graph”). Each slice will be named (“Slice 1”, etc), as will each sample in the legend (“Sample 1”, etc) and its label (“Label 1”, etc). Each slice-and-sample pair will be grouped (”Group 1”, etc). For this reason, you should create only one chart per Illustrator document (you can copy and paste them later if you want). The graph will be centred in the page area.
The script colors the slices in greyscale percentages. It also gives them a 0.25-point black border (this can be changed; see the values strokeWidth and strokeColor near the top of the script).
The script also has the ability to update its charts; if run again with new values, it should redraw while retaining any changes you have made to stroke and fill. This feature is fairly basic, and as such is fragile. (It will also move a chart back to the centre of the page if you have moved it.)
Requirements:
· Adobe Illustrator CS2-CS4