Pie Charts and Multiple Screen Dumps

See all articles from Sinc-Link v8 n4
Author(s): Warren Fricke
Publication: Sinc-Link
Pub Details: Sinc-Link v8 n4 (Volume 8, Issue 4)
Date: July/August 1990
Pages: 26

In this monthly contribution, I want to demonstrate in particular the capability of the TS2068 for constructing PIE CHARTS from a given set of values. The program is arranged as a tutorial so that one may substitute other items and values and use it as a utility for a statistical program.

In this illustration we assumed seven items: Salaries, Insurance, etc. The number of items can be any thing but such a chart usually accommodates up to 10 items without crowding. If you have a different number of items, change the values in program lines 20, 30, 100, 300, etc. to suit.

Program line 50 contains a correction factor “n” which allows the resulting pie to look like a circle instead of an ellipse. As you know, circles do not reproduce undistorted on the prinout. As we cannot conveniently correct this distortion in the CIRCLE algorithm, it was not used.

This exercise also demonstrates the capability of the TS2068 to produce printouts of more than one screen dump. In this instance two screens were dumped onto the printer in succession, giving a unified look to the chart and accompanying text. This scheme can be used for more than two, if desired, by a continuation of the process. Refer to program lines 180 and 400. When the run STOPs at these points, get the printer ready, and by direct entry do a CONTinue….ENTER. Better yet; just delete the STOP commands in these lines and the figure builds up automatically.

Now, how many other computers can do this with such a simple and short BASIC program?

Warren Fricke

   2 REM ** MODEL of a PIE CHART
3 REM ** "C-63", 10-7-87, WF
5 REM ** UPPER BORDER
7 DRAW 0,175: DRAW 255,0: DRAW 0,-175
10 REM ** IDENTIFY and EVALUATE ITEMS
20 DIM q$(7,15): DIM r$(7,5): LET T=0
30 FOR a=1 TO 7: READ q$(a): READ r$(a): LET T=T+VAL r$(a): NEXT a
40 REM ** UNDISTORTED CIRCLE
50 LET n=1.23: REM Cor. Factor
60 FOR a=0 TO 2*PI STEP .02
70 PLOT 127+n*80*COS a,92+80*SIN a: NEXT a
80 REM ** DRAW SECTOR RADII
90 LET a=0: REM Starting Angle
100 FOR p=1 TO 7
110 LET a=2*PI*VAL r$(p)/T+a
120 FOR R=0 TO 80
130 PLOT 127+n*R*COS a,92+R*SIN a
140 NEXT R: NEXT p
150 REM ** IDENTIFY SECTORS
160 PRINT AT 5,18;"S";AT 7,8;"I";AT 9,7;"OS";AT 15,11;"R";AT 17,18;"U";AT 13,22;"JS";AT 11,27;"D"
170 PRINT AT 20,1;"SECTORS are";AT 20,21;"identified"
175 PRINT AT 21,1;"by the INITIALS of the ITEMS."
180 STOP : COPY : CLS
255 REM ** LIST ITEMS & AMOUNTS
260 PRINT AT 1,2;"ITEM";TAB 20;"DOLLARS"
270 PRINT OVER 1;AT 1,2;"____";AT 0,20;"_______": PRINT
300 FOR a=1 TO 7
310 PRINT 'TAB 2;q$(a);TAB 22;r$(a): NEXT a
323 PRINT AT 16,19;"__________"
325 PRINT AT 18,4;"Total..........";T
330 PRINT AT 20,1;"EXPENSES of the WIDGIT COMPANY"
340 PRINT OVER 1;AT 20,1;"______________________________"
350 REM ** LOWER HALF BORDER
360 PLOT 0,175: DRAW 0,-175: DRAW 255,0: DRAW 0,175
400 STOP : COPY
500 DATA "Salaries","40563","Insurance"," 4160","Office Supplies"," 4918","Rent","25001","Utilities","14987","Janitor Serv."," 8026","Depreciation"," 2898"
Pie chart printout: Expenses of the Widgit Company
Pie chart printout: Expenses of the Widgit Company

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.