# Illustrator

Currently Being Moderated

## how to make an odd shaped pie chart

### Apr 11, 2012 4:47 AM

Hi there,

I was wondering how difficult it would be to translate stats into an odd shaped object, to be divideed up into a pie. Oviously I could make a normal pie. overlay it and split the object up according to the angles, but this would result in un even area mass (ideally the area of each slace should equate to the percentage of each figue).

Hope this makes sense (my brains feeling slightly mushy thanks for excessive analysis of recycling statistics!

Kind regards D.E

Replies
• Currently Being Moderated
Apr 11, 2012 5:14 AM   in reply to daymonic

If your object is odd-shaped I have the feeling that it won't make a very good pie chart. It will be difficult to compare visually the relative areas og the slices.

Apart from that I don't think there's any way to divide an irregular shape automatically into slices of a predetermined area. You would presumably need to start off by finding the shape's centre of gravity but that will only get you so far. (There are threads about that. Here's a nice long one: http://forums.adobe.com/message/4279794#4279794)

|
Mark as:
• Currently Being Moderated
Apr 11, 2012 6:39 AM   in reply to daymonic

What kind of "odd shape" do you have in mind?

If you're talking about having AI's pie graph functionality automatically substitute any arbitrary shape for the circular pie, then no, there is no feature for such a thing.

If you're talking about manually substituting the arbitrary shape(s), and the stumbling block is just knowing the area of the arbitrary shape:

Illustrator's Javascript model does include an area property of the PathItem object, which returns the area of a path in square points. So you could:

1. Use the Pie Chart Graph tool to create a plain vanilla pie chart.

2. Ungroup the chart completely (several nestings deep) until you have individual paths.

3. Select a wedge, run the script (a simple script is below), note the area.

4. Draw the corresponding arbitrary shape, run the script, note the area.

5. Divide the areas to arrive at a scale factor.

6. Scale the arbitrary shape accordingly.

//script start

var docRef=app.activeDocument;

var pathRef=docRef.selection[0];

var pathRefArea=pathRef.area;

//script end

A little elaboaration of the script could automatically scale the arbitrary shape to the same area as that of the pie chart slice, but doing the simple math should not be arduous for occasional need.

So, for example, suppose you wanted to conceptually compare the counts of three separate recycled items by depicting proportional heaps of each item: aluminum cans, plastic bottles, glass bottles. You could:

1. Store a graphic of a single can, a single plastic bottle, and a single glass bottle as Symbols.

2. Use the Symbolism tools (Sprayer, Sizer, Scruncher, Spinner, etc.) to draw the three heaps.

3. Use the procedure described above to determine scale factors for the three heaps.

The results could look like three similarly- but irregularly-shaped piles of cans, plastic bottles, and glass bottles, proportionally sized to suggest the relative counts of recycled items.

JET

|
Mark as:
• Currently Being Moderated
Apr 11, 2012 10:19 AM   in reply to daymonic

Are you familair with using the pie chart tool in illustrator?

Click the pie tool

Enter the size of the pie chart you want (egL i used 4" x 4")

Enter the values in your excel style chart

Clcik the chekmark to generate chart

Expand the pie chart.

Use the pieces to either pathfinder or mask.

|
Mark as:
• Currently Being Moderated
Apr 11, 2012 11:45 AM   in reply to Mike Gondek

Obviously this method will work as long as the original object is roughly pie-shaped.

But what if it's L-shaped or even just plain square? You're going to get into hellish trouble reckoning out the areas of the slices (like JET explains).

It's a bit like dividing seven potatoes equally between five people – usually the easiest way is to mash them.

|
Mark as:
• Currently Being Moderated
Apr 11, 2012 1:12 PM   in reply to Steve Fairbairn

Still with the Bangers&Mash, eh Steve. Can't get the Englis out of the boy.

|
Mark as:
• Currently Being Moderated
Apr 11, 2012 3:52 PM   in reply to Larry G. Schneider

Still with the Bangers&Mash, eh Steve.

First thing I go for when visiting the UK. Can't get decent bangers here.

As fot the spuds, have you guys (stateside) got another word for mashing?

|
Mark as:
• Currently Being Moderated
Apr 11, 2012 3:58 PM   in reply to Steve Fairbairn

Usually here referred to as mashed potatoes.

|
Mark as:
• Currently Being Moderated
Apr 11, 2012 5:23 PM   in reply to Larry G. Schneider

Usually here referred to as mashed potatoes.

So that's just about the same. How about bangers or don't you have them? And I don't mean wieners/frankfurters.

Proper bangers ares made from fat pork, breadcrumbs moistened with milk, pepper, salt and various herbs.

Sold uncooked (pale and limp) and they fatten up when fried so you have to ***** them beforehand so that the skins don't split. Fry until crisp on the outside.

The final result looks something like this (the gravy is optional):

|
Mark as:
• Currently Being Moderated
Apr 11, 2012 9:10 PM   in reply to Steve Fairbairn

I think it sounds (and looks) excellent, but imagination fails me when I try to figure out  how to ***** them. What did Nanny omit?

|
Mark as:
• Currently Being Moderated
Apr 12, 2012 2:15 AM   in reply to tromboniator

It appears that Nanny deleted the very innocent word for what you do with a fork to make little holes.

p

r

i

c

k

Sorry 'bout that :-)

|
Mark as:
• Currently Being Moderated
Apr 12, 2012 6:14 AM   in reply to tromboniator

Ahahahaha. Best post ever.

|
Mark as:
• Currently Being Moderated
Apr 12, 2012 2:30 PM   in reply to daymonic

After wrestling for about 2 hours with Illustrator's immensely frustratingly limited Javascript, I'm officially giving up on this.

I came this far:

1. Select the base object, and enter a series of values. Easy as Pie Chart, so far. Even drawing a proper pie on top of the selection -- to use as a base value -- is ... doable. Just.

2. you cannot get 'the area' of a symbol or compound object. So I (manually!) draw an outline copy on top of the original and used that.

3. you cannot 'intersect', 'minus back', or do any other pathfinder operation. So I copied Carlos' method of creating a Graphic Style for Minus Back.

4. you cannot Expand Appearance from a script, and you cannot measure the area of a live Minus Back'ed object.

There goes my idea, down the drain: calculate the deviation of the sliced-up object to the value required, adjust, and re-slice the object according to this new insight.

Instead I got an entirely new insight. Guess what it was.

|
Mark as:
• Currently Being Moderated
Apr 12, 2012 5:32 PM   in reply to daymonic

We got into mashed potatoes because the best way to recycle your log of firewood is to reduce it to sawdust and then regroup it.

JET's answer is probably next best but my brain doesn't work the same way as his so I'm sure I would never get a script like he suggests to work properly.

Mike's way is good too but you would need to fiddle with it if you want to get the centre vertices to match the centre of the annual rings. I reckon I would fake it and hope that no-one would notice (which they probably wouldn't if you did it well). It has something to do with positioning the centre of the (undistorted) pie chart on a point diametrically opposite the centre of the annual rings and then moving just the centre points back the the centre of the rings, but I don't know how to do it mathematically.

