A bar chart is one of the most commonly used methods of graphically presenting data for quick interpretation. Such charts work nicely within the constraints of the ZX80 and MicroAce. Beside making for a good display, they provide an excellent way of storing data.
The program listed here works with 1K to chart two years of monthly checking account balances with vertical bars. The graph is set up for a range of $0 to $1500, but can be modified for other ranges with a few changes and some trial-and-error experimentation. Of course, any other sort of data such as monthly rainfall or average temperatures, miles-per-gallon, electricity use, or frequency distributions (histograms) can be plotted.
Because of memory limitations the array storing the data is created and filled in a routine that is later erased (lines 10-100). All elements of the array contain either data or zeroes, and line 320 is used to show the user which element of the array should be filled next. To add a monthly figure enter 330 LET B(16)=XXXX, then GO TO 330 and N/L, and finally erase line 330 and update line 320 to REM B(17).
After entering the program, you can enter the following data to see how it works: 1012, 796, 931, 1236, 1252, 1088, 786, 1132, 1194, 908, 1113, 896, 913, 849, 553, 429.
Subroutine
10 DIM B(23)
20 FOR I=0 TO 23
30 LET B(I)=0
40 NEXT I
50 FOR I=0 TO 23
60 PRINT I
70 INPUT B(I)
80 IF B(I)=0 THEN STOP
90 IF I>20 THEN CLS
100 NEXT I
Erase lines 10-100 and use GO
TO 1 instead of RUN hereafter.
Bar Chart Program
100 REM GO TO 1 (Leave cursor on line
110 PRINT 100 when saving
120 PRINT reminder not to RUN.)
130 PRINT "X100 AVE DAILY BALANCE" (3 sp.)
140 PRINT "----(3 sp. and 17 SHIFT G)"
150 PRINT
160 FOR I=-15 TO 0
170 LET K=(I/3)*10-I*10/3
180 IF K=0 AND I<-9 THEN PRINT -I;"-";
190 IF K=0 AND I>-10 THEN PRINT " ";-I;"-"; (1 sp.)
200 IF K>0 THEN PRINT " -"; (2 sp.)
210 FOR J=0 TO 23
220 IF B(J)=0 THEN GO TO 280
230 LET D=B(J)+I*100
240 IF D<-25 THEN PRINT " "; (1 sp.)
250 IF D>-26 AND D<25 THEN PRINT CHR$(7);
260 IF D>24 THEN PRINT CHR$(130);
270 NEXT J
280 PRINT
290 NEXT I
300 PRINT " 1980 (SHIFT E) 1981" (7, 4, and 3 sp.)
310 STOP
320 REM B(16)
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.