How to Make a Pie Chart |
|
Editor's Note: You can change the rect and the color listing to anything you like, and the pie chart will adapt to suit. Note that the parsing of the data is specific to the input provided - if you want your data coming in in a different format, you'll have to make the appropriate modifications.on mouseUp put fld 1 into tData put "20,20,220,220" into tRect put "blue,green,red,yellow,purple,orange,gray" into tColors -- MakePieChart tData, tRect, tColors end mouseUp on MakePieChart pData, pRect, pColors lock screen -- Set up template object: set the style of the templategraphic to "oval" set the rect of the templategraphic to pRect set the filled of the templategraphic to true -- -- Create legend field: create field "PieLegend" put it into tLegendField set the showborder of tLegendField to false set the locktext of tLegendField to true set the traversalon of tLegendField to false -- -- Create pie slices: put 0 into tCounter put empty into tNuObj repeat for each line tLine in pData add 1 to tCounter if tNuObj is not empty then put tNuObj into tOldObj create grc put it into tNuObj set the arcAngle of tNuObj to (360 * (last word of tLine/100) ) if tCounter > 1 then set the startAngle of tNuObj to (the arcAngle of tOldObj)+(the startAngle of tOldObj) end if put item tCounter of pColors into tColor set the backgroundcolor of tNuObj to tColor -- Make legend entry: put " "&word 1 of tLine into line tCounter of field "PieLegend" set the backgroundcolor of char 1 to 4 of line tCounter of field "PieLegend" to tColor end repeat -- -- Position legend field: set the height of field "PieLegend" to the formattedheight of tLegendField set the topleft of field "PieLegend" to the topright of grc 1 choose browse tool unlock screen end MakePieChart
Richard Gaskin
Fourth World Media Corporation
Custom Software and Web Development for All Major Platforms
Developer of WebMerge 2.0: Publish any Database on Any Site
___________________________________________________________
Ambassador@FourthWorld.com http://www.FourthWorld.com
Tel: 323-225-3717 AIM: FourthWorldInc
Posted on 11/11/2002 to the Use-Revolution list