Tải bản đầy đủ
APPENDIX C.1: BAR AN D COLUMN CHARTS COMPUTER PROGRAM “GRAPH-C1”

APPENDIX C.1: BAR AN D COLUMN CHARTS COMPUTER PROGRAM “GRAPH-C1”

Tải bản đầy đủ

APPENDICES

131

The user now has to choose how to display the column chart data, either as a single or multiple column chart, or as a
stacked or 100% stacked column chart. The user can also display a background grid if required for scaling. Once these
selections have been made, the program branches at Line 740, depending on the user choice of presentation.
(g) Data preparation for columns

Line numbers 750–990

This segment of code contains three sets of routines to prepare data for a single column chart or for either of the stacked
column charts.
(h) Column chart display

Line numbers 1000–1670

This is the column chart part of the program and uses several of the graphics presentation routines described in
Chapter 1, to set up the screen (GOSUB 7300), title the graph (GOSUB 7500), and draw a background grid if
required (GOSUB 7600). Colours and monochrome hatching patterns are then chosen for the display. If a single or
multiple column chart display was chosen, this is drawn in Lines 1200–1410. If a stacked column chart was chosen, then
this is drawn in Lines 1500–1670.
(i) Bar chart presentation?

Line numbers 2500–2740

The user now has to choose how to display the bar chart, either as a single or multiple bar chart, or as a stacked or 100%
stacked bar chart. The user can also display a vertical grid if required for scaling.
(j) Data preparation for bars

Line numbers 2750–2990

This segment of code contains three sets of routines to prepare data for a single bar chart or for either of the stacked bar
charts.
(k) Bar chart display

Line numbers 3000–3670

This is the bar chart part of the program and uses several of the graphics presentation routines described in Chapter 1. To
set up the screen for bar charts, the X and Y axes have to be reversed, and this is contained in a routine at Line 7800.
The graph is titled using (GOSUB 7500) where some changes are required due to reversing the X and Y axes. A
background grid is also drawn if required (GOSUB 7600). Colours and monochrome hatching patterns are then chosen
for the display. If a single or multiple bar chart display was chosen, this is drawn in Lines 3200–3410. If a stacked bar
chart was chosen, this is drawn in Lines 3500–3670.
(l) Appendix A.8
Line numbers 7000–7090
(m) Appendix A.9
Line numbers 7100–7290
(n) Appendix A.10
Line numbers 7300–7490
(o) Appendix A.11
Line numbers 7500–7590
Note changes required to reverse X-axis and Y-axis labels.
(p) Appendix A.12
Line numbers 7600–7710
(q) Reverse X and Y axes

Line numbers 7800–7990

132

BAR AND COLUMN CHARTS

This routine is similar to (n) above, except that the X and Y axes ranges are reversed, with the X-range now plotted
vertically and the Y-range plotted horizontally.
The program also requires the following routines.
(r) Appendix A.2
(s) Appendix A.3
(t) Appendix A.4
(u) Appendix A.5
(v) Appendix A.14
(w) Appendix A.3
(x) Appendix A.15
(y) Appendix A.16
(z) Appendix A.17
(aa) Appendix A.18
(bb) Appendix A.19

Line numbers 8000–8180
Line numbers 8200–8390
Line numbers 8400–8490
Line numbers 8500–8590
Line numbers 8600–8660
Line numbers 8800–8990
Line numbers 9000–9050
Line numbers 9500–9600
Line numbers 10000–10310
Line numbers 40000–40590
Line numbers 55000–56960

