REM ***********************************************
REM Title: Pie Chart
REM Author: 
REM Downloaded from: http://dbcc.zimnox.com/
REM ***********************************************
 
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
end
 
 
 
 
 
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