TK-Graph Manual

(main)
CONTENTS

INTRODUCTION

REFERENCE

Top Left Corner
Bottom Right Corner
Flags
Graph Title
X Axis Labels
X Axis Title
Y Axis Title
Legend
Graph Data
Printing Graphs
APPENDICES
A - SYSTEM INFORMATION
B - DEFAULT KEYBOARD ASSIGNMENTS


INTRODUCTION

The PG&A TK-GRAPH package provides the MUMPS programmer with the ability to easily generate device independent character graphics. Use your imagination with this graphing product. Its uses are almost endless.
Sample Graphs You may want to run the TK-GRAPH Sampler program which illustrates the tool's capabilities. To do this...

DO ^TKGRAPHS
If this is the first time PG&A software has been run on your system, the sampler will first take you through a short initialization before beginning its demonstration. See Appendix A for more information on the initialization process.
How To Use TK-GRAPH is very simple to use. The user need only set a single MUMPS local variable (Y) and call TKGRAPH (TKGRAP for a printer) with a DO command. TK-GRAPH does the rest.

The Y variable is a parameter string that instructs TK-GRAPH how the graph is to built and displayed on the screen. The Y variable consists of nine pieces delimited with a "\" backslash character. Pieces 1, 2, 3 and 9 are required, the others are optional. The pieces are defined as follows:

Piece Description
1 Top left corner
2 Bottom right corner
3 Flags that define graph type
4 Graph title
5 X axis labels
6 X axis title
7 Y axis title
8 Legend
9 Graph data points

The following reference pages describe in detail how each piece of the Y variable may be used and also includes examples.

The user should keep in mind that the graphs created for the display will superimpose any text that might already be on the screen. Once the graph has been drawn, the control is returned to the application program that called it. TK-GRAPH does not clear the screen before or after the graphing process.

Portability Although the MUMPS community has been slow in providing a portable solution to advanced terminal handling, Patterson, Gray and Associates has been addressing these issues since 1979. The tool TK-GRAPH, like each member of the Toolkit line, is based on an effective methodology for providing advanced terminal features while separating application software from its environment.

We hope your experience with the PG&A programming tool will be as enjoyable and profitable as ours.



TOP LEFT CORNER

Piece 1


Description Piece 1 of the Y variable specifies the upper left hand corner of the graph. First, specify the starting row number, keeping in mind that terminals normally only have 24 rows. Separated by a comma, enter the starting column, also keeping in mind that terminals normally have 80 columns.

Larger values for the row and column may be used on display terminals with more than 24 lines or 80 columns and when the graph is directed to the printer. On printed graphs the starting row value indicates how many lines are skipped before the graph is printed.


Example In the figure below, we can see how the starting point can alter the size of the graph window displayed on the screen.



BOTTOM RIGHT CORNER

Piece 2


Description Piece 2 of the Y parameter specifies the lower right hand corner of the graph. Enter the ending row number, and, separated by a comma, the ending column number. You may enter a larger number than 80 columns if your terminal or printer supports 132 column mode. TK-GRAPH will not switch into compressed mode automatically. It is up to the programmer to handle any terminal setup changes. Likewise, if printing a graph to hard copy, you can specify the graph to be longer than 24 lines.

Generally you will want to create as large a graph as possible in the medium that you are working. Since the resolution of the graph is based upon the number of lines and columns, the larger the graph, the more accurate the readings.


Example In the figure below, we can see how the ending point can alter the size of the graph window displayed on the screen.



FLAGS

Piece 3


Description Piece 3 of the Y variable is the flag field. The flag field is a grouping of specifiers explained below which define the type and attributes of the graph.

Every graph will contain at least one or more flags. By changing the flags, you may change the physical appearance of the graph.

The flags may be included in any desired order. Some flags allow for an argument which immediately follows the flag. Each argument is one or more decimal numbers. If multiple numbers are allowed, they must be separated by commas.


Alternate
Intensity (A)
Reverses relative intensities of graph with a border. The flag "L" places a box around the drawn graph and the flag "H" causes the border to be displayed in lower intensity and the graph to be displayed in high intensity. The "A" flag alternates this order and causes the border to be in high intensity and the graph in low intensity.


Bar Chart (B) This flag defines the type of graph to be a bar chart. An optional number following the the "B" selects different types of bar charts where:

B - is the standard bar graph
B1 - is a stacked bar graph
B2 - (not currently used)
B3 - is a box and whisker graph

The data for the bar chart is found in piece 9 or the Y array (see the Y flag). The X value of the data is not important in magnitude, but indicates relative order. Although multiple Y values may be specified for any of the types of bar graphs, type B1 requires multiple Y values and type B3 requires five Y values for each X in the order of: maximum, 3/4 mark, median, 1/4 mark, minimum.

Note that bar charts are normally displayed using reverse video. Because some terminals require a a space on the screen to implement reverse video (non-embedded attribute terminals), it may be necessary to use the alternate character flag(s).

TK-GRAPH will alternate intensities between bars if there is more than one value per point. Because of the differences between terminals and printers the number of differing bars will not be constant. Some will show two different bars, some three and others four.


Alternate Characters (C) Follow C with a list of decimal codes to use instead of the default character sequence(s). (Default for X/Y graphs is an asterisk "*", default for bar charts is reverse intensity). The decimal codes represent the ASCII value of characters to be used. You may specify a second, a third and a fourth alternate characters by delimiting with a ";".

For an example: If you wanted the primary points of the X/Y graph to be "o" rather than the default "*" then you would specify "C111" in the flags as the "o" character has an ASCII value of 111. If on the other hand you want two characters to be display superimposed on each other, such as "+~BO" then you would use "C43,8,79" where the 8 represents a backspace.


