BAR CHART
by Norman Brooks
from ZX Computing Jun/Jul.1984

[see BARCHART.GIF for the accompanying program flowchart. JimG]

BAR CHARTS REVISITED

Don't just store that information inside your ZX81,
display it with the aid of Norman Brooks in Kent.


When confronted with a mass of numeric data it is often
easier to understand and analyse if it is drawn as a bar
chart. This program enables you to chart up to twenty-four
numeric quantities and can handle numbers in the range of 0
to 9999. You can manipulate the vertical scale at will to
suit the commodity you are charting.

Menu driven, it enables you to set up a bar chart and, once
created, add and change data quickly and easily. You might
for example use it to:

Chart annual income. Graph media statistics (eg. Retail
Price Index.) Compare electricity/gas usage quarter by
quarter. Chart bills such as telephone, rates, groceries
etc. Log petrol consumption, car mileage, service charges
etc. Present experimental results for school projects.

The list is really endless and I'm sure you can think of
many more applications which would benefit from this method
of presentation.


Variables

V         Number of menu option selected.
T$        Bar chart title.
X$        X axis title.
W$        Column label.
Y$        Y axis title.
A         Maximum Y value.
B         Minimum Y value.
Z1        A-B modified to suit screen size.
Z2
P         Power of 10 to which A-B has been modified.
Z(10)     String of scale numbers for printing on Y axis.
D$ to I$  Graphic variables for drawing chart framework.
C         Number of columns required.
D(C)      String of inputted data.
N(C)      String of inputted data less minimum value of Y (ie. B).
C1        Number of extra columns required.
C2        Number of column where data is to be changed.


Loading instructions

Type in listing using line 10 REM "BAR CHART" to
periodically SAVE as you go. Once this is completed, line 10
is redundant as the program offers an automatic SAVE option
at line 5600. You might wish to change this to read 5600
SAVE T$ so that you SAVE and LOAD to the specific name you
give to your chart.

Start the program by typing RUN 1000. This will then take
you through every stage necessary to set up a new chart.
(Alternatively type GOTO 10 which will start you at the menu
screen and then choose option 6). From then on never RUN the
program as this will destroy your variables. If for any
reason you break out of the program then re-enter by typing
GOTO 10.

You can always start a new chart on a different topic by
LOADing an existing chart and selecting menu option 6.


A few words

1  INPUTted numeric data is rounded to the nearest pixel division
   on the Y axis scale.
2  By PLOTting the bars I am using a grid of 20 rows by 24 columns.
3  The Y axis scale will never show a number greater than 100 but
   at the base of the scale you will see a scale factor;
   eg. X1, X10, X100 etc. Thus, a value of say 600 would show a bar
   to a height of 60 with a scale factor of X10.
4  I indicated in the opening remarks that the maximum number the
   program can handle is 9999. The graph can be used to plot any
   positive number but as the data is PRINTed above the graph I am
   limited in space to 4 digits per number to prevent adjacent
   numbers merging. You can INPUT non whole numbers providing the
   maximum number of digits does not exceed 4.
   ie. Data less than 1 = numbers to 3 decimal places.
   From 1 to 9.99 = numbers to 2 decimal places.
   From 10 to 99.9 = numbers to 1 decimal place.
   100 and above = whole numbers only.
   I have found this adequate for most applications.
5  As all INPUTted information is shown on the resultant bar chart
   (option 1 from menu) a hard copy of the graph is offered using
   the COPY feature at line 5730.
6  Using the "Electricity Consumption" shown in Fig.7 you will note
   that I have INPUTted data as zero in columns 5, 10, 15 and 20 to
   delineate one year from the next and have labelled these columns
   with a SPACE. I have found this a useful presentation technique.


--
Another Fine Product transcribed by:
Jim Grimwood (jimg@globalnet.co.uk), Weardale, England
--
