Pascal pie charts

Can anybody tell me how to create a pie chart in pascal.  The user must enter in the numbers to be represented> Thanks.
PunditAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
mitchell042997Connect With a Mentor Commented:
Do you know how to do basic graphics in pascal?  You will use graph.tpu, so you will need to add:

   uses graph;

now, look in help for the command titled arc.

The basics behind drawing a pie chart are as follows.  You must first determine the probability of each of your "wedges".  For example, if you had a pie chart representing a group's hobbies, and the sample was taken from 10 people, and 4 said reading, 2 said walking, 1 said modelling, and 3 said programming, then get probabilities for all activities (3/10, for programmers, 4/10 for reading, etc.)  Now, take that decimal number, and multiply it times 2*pi.  This is the amount of radians each will take up.  If you need it in degrees, multiply each decimal by 360.  Then just do a simple loop which starts at 0 degrees or 0 radians, and steps through each activity, drawing from the current radian to the current radian plus the activities allocated radians.  Once drawn, adjust the current radian setting to the current radian setting previously, plus the current activity's alloted radians.
0
 
mitchell042997Commented:
Has this been helpful?  If so, please grade the answer, else tell me what further information you need and I will gladly supply it!  :)  Happy programming...
0
All Courses

From novice to tech pro — start learning today.