“GRAPH-C1”—BASIC program
10 REM Presentation Graphics Program C.1
14 REM (C) Copyright P.H.Milne 1990 - Bar/Column Charts
16 REM ALL RIGHTS RESERVED
20 REM VERSION PC-1.00, 1990
30 CLEAR
40 ON ERROR GOTO 10000
50 PCF$ = "PGSCRDSK.PGD"
60 GOSUB 8000: REM Check Screen & Disc
70 X0 = 70: Y0 = 50: DATBX = 0: YSCM = 0: YSCMAX = 0
75 A$ = "*": DSET$ = "*": HIST$ = "N" : HGRID$ = "N": VGRID$ = "N"
80 DIM Z(15, 6), ZD(15, 6), ZP(15, 6), DAT$(5)
90 WINDOW (0, 0) - (639, 199)
100 CLS : PC$ = "Bar Chart"
110 GOSUB 8200: REM Check ID File and DATA
120 LOCATE 15, 10: PRINT "Number of DATA Sets = "; ND
130 LOCATE 17, 10: PRINT "Number of DATA Points = "; NROW
140 LOCATE 20, 10: PRINT "Do you wish to VIEW Graph (Y/N) ";
150 A$ = INPUT$(1)
160 IF INSTR("YNyn", A$) = 0 THEN 140
170 IF A$ = "N" OR A$ = "n" THEN 9500
180 IF SCR% <> 2 THEN GOSUB 8600
200 CLS : GOSUB 9000
210 GOSUB 7000: REM Check Min & Max Data
240 LOCATE 12, 10: PRINT "Y-AXIS : Min = "; YMIN
250 LOCATE 12, 40: PRINT ": Max = "; YMAX
260 LOCATE 15, 10: PRINT "Change Default Values (Y/N) ";
270 A$ = INPUT$(1)
280 IF INSTR("YNyn", A$) = 0 THEN 260
290 IF A$ = "N" OR A$ = "n" THEN 340
320 LOCATE 18, 10: INPUT "New Y-AXIS (Y-min, Y-max) "; YMIN, YMAX

APPENDICES

330
350
355
360
370
380
390
400
410
420
430
440
499
500
510
520
530
540
541
542
543
544
550
560
561
570
580
585
590
591
592
593
594
595
600
605
610
620
630
640
650
670
680
690
695
700
705
710
720

IF YMIN >= YMAX THEN 320
IF YMIN > 0 THEN YMIN = 0
IF YMIN < 0 THEN YMIN = YMIN − 10
XTC = INT(500 / NROW): XND = INT(XTC / (ND + 1))
XM = 500
YTC = (YMAX − YMIN) / 10: TCC = YTC: GOSUB 7100
YTC = TCC: YM = 120
GOSUB 8500: REM Read Titles from Disc
LOCATE 20, 10: PRINT "Change Graph Titles (Y/N) ";
A$ = INPUT$(1)
IF INSTR("YNyn", A$) = 0 THEN 410
IF A$ = "N" OR A$ = "n" THEN 590
REM ***** JUMPS HERE FROM ERROR IN 8500 *****
CLS : GOSUB 9000
LOCATE 6, 10: INPUT "Enter Graph Title (Max 40) "; TITLE$
LOCATE 8, 10: INPUT "Enter X-AXIS Title (Max 30) "; LXAXI$
LOCATE 10, 10: INPUT "Enter Y-AXIS Title (Max 11) "; LYAXI$
LOCATE 12, 10:
INPUT "Y-AXIS Title (H)oriz. or (V)ert. "; YLAB$
IF INSTR("HVhv", YLAB$) = 0 THEN 540
IF YLAB$ = "h" THEN YLAB$ = "H"
IF YLAB$ = "v" THEN YLAB$ = "V"
FOR I = 1 TO NCOL − 1
LOCATE 13 + I, 10:
PRINT "Enter Legend DATA "; I; " (Max 9) ";
INPUT DAT$(I)
NEXT I
GOSUB 8400: REM Store Titles on Disc
LOCATE 22, 10: PRINT "Select Column Chart or Bar Chart (C/B)";
CH$ = INPUT$(1)
IF INSTR("CBcb", CH$) = 0 THEN 590
IF CH$ = "C" THEN CH$ = "C"
IF CH$ = "b" THEN CH$ = "B"
IF CH$ = "B" THEN 2500
CLS : PC$ = "Column Chart": GOSUB 9000
IF ND = 1 THEN NSEL = 1: GOTO 695
LOCATE 5, 10: PRINT "Select Column Chart Presentation :-"
LOCATE 8, 10: PRINT "<1> Single column chart"
LOCATE 10, 10: PRINT "<2> Multiple column chart"
LOCATE 12, 10: PRINT "<3> Stacked column chart"
LOCATE 14, 10: PRINT "<4> 100% stacked column chart"
LOCATE 16, 10: PRINT "Enter Choice "; : SEL$ = INPUT$(1)
IF INSTR("1234", SEL$) = 0 THEN 670
NSEL = VAL(SEL$)
IF SCR% <> 2 THEN 740
LOCATE 20, 10: PRINT "Do you wish Horizontal Grid (Y/N)";
HGRID$ = INPUT$(1)
IF INSTR("YNyn", HGRID$) = 0 THEN 700
IF HGRID$ = "y" THEN HGRID$ = "Y"

