Pie Chart by Phaelax16th Mar 2004 22:12
|
---|
Summary Draws a pie chart. Add as many slices as you want, each with a value. Percentage that each slice takes up of the whole is automatically configured. Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com Global dim slices(0) as float Global numberOfSlices as integer Global valueTotal as float addSlice(50) addSlice(30) addSlice(153.5) addSlice(97) drawPieChart(300,300,100) suspend for key function addSlice(amount as float) array insert at top slices(0) slices(0) = amount valueTotal = valueTotal + amount inc numberOfSlices endfunction function drawPieChart(x as float, y as float, r as float) for i = 0 to numberOfSlices-1 percentage# = (slices(i) / valueTotal) * 100.00 a# = a# + (slices(i) * 360) / valueTotal x2# = x + cos(a#) * r y2# = y + sin(a#) * r line x, y, x2#, y2# text x2#, y2#, str$(percentage#)+"%" next i circle x, y, r endfunction |