Pie Chart Algorithms?

Klaus Major klaus at major-k.de
Tue Feb 28 16:38:47 EST 2006


Hi Swami,

> OK, was musing to make a simple pie chart: make a circle and set up  
> the center point as a fixed variable and the point on the circle as  
> the dynamic variable and draw radius lines programatically: seems  
> simple enough.. but:
>
> 1) draw circle graphic with shift key down to constrain to perfect  
> circle
> 2) name it "oval1"
> 3) msg box: put the points of grc "oval1"
>
> result: nothing
>
> I'm missing something... Where to go from here? Obvious algorithms  
> needed:
>
> 1) draw radius vectors e.g.
>
> -- set the divisions to 10% (of the circle); draw nine vectors  
> (where there are ten equal divisions)-- set initial vector to  
> vertical (center to point 1 where point one is the exact top of the  
> circle
> -- add second vector at 30% off the circle (another line draw 30  
> degrees off from the above radius )
>
> 2) fill resulting sectors (by script) with a color
> 3) find some point equidistant from the three points of a sector  
> (for dropping in a label field programatically)
>
> That's as far as I could "see" I sure others have invented this  
> wheel a long time ago... my trigonometry is  a bit too weak for me  
> to actually start writing the code from ground zero, but I could  
> probably "get it" if I saw some basic scripts.

my math ability is similary ehm... handicaped, but i would do it with  
some oval graphics,
all at the same loc, and calculate their "startangle" and "arcangle" :-)

Seems pretty easy, even to me :-D

> Meanwhile I'm off to dig the doc for related syntax.

Hope that wil get you started.

> Sivakatirswami

Regards

Klaus Major
klaus at major-k.de
http://www.major-k.de




More information about the use-livecode mailing list