133

134

BAR AND COLUMN CHARTS

730 IF HGRID$ = "n" THEN HGRID$ = "N"
732 IF HGRID$ = "Y" THEN YLAB$ = "V"
735 IF NSEL = 4 THEN YLAB$ = "V"
740 ON NSEL GOTO 750, 1000, 800, 900
749 REM *** Setup Single Column Chart/Histogram ***
750 IF ND = 1 THEN K = 2: GOTO 772
755 LOCATE 22, 10: PRINT "Which Data Set to plot 1-"; ND;
760 DSET$ = INPUT$(1)
765 IF INSTR("12345", DSET$) = 0 THEN 760
770 K = VAL(DSET$) + 1
772 LOCATE 24, 10: PRINT "Plot as Histogram (Y/N) ";
775 HIST$ = INPUT$(1)
780 IF INSTR("YNyn", HIST$) = 0 THEN 775
785 IF HIST$ = "y" THEN HIST$ = "Y"
790 IF HIST$ = "n" THEN HIST$ = "N"
795 GOTO 1000
799 REM *** Setup Stacked Column Chart ***
800 FOR I = 1 TO NROW: YSCM = 0
810 FOR K = 2 TO NCOL
820 YSCM = YSCM + (Z(I, K) − YMIN)
830 IF YSCM > YSCMAX THEN YSCMAX = YSCM
840 NEXT K
850 NEXT I
860 YTC = YSCMAX / 10
870 TCC = YTC: GOSUB 7100
880 YTC = TCC: YM = 120
890 GOTO 1000
899 REM *** Setup 100% Stacked Column Chart ***
900 FOR I = 1 TO NROW: YSCM = 0
910 FOR K = 2 TO NCOL
920 YSCM = YSCM + (Z(I, K) − YMIN)
930 ZP(I, K) = YSCM
940 NEXT K
950 FOR J = 2 TO NCOL
960 ZD(I, J) = ZP(I, J) / YSCM
970 NEXT J
980 NEXT I
990 YTC = 10
1000 GRAPH = 2: GOSUB 7300: REM Sets up Screen
1010 GOSUB 7500: DATBX = 1: REM Titles
1015 IF NSEL = 1 THEN J = VAL(DSET$): GOTO 1030
1020 FOR J = 1 TO NCOL − 1
1030 AVGX = 94 + 103 * (J − 1): AVGY = Y0 − 22
1040 GOSUB 40000
1050 LOCATE 22, 1 + J * 13: PRINT DAT$(J)
1055 IF NSEL = 1 THEN 1070
1060 NEXT J
1070 IF HGRID$ = "N" THEN 1100
1080 GOSUB 7600: REM Draw Grid

APPENDICES

1100
1110
1120
1130
1140
1150
1200
1210
1215
1220
1225
1230
1240
1245
1250
1255
1320
1330
1340
1350
1360
1370
1380
1390
1400
1410
1499
1500
1510
1520
1530
1540
1550
1560
1570
1580
1590
1600
1610
1620
1630
1640
1650
1660
1670
2499
2500
2510
2520

