Regarding PieChart [Archive] - XML Elves

Regarding PieChart

Priya
07-07-2005, 07:24 AM
Hi friends,
I am trying to generate a pie chart... and i have taken a piece of code in an example of pie chart from the net... and the code is below..

<g style="stroke:black;stroke-width:1" transform="translate(350,150)">
<g style="fill:#6699cc" transform="rotate(-0) ">
<path d="M 0 0 h 130 A 130,130 0,0,0 115.13706634041603,-60.36104666523466 z"/>
<text class="values" x="63" y="-10" transform="rotate(0 63 -16)">8%
</text>
</g>

my doubt is how the values (x,y) endpoint of arc are derived ? i.e., the values of (115.13706634041603,-60.36104666523466) in the path command.......

Please let l me know are there any formulas behind it....

Thanks ,
Priya

Anonymous
07-08-2005, 01:18 AM
In your path
<path d="M 0 0 h 130 A 130,130 0,0,0 115.13706634041603,-60.36104666523466 z"/>
PieChart is centered in 0 0. Radius is 130.
You will show 8%, so in angle it's Math.PI * 16 / 100 and your arc end in
0 + 130 * Math.cos(Math.PI * 4 / 25)
0 - 130 * Math.sin(Math.PI * 4 / 25)

If you want to draw next pie, you have to store current angle and calculate ...
If your next value is 15% by example, d attribute for next pie will be
M 0 0 Lx1 y1 A 130 130 0 0 0 x2 y2 z" with
x1 and y1 are previous point 115.... -60....
x2 = 0 + 130 * Math.cos(Math.PI * 4 / 25 + Math.PI * 3 / 10)
y2 = 0 - 130 * Math.sin(Math.PI * 4 / 25 + Math.PI * 3 / 10)

Michel

Priya
07-08-2005, 03:28 AM
hi Michel,

Thanks for u r detailed explanation....
I got the point.....

Thanks..
Priya

 
Web mp2kmag.com
mapforums.com

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum