On Montag, Nov 11, 2002, at 11:12 Europe/Zurich, yves COPPE wrote:

Hi,

I have a list of ages with percent :

0-10 : 15
11-20 : 20
21-30 : 17
...


does anyone know the script how to make a pie chart with this suite of data ?

Thanks.
--
Greetings.

Yves COPPE
I would take a look at the arcAngle and startAngle properties.
you could make 3 oval graphics and align them properly.
for your example, you would have to calculate like this:

15 + 20 + 17 = 52 // the whole circle is equivalent to 52 "pieces"
360 : 52 = 6.923077 // this is how big 1 "piece" would be in degree
15 * 6.923077 = 103.846155 // you must make a integer out of your results
20 * 6.923077 = 138.46154 //try to round to integer but beware of overlap and spaces!
17 * 6.923077 = 117.692309 //see how they are 360.000004 together?

The problem here is that you got all together 2.000004 behind the coma, and you only should have 2, so its quiet hard to calculate it exactly...

maybe like this:
//this is untested, so use it at your own risk
put (15 * 6.923077) into varGraph1
put (20 * 6.923077) into varGraph2
put (17 * 6.923077) into varGraph3
//calculate how many rest can be distributed //its 2.000004, remeber?
put trunc((15 * 6.923077) mod 1 + (20 * 6.923077) mod 1 + (17 * 6.923077) mod 1) into theStinkinRest
//divide them evenly among the members
repeat for theStinkinRest times
add one to counter
if counter mod 3 = 0 then
add one to varGraph3
else if counter mod 2 = 0 then
add one to varGraph2
else
add one to varGraph1
end if
end repeat


Now create 3 ovals that are the same size, round and on the same position

set the startangle of graphic "new graphic 1" to 360 //you could leave that out
set the arcangle of graphic "new graphic 1" to 104
set the startangle of graphic "new graphic 2" to 104
set the arcangle of graphic "new graphic 2" to 139
set the startangle of graphic "new graphic 3" to 242 //139 + 103
set the arcangle of graphic "new graphic 3" to 117

voila, pie!
nice munching ;)
Björnke von Gierke

_______________________________________________
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


Reply via email to