IF SCR% = 2 THEN CL(1) = 4 ELSE CL(1) = 1
IF SCR% = 2 THEN CL(2) = 1 ELSE CL(2) = 1
IF SCR% = 2 THEN CL(3) = 2 ELSE CL(3) = 1
IF SCR% = 2 THEN CL(4) = 3 ELSE CL(4) = 1
IF SCR% = 2 THEN CL(5) = 5 ELSE CL(5) = 1
ON NSEL GOTO 1200, 1200, 1500, 1500
FOR J = 1 TO NROW: IF NSEL = 1 THEN 1215
FOR K = 2 TO NCOL
IF NSEL = 1 THEN X1 = (J − 1) * XTC + X0 + 15
IF NSEL = 2 THEN X1 = (J − 1) * XTC + (K − 1)
IF HIST$ = "Y" THEN X1 = (J − 1) * XTC + X0 +
Y1 = Y0 + 1
IF HIST$ = "N" THEN X2 = X1 + (XND − 1)
IF DSET$ <> "*" THEN X2 = X1 + XTC / 2
IF HIST$ = "Y" THEN X2 = X1 + XTC
Y2 = (Z(J, K) − YMIN) * 12 / YTC + Y0
IF X1 > 560 THEN 1390
IF Y1 > 160 THEN 1390
IF SCR% <> 2 THEN 1360
LINE (X1, Y1) − (X2, Y2), CL(K − 1), BF: GOTO
LINE (X1, Y1) − (X2, Y2), , B
PAINT (X1 + 2, Y1 + 2), TILE$(K − 1)
IF NSEL = 1 THEN 1400
NEXT K
NEXT J
GOTO 9500
REM ***** Stacked Column Charts *****
FOR J = 1 TO NROW
Y1 = Y0 + 1
FOR K = 2 TO NCOL
X1 = (J − 1) * XTC + X0 + 10
Y1 = Y1
X2 = J * XTC + X0
IF NSEL = 3 THEN Y2 = Y1 + (Z(J, K) − YMIN) *
IF NSEL = 4 THEN Y2 = Y0 + ZD(J, K) * 120
IF X1 > 560 THEN 1650
IF Y1 > 160 THEN 1650
IF SCR% <> 2 THEN 1620
LINE (X1, Y1) − (X2, Y2), CL(K − 1), BF: GOTO
LINE (X1, Y1) − (X2, Y2), , B
PAINT (X1 + 2, Y1 + 2), TILE$(K − 1)
Y1 = Y2
NEXT K
NEXT J
GOTO 9500
REM ***** BAR CHART *****
YTC = INT(120 / NROW)
YND = INT(YTC / (ND + 1))
YM = NROW * YTC

* XND + X0
1

1380

12 / YTC

1640

135

136

BAR AND COLUMN CHARTS

2530
2340
2550
2600
2610
2620
2630
2640
2650
2670
2680
2690
2695
2700
2705
2710
2720
2730
2735
2740
2749
2750
2760
2765
2770
2780
2790
2799
2800
2810
2820
2830
2840
2850
2860
2870
2880
2890
2899
2900
2910
2920
2930
2940
2950
2960
2970
2980
2990

