Hi,<br><br>This is a solution, rather than a problem.<br><br>I had need for a pie chart with a clickable imagemap in a webpage where I was also rendering maps with mapserver. I thought about looking for a tool to do this for me, then decided to write a quick script to make a small table in my postgis database that would have the necessary information to draw the pie chart with mapserver. This code will generate a pie-ish chart within a bounding box of (-1 -1 1 1). It is pie-ish because the sectors are actually triangles, not true circle sectors. That could be modified, I had over 100 segments, and that approximated a circle well enough for my purposes.
<br><br>I am submitting the perl code in case others have use for it. Trivial abuse of mapserver, yes, but it was very handy for me -- perhaps it will be handy for someone else.<br><br>Below the dotted line is the perl code.
<br><br>Thanks,<br>Matt<br><br>--------------------------------------<br><br>#This perl code generates coordinate combinations using WKT to create<br>#a table whose geometry rendered by mapserver will create a pie-ish<br>
#chart. It's not exactly a pie chart, as the pie wedges are triangles,<br>#not true circle sectors, but it's close enough for a large number of<br>#slices. Code should be easily modifiable to make more circular<br>
#objects for low number of slices.<br><br>########################################################################<br># config<br>########################################################################<br>my $PI = 3.1415926535897932384626433832795
;<br><br>my $slices = 134; # number of pie slices<br><br>my $ccw = -1; # 1 is counter-clockwise, -1 is clockwise<br><br>my $phase = -$PI / 2.0; # phase shift of the starting point<br> # -$PI /
2.0 starts slice enumeration at the<br> # 12 o'clock position<br><br>########################################################################<br># generate wkt coords of slices<br>########################################################################
<br>for my $i (1 .. $slices) {<br> my $xy1<br> = sprintf(<br> "%5f %5f"<br> , cos (2 * $PI * ($i - 1) * $ccw / $slices - $phase)<br> , sin (2 * $PI * ($i - 1) * $ccw / $slices - $phase)<br>
);<br> my $xy2<br> = sprintf(<br> "%5f %5f"<br> , cos (2 * $PI * $i * $ccw / $slices - $phase)<br> , sin (2 * $PI * $i * $ccw / $slices - $phase)<br> );<br><br> print "insert into temp values"
<br> ,"($i,GeometryFromText('POLYGON ((0 0, $xy1, $xy2, 0 0))',-1));"<br> , "\n";<br>};<br><br clear="all"><br>