Or maybe Jongware has got something up his sleeve that he's not letting on about.

|
Mark as:
• Currently Being Moderated
Apr 12, 2012 8:06 PM   in reply to daymonic

Assuming the graphic is roughly circular, like the example you showed:

JET

|
Mark as:
• Currently Being Moderated
Apr 12, 2012 9:11 PM   in reply to [Jongware]

[Jongware] wrote:

After wrestling for about 2 hours with Illustrator's immensely frustratingly limited Javascript, I'm officially giving up on this.

hahaha...sorry about that Jongware, I know, it's not funny...are you implying you can actually do stuff with ID scripting?

Instead I got an entirely new insight. Guess what it was.

#@%& Illustrator Scripting?

Message was edited by: CarlosCanto

|
Mark as:
• Currently Being Moderated
Apr 13, 2012 1:49 AM   in reply to CarlosCanto

CarlosCanto wrote:

...are you implying you can actually do stuff with ID scripting?

I sure can. You'll be amazed, but ...

Instead I got an entirely new insight. Guess what it was.

#@%& Illustrator Scripting?

right! ... so you're going to have to use InDesign to use that forthcoming Amazing Script.

|
Mark as:
• Currently Being Moderated
Apr 13, 2012 3:28 AM   in reply to daymonic

DE,

In a stump chart case like this it would seem appropriate to use the pith as the starting point of the chart.

The following images show a relatively simple way of making a quite accurate division in connexion with a stump that has a strongly asymmetric shape with reaction wood.

Always keep a copy of the artwork at different stages.

I) shows the stump, the stroke/nofill annual rings and the pith as a group kept on top and (mostly) locked in the following steps, the stroked and filled (outer) shape of the stump being worked with.

II) shows a division aid in the form of a 360 (1 degrees) pie chart, made from a Polar grid with 0 Concentric Dividers and 360 Radial Dividers: the Radial Dividers are extended past the outer circle, and the pie pieces are formed by Pathfinder>Divide.

III) shows the division aid centred over the pith.

IV) shows the stump moved on top of the division aid, its fill covering the inner part.

V) shows the result of Object>Path>Divide Objects Below where the stump has cut the division aid.

VI) shows the result when the outlying superfluous parts of the division aid have been deleted.

Now the division aid consists of 360 closed paths, each spanning 1 degree, all starting/meeting at the pith. These should be Ungrouped.

At any time up to this point, the total stump area may be determined, for older versions the free Telegraphics PathArea Filter may be used (available at http://www.telegraphics.com.au/sw/browse/Filters).

Now it is easy to select a number of closed paths of the division aid and use the PathArea filter (or whatever) to determine the proportion of the total area (simple division), to adjust by adding/removing and/or undoing/redoing, and then to Pathfinder>Unite (or whatever it is called in the version in question) to create a piece of the pie, and finally to increase the Stroke Weight as desired.

VII) shows the result of creating the top piece of 11%.

VIII) shows the result of creating all the pieces (made clockwise one at a time), the three 11% pieces (the first one and the two last ones) chosen to be alike, thus showing the great difference(s) in angles for identical areas.

This procedure leads to a great number of Anchor Points in the bark; it is possible to get rid of them by scaling the pieces with the pith as the key object, placing the original stump path on top, and Object>Path>Divide Objects Below, then delete the outlying parts.

It is also possible to move the pieces apart, away from the pith, if there is a wish to hurt the stump (even more).

The accuracy is well within 0.1% of the total stump area for the least accurate pieces.

|
Mark as:
Actions

#### More Like This

• Retrieving data ...

#### Answers + Points = Status

• 10 points awarded for Correct Answers