XTC = (YMAX − YMIN) / 10
TCC = XTC: GOSUB 7100
XTC = TCC: XM = 500
CLS: GOSUB 9000: IF ND = 1 THEN NSEL = 1: GOTO 2695
LOCATE 5, 10: PRINT "Select Bar Chart Presentation :-"
LOCATE 8, 10: PRINT "<1> Single bar chart"
LOCATE 10, 10: PRINT "<2> Multiple bar chart"
LOCATE 12, 10: PRINT "<3> Stacked bar chart"
LOCATE 14, 10: PRINT "<4> 100% Stacked bar chart"
LOCATE 16, 10: PRINT "Enter Choice "; : SEL$ = INPUT$(1)
IF INSTR("1234", SEL$) = 0 THEN 2670
NSEL = VAL(SEL$): HGRID$ = "N": VGRID$ = "N"
IF SCR% <> 2 THEN 2740
LOCATE 20, 10: PRINT "Do you wish Vertical Grid (Y/N) ";
VGRID$ = INPUT$(1)
IF INSTR("YNyn", VGRID$) = 0 THEN 2700
IF VGRID$ = "y" THEN VGRID$ = "Y"
IF VGRID$ = "n" THEN VGRID$ = "N"
YLAB$ = "V"
ON NSEL GOTO 2750, 3000, 2800, 2900
REM *** Setup Single Bar Chart ***
IF ND = 1 THEN K = 2: GOTO 3000
LOCATE 22, 10: PRINT "Which Data Set to plot 1-"; ND;
DSET$ = INPUT$(1)
IF INSTR("12345", DSET$) = 0 THEN 2760
K = VAL(DSET$) + 1
GOTO 3000
REM *** Setup Stacked Bar Chart ***
FOR I = 1 TO NROW: XSCM = 0
FOR K = 2 TO NCOL
XSCM = XSCM + (Z(I, K) − YMIN)
IF XSCM > XSCMAX THEN XSCMAX = XSCM
NEXT K
NEXT I
XTC = XSCMAX / 10
TCC = XTC: GOSUB 7100
XTC = TCC: XM = 500
GOTO 3000
REM *** Setup 100% Stacked Bar Chart ***
FOR I = 1 TO NROW: XSCM = 0
FOR K = 2 TO NCOL
XSCM = XSCM + (Z(I, K) − YMIN)
ZP(I, K) = XSCM
NEXT K
FOR J = 2 TO NCOL
ZD(I, J) = ZP(I, J) / XSCM
NEXT J
NEXT I
XTC = 10

APPENDICES

3000
3010
3015
3020
3030
3040
3050
3055
3060
3070
3080
3100
3110
3120
3130
3140
3150
3200
3210
3215
3220
3225
3230
3240
3250
3255
3320
3330
3340
3350
3360
3370
3380
3390
3400
3410
3499
3500
3510
3520
3530
3540
3550
3560
3570
3580
3590
3600
3610

GRAPH = 2: GOSUB 7800: REM Sets up Screen
GOSUB 7500: DATBX = 1: REM Titles
IF NSEL = 1 THEN J = VAL(DSET$): GOTO 3030
FOR J = 1 TO NCOL − 1
AVGX = 94 + 103 * (J − 1): AVGY = Y0 − 22
GOSUB 40000
LOCATE 22, 1 + J * 13: PRINT DAT$(J)
IF NSEL = 1 THEN 3070
NEXT J
IF VGRID$ = "N" THEN 3100
GOSUB 7600: REM Draw Grid
IF SCR% = 2 THEN CL(1) = 4 ELSE CL(1) = 1
IF SCR% = 2 THEN CL(2) = 1 ELSE CL(2) = 1
IF SCR% = 2 THEN CL(3) = 2 ELSE CL(3) = 1
IF SCR% = 2 THEN CL(4) = 3 ELSE CL(4) = 1
IF SCR% = 2 THEN CL(5) = 5 ELSE CL(5) = 1
ON NSEL GOTO 3200, 3200, 3500, 3500
FOR J = 1 TO NROW: IF NSEL = 1 THEN 3215
FOR K = 2 TO NCOL
IF NSEL = 1 THEN Y1 = (J − 1) * YTC + Y0 + 4
IF NSEL = 2 THEN Y1 = (J − 1) * YTC + (K − 1) * YND + Y0 + 3
IF DSET$ <> "*" THEN Y1 = (J − 1) * YTC + Y0 + 4
X1 = X0 + 1
Y2 = Y1 + (YND − 1)
IF DSET$ <> "*" THEN Y2 = Y1 + YTC / 2
X2 = (Z(J, K) − YMIN) * 50 / XTC + X0
IF X1 > 560 THEN 3390
IF Y1 > 170 THEN 3390
IF SCR% <> 2 THEN 3360
LINE (X1, Y1) − (X2, Y2), CL(K − 1), BF: GOTO 3380
LINE (X1, Y1) − (X2, Y2), , B
PAINT (X1 + 1, Y1 + 1), TILE$(K − 1)
IF NSEL = 1 THEN 3400
NEXT K
NEXT J
GOTO 9500
REM ***** Stacked Bar Charts *****
FOR J = 1 TO NROW
X1 = X0 + 1
FOR K = 2 TO NCOL
Y1 = (J − 1) * YTC + Y0 + 3
X1 = X1
Y2 = J * YTC + Y0
IF NSEL = 3 THEN X2 = X1 + (Z(J, K) − YMIN) * 50 / XTC
IF NSEL = 4 THEN X2 = X0 + ZD(J, K) * 500
IF X1 > 560 THEN 3650
IF Y1 > 170 THEN 3650
IF SCR% <> 2 THEN 3620
LINE (X1, Y1) − (X2, Y2), CL(K − 1), BF: GOTO 3640