Grid Lines (G) You may add one of two types of horizontal lines to the graph to make it easier to read accross a wide area. You indicate the type by either a "G" or "G1" flag.

A "G" flag applies the grid to the bars on a bar chart. It is not currently used on other types of graphs.

A "G1" flag adds a horizontal grid to the entire graph area for all types of graphs.


High Intensity (H) Specifies that the main portion of the graph is to be displayed in high intensity or bold. Without the "H" flag, the graph will be displayed in low or normal intensity and the X/Y points will be displayed in high intensity. The bars on the bar charts will be displayed in high and low as usual.

If a line border is specified with the "L" flag, it also will be displayed in either high or low intensity according to the "H" flag, unless the the "A" flag is included to alternate the intensity between the line border and the graph.

Line Border (L) Adds a line border around the complete graph including legends.


Override (O) Override automatic scaling on the Y axis.

TK-GRAPH automatically computes the range and scale factor for both X and Y axis. It performs a maximum and minimum search on all values and then computes an optimum scale taking into account line spacing and rounding of the numbers. This should be sufficient for most operations.

The user may override this automatic computation on the Y axis by specifying either the minimum, maximum and/or delta Y values. Follow O with three values separated by commas in the following format:

O minimun,delta Y,maximum (no spaces)

Missing values will be computed by TK-GRAPH.


Reverse Video (R) This flag displays the entire graph in reverse video. (This flag is not used by most printers when printing the graph.)


Values (V) Display Values on Bar Charts.

The data value for each bar is displayed directly above the bar. Because of the low resolution on the standard video display terminal, this flag is particularly helpful as it allows for more accurate differentiation between values.


X/Y Point
Graph (X)
Data values are displayed as points with asterik "*" as the default character for the points. The "C" flag may be used to override as shown below.

By using the "X1" flag, TK-GRAPH can connect the X/Y points using interpolation. The data points are displayed in high intensity and the interpolated points will be displayed in low intensity.


Y Array
Specified (Y)
A small number of data points will easily fit into piece 9 of the Y variable. For larger amounts of data points or for convenience in loading the values, you may load the Y array instead. Included the "Y" flag to indicate the data is in the Y array.

In setting the Y array, each X value uses a new subscript. The Y values are the data and multiple Y values are delimited with commas.


Three
Dimensional (3D)
This flag displays data as a block or a three dimensional box.



GRAPH TITLE

Piece 4


Description Piece 4 of the Y variable is optional. It allows for a title. If left blank, no title will be printed with the graph. Otherwise, enter any title you which. TK-GRAPH will double space a short title, and single space a longer one as illustrated below. Also keep in mind that by using a title, the actual graph will start one line lower.



X AXIS LABELS

Piece 5


Description Piece 5 of the Y variable is optional. If left blank, the X axis (horizontal axis) is numbered numerically according to the data entered in piece 9. (see TK-GRAPH data for additional information.) However, by entering either numeric or alpha characters seperated by commas, the X axis labeling is no longer contigent on the X values in piece 9 of the Y variable, but uses Piece 5. The example below illustrates a possible use of this.



X AXIS TITLE

Piece 6


Description Piece 6 of the Y variable is optional. It allows for an X axis title. If left blank, no title will be printed with the graph. Otherwise, enter any title you which. TK-GRAPH will double space a short title, and single space a longer one as illustrated below. Also keep in mind that by using a title, the actual graph will be one line higher than specified to allow room for the title.



Y AXIS TITLE

Piece 7


Description Piece 7 of the Y variable is optional. It allows for an Y axis title. If left blank, no title will be printed with the graph. Otherwise, enter any title you which.



LEGEND

Piece 8


Description Piece 8 of the Y variable is optional.

A legend is useful when there are multiple values of Y for each X. It provides a means of distinguishing points in a multi-point X/Y graph and it provides a guide for multi-bar bar graphs.

If piece 8 is used, TK-GRAPH will display the character(s) used to graph each value of Y along side the legend description. Enter text separated by commas for however many values there are as illustrated by the example below. Also keep in mind that by invoking a legend, the actual graph will be one line higher than specified to allow room for the legend.



GRAPH DATA

Piece 9


Description Piece 9 of the Y variable contains the actual data points to graph. It consists of an ordered structure with groupings of one or more Y values following each value of X. Multiple values of X are separated by a ";" and the Y values are delimited from the X with a ",". The format is as follows:

x~/1~\,y~/1A~\y~/1B~\...y~/1n~\;x~/2~\y~/2A~\...

There does not need to be the same number of Y values for each X. Non-existent or missing values of Y can be distinquished from Y with a value of 0 by using the empty string (i.e. 3,4,,6). The X value has little value in bar charts other than to define the order of the bars.

As an alternative to piece 9, the values may be inserted into the Y array (see the "Y" flag).



PRINTING GRAPHS


Printing Printing a graph from TK-GRAPH to a printer is as easy as displaying a graph on the terminal and the graphs will look almost the same. The following points should be kept in mind when design graphs for the printer:


Printer Setup When printing a graph to a printer, the setup of the printer is left to the user. You will need to open and use the device before calling TKGRAP (note the "H" is missing on TKGRAP - use TKGRAPH for the terminal, TKGRAP for the printer). By the same token, you will also need to close it after the graph has been printed.


Printer Types Different printers require different considerations when TK-GRAPH creates a graph for hardcopy. You will need to call TKGRAP at an entry point that defines your printer type. The current entry points are:

IBMCHAR^TKGRAP - for IBM character set
EPSON^TKGRAP - for EPSON character set
OASYS^TKGRAP - for printers using the EXPRESS PDL
ANSI^TKGRAP - for printer using ANSI

Graph Sizes Because the size of the paper may be of various sizes, you may specify the graph sizes to be of any dimension. The graph resolution will improve with the larger sizes.