137

138

BAR AND COLUMN CHARTS

3620
3630
3640
3650
3660
3670

LINE (X1, Y1) − (X2, Y2), , B
PAINT (X1 + 2, Y1 + 2), TILE$(K − 1)
X1 = X2
NEXT K
NEXT J
GOTO 9500

7500
7510
7515
7520
7525
7526
7527
7530
7535
7536
7537
7540
7545
7550
7552
7555
7560
7570
7580
7590
7800
7810
7820
7830
7840
7850
7860
7870
7880
7890
7900
7805
7910
7920
7930
7940
7950
7960
7970
7980
7990

LNT = LEN(TITLE$): LNC = 40 − LNT/2
LOCATE 2, LNC: PRINT TITLE$
IF CH$ = "B" THEN 7525
LNT = LEN(LXAXI$): LNC = 40 − LNT/2: GOTO 7530
IF NSEL = 4 THEN LYAXI$ = "Percentage"
LNT = LEN(LYAXI$): LNC = 40 − LNT/2
LOCATE 21, LNC: PRINT LYAXI$: GOTO 7535
LOCATE 21, LNC: PRINT LXAXI$
IF YLAB$ = "V" THEN 7550
IF NSEL = 4 THEN 7550
IF CH$ = "B" THEN 7550
LOCATE 4, 11: PRINT LYAXI$
RETURN
IF CH$ = "C" THEN YDIST$ = LYAXI$
IF CH$ = "B" THEN YDIST$ = LXAXI$: GOTO 7560
IF NSEL = 4 THEN YDIST$ = "Percentage"
FOR I = 1 TO 15
LOCATE 6 + I, 3: PRINT MID$ (YDIST$, I, 1)
NEXT I
RETURN
IF SCR% <> 2 THEN 7820
COLOR 15, 0
CLS: GOSUB 9000
IF SCR% = 2 THEN RGB% = 12 ELSE RGB% = 3
LINE (10, 20) - (620, 180), RGB%, B
IF GRAPH = 0 THEN RETURN
IF SCR% = 2 THEN RGB% = 15 ELSE RGB% = 3
LINE (X0, Y0 + YM) - (X0, Y0), RGB%: LINE − (X0 + XM, Y0), RGB%
IF GRAPH = 1 THEN RETURN
FOR LYD = 1 TO NROW
AVGY = Y0 + 1 + INT(YTC / 2) + (LYD − 1) * YTC
AVGX = X0 − 11: LDAT = Z(LYD, 1)
PSET (X0, AVGY): LINE − (AVGX, AVGY), RGB%
AVGX = AVGX − 20: AVGY = AVGY − 4: GOSUB 55000
NEXT LYD
FOR LXD = 0 TO 10
AVGX = X0 + LXD * 50: AVGY − Y0 − 3: LDAT = YMIN + LXD * XTC
PSET (AVGX, Y0): LINE − (AVGX, Y0 − 3), RGB%
AVGX = AVGX − 9: AVGY = AVGY − 8: GOSUB 55000
NEXT LXD
RETURN

APPENDICES

139

COMPUTER PROGRAM “GPLOT-C1”
To convert the program “GRAPH-C1” from screen graphics to an HPGL plotter the following changes are required:
replace segment (h) with the code for Lines 1000–1670, which are given at the end of this section
replace segment (k) with the code for Lines 3000–3670, which are given at the end of this section
replace segment (n) with Appendix A.28
replace segment (o) with the code for Lines 7500–7590, which are given at the end of this section
replace segment (p) with Appendix A.30
replace segment (q) with the code for Lines 7800–7990, which are given at the end of this section
replace segment (aa) with Appendix A.32
delete segments (v) and (bb)
add the following:
(cc) Appendix A.19
(dd) Appendix A.20

Line numbers 50000–50180
Line numbers 50500–50570

(ee) Appendix A.21
(ff) Appendix A.22
(gg) Appendix A.24

Line numbers 51000–51060
Line numbers 52000–52050
Line numbers 60000–60150

“GPLOT-C1”—BASIC program—segments (h), (k), (o) and (q) only
1000
1010
1015
1020
1030
1031
1032
1040
1045
1050
1060
1150
1200
1210
1215
1220
1225
1230
1240
1245
1250
1255

GRAPH = 2: GOSUB 7300: REM Sets up Plotter
GOSUB 7500: DATBX = 1: REM Titles
GOSUB 50500: REM Header
FOR J = 1 TO NCOL − 1
AVGX = 94 + 103 * (J − 1): AVGY = Y0 − 25
X1 = AVGX − 4: Y1 = AVGY
X2 = AVGX + 4: Y2 = AVGY + 4
K = J + 1: GOSUB 52000
PRINT #3, "PU;PA"; AVGX + 10; ","; AVGY; ";": GOSUB 60000
PRINT #3, "LB"; DAT$(J); CHR$(3): GOSUB 60000
NEXT J
ON NSEL GOTO 1200, 1200, 1500, 1500
FOR J = 1 TO NROW: IF NSEL = 1 THEN 1215
FOR K = 2 TO NCOL
IF NSEL = 1 THEN X1 = (J − 1) * XTC + X0 + 15
IF NSEL = 2 THEN X1 = (J − 1) * XTC + (K − 1) * XND + X0
IF HIST$ = "Y" THEN X1 = (J − 1) * XTC + X0 + 1
Y1 = Y0
IF HIST$ = "N" THEN X2 = X1 + (XND − 1)
IF DSET$ <> "*" THEN X2 = X1 + XTC / 2
IF HIST$ = "Y" THEN X2 = X1 + XTC
Y2 = (Z(J, K) − YMIN) * 12 / YTC + Y0

140

BAR AND COLUMN CHARTS

1320
1330
1340
1380
1390
1400
1405
1410
1499
1500
1510
1520
1530
1540
1550
1560
1570
1580
1590
1600
1640
1650
1660
1605
1670

IF X1 > 560 THEN 1390
IF Y1 > 160 THEN 1390
GOSUB 52000
IF NSEL = 1 THEN 1400
NEXT K
NEXT J
PRINT #3, "PU;SP0;": CLOSE
GOTO 9530
REM ***** Stacked Column Charts *****
FOR J = 1 TO NROW
Y1 = Y0
FOR K = 2 TO NCOL
X1 = (J − 1) * XTC + X0 + 10
Y1 = Y1
X2 = J * XTC + X0
IF NSEL = 3 THEN Y2 = Y1 + (Z(J, K) − YMIN) * 12 / YTC
IF NSEL = 4 THEN Y2 = Y0 + ZD(J, K) * 120
IF X1 > 560 THEN 1650
IF Y1 > 160 THEN 1650
GOSUB 52000
Y1 = Y2
NEXT K
NEXT J
PRINT #3, "PU;SP0;": CLOSE
GOTO 9530

3000
3010
3015
3020
3030
3031
3032
3040
3045
3050
3060
3150
3200
3210
3215
3220
3225
3230
3240
3250
3255
3320
3330

GRAPH = 2: GOSUB 7800: REM Sets up Screen
GOSUB 7500: DATBX = 1: REM Titles
GOSUB 50500: REM Header
FOR J = 1 TO NCOL − 1
AVGX = 94 + 103 * (J − 1): AVGY = Y0 − 22
X1 = AVGX − 4: Y1 = AVGY
X2 = AVGX + 4: Y2 = AVGY + 4
K = J + 1: GOSUB 52000
PRINT #3, "PU;PA"; AVGX + 10; "," AVGY; ";": GOSUB 60000
PRINT #3, "LB"; DAT$(J); CHR$(3): GOSUB 60000
NEXT J
ON NSEL GOTO 3200, 3200, 3500, 3500
FOR J = 1 TO NROW: IF NSEL = 1 THEN 3215
FOR K = 2 TO NCOL
IF NSEL = 1 THEN Y1 = (J − 1) * YTC + Y0 + 4
IF NSEL = 2 THEN Y1 = (J − 1) * YTC + (K − 1) * YND + Y0 + 3
IF DSET$ <> "*" THEN Y1 = (J − 1) * YTC + Y0 + 4
X1 = X0
Y2 = Y1 + (YND − 1)
IF DSET$ <> "*" THEN Y2 = Y1 + YTC / 2
X2 = (Z(J, K) − YMIN) * 50 / XTC + X0
IF X1 > 560 THEN 3390
IF Y1 > 170 THEN 3390

APPENDICES

3340
3380
3390
3400
3405
3410
3499
3500
3510
3520
3530
3540
3550
3560
3570
3580
3590
3600
3640
3650
3660
3605
3670

GOSUB 52000
IF NSEL = 1 THEN 3400
NEXT K
NEXT J
PRINT #3, "PU;SP0;": CLOSE
GOTO 9530
REM ***** Stacked Bar Charts *****
FOR J = 1 TO NROW
X1 = X0
FOR K = 2 TO NCOL
Y1 = (J − 1) * YTC + Y0 + 3
X1 = X1
Y2 = J * YTC + Y0
IF NSEL = 3 THEN X2 = X1 + (Z(J, K) − YMIN) * 50 / XTC
IF NSEL = 4 THEN X2 = X0 + ZD(J, K) * 500
IF X1 > 560 THEN 3650
IF Y1 > 160 THEN 3650
GOSUB 52000
X1 = X2
NEXT K
NEXT J
PRINT #3, "PU;SP0;": CLOSE
GOTO 9530

7500 LNT = LEN(TITLE$)
7501 PRINT #3, "SP2;SI0.3,0.55;SL0.2;": GOSUB 60000
7502 PRINT #3, "PU;PA320,185;": GOSUB 60000
7503 PRINT #3, "CP"; −LNT / 2; "0;": GOSUB 60000
7510 PRINT #3, "LB"; TITLE$; CHR$(3): GOSUB 60000
7511 PRINT #3, "SP1;SL;SI0.2,0.3;PU;PA320,35;": GOSUB 60000
7515 IF CH$ = "B" OR CH$ = "b" THEN 7525
7520 LNT = LEN(LXAXI$): PRINT #3, "CP"; −LNT / 2; "0;": GOSUB 60000
7521 GOTO 7530
7525 LNT = LEN(LYAXI$): PRINT #3, "CP"; −LNT/2; "0;": GOSUB 60000
7526 PRINT #3, "LB"; LYAXI$; CHR$(3): GOSUB 60000: GOTO 7550
7530 PRINT #3, "LB"; LXAXI$; CHR$(3): GOSUB 60000
7550 IF CH$ = "C" OR CH$ = "c" THEN YDIST$ = LYAXI$
7555 IF CH$ = "B" OR CH$ = "b" THEN YDIST$ = LXAXI$
7560 LNC = LEN(YDIST$)
7570 PRINT #3, "PU;PA30,65;": GOSUB 60000
7575 PRINT #3, "DI 0,1;": GOSUB 60000
7580 PRINT #3, "LB"; YDIST$; CHR$(3): GOSUB 60000
7585 PRINT #3, "DI 1,0;"
7590 RETURN
7800 GOSUB 50000
7805 PRINT #3, "IN;"
7810 PRINT #3, "IP"; IPXMIN; ","; IPYMIN; ","; IPXMAX; ","; IPYMAX;
";"
7815 PRINT #3, "SC 0,640,0,200;"

141