SHEET version 3.0 Manual of Graphic Part By Chor-ming Lung Date: October 31, 1989 Table of contents _________________ Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 LINE graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Draw Graph . . . . . . . . . . . . . . . . . . . . . . . . . 2 Exit Graph . . . . . . . . . . . . . . . . . . . . . . . . . 2 Reset selections . . . . . . . . . . . . . . . . . . . . . . 2 Selections . . . . . . . . . . . . . . . . . . . . . . . . . 2 Graph layout . . . . . . . . . . . . . . . . . . . . . . . . 2 Checked box . . . . . . . . . . . . . . . . . . . . . . 2 Font dialog . . . . . . . . . . . . . . . . . . . . . . 2 Snap to . . . . . . . . . . . . . . . . . . . . . . . . 3 Data variables . . . . . . . . . . . . . . . . . . . . . . . 3 Scale . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Fine tune the graph . . . . . . . . . . . . . . . . . . . . . 3 Legend . . . . . . . . . . . . . . . . . . . . . . . . . 3 Axes and Grids . . . . . . . . . . . . . . . . . . . . . 4 Labels on Xaxis . . . . . . . . . . . . . . . . . . . . 4 Chart dimension . . . . . . . . . . . . . . . . . . . . 4 White spaces on border . . . . . . . . . . . . . . . . . 5 Displacements from graph . . . . . . . . . . . . . . . . 5 Graph defaults . . . . . . . . . . . . . . . . . . . . . 5 BASIC output . . . . . . . . . . . . . . . . . . . . . . . . 5 XY graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 mouse clicks on a cell . . . . . . . . . . . . . . . . . . . 8 Bar graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Group Bars by . . . . . . . . . . . . . . . . . . . . . . . . 10 BASIC graph subroutine . . . . . . . . . . . . . . . . . . . 10 SHEET -- Graph part By Chor-ming Lung October 31, 1989 Graphics ________ Introduction: ____________ SHEET v3.0 provides menu options to generate graphs. GDOS is optional. If you want graphs drawn on paper, meta-files or on screen with GDOS screen font, you should install GDOS before using SHEET. If you intend to use SHEET with GDOS, you should read the part GDOS and SHEET and get back to here after that. ______________ I am using the hands-on approach to write this part. We will use the three graphic files -- LINEG.SHT, SINE.SHT, BAR.SHT -- as samples for describing different Graph options. Graph The Line graph example shows you how to make a graph within a few seconds. After that, it will show you how to fine tuning the graph to meet your need. Finally, it shows you how to generate BASIC graph commands and add other graph commands to refine the graph which is impossible just using the graph options. The second sample shows you how to create XY graph. We will learn some important facts from mistakes. We will also learn some new tricks to enter range automatically. The third sample shows you how to create BAR chart. BAR chart is different from XY and LINE graph too. We will also analyze the graph subroutine generated from the graph options. Currently, the graph options support Line, XY and Bar graphs only. New types will be provided in the future. G 1 SHEET -- Graph part By Chor-ming Lung October 31, 1989 LINE graph: __________ Before we do anything, I would like to show you the graph on the file LINEG.SHT. Here is the steps to generate our first Line graph: - Load LINEG.SHT to SHEET - Select the menu item Draw Graph under the menu title Graph Draw Graph Graph - Stare at the screen to see the graph being drawn - Select the menu item Exit Graph under Graph. Exit Graph Graph From the above steps, we know that Draw Graph draws the Draw Graph predefined graph instantly and Exit graph redraws the spreadsheet Exit graph on your screen. The remaining problem is: how should I setup the options to generate the Line graph? Before we get the answer, let us erase the predefined options. - Select the menu item Reset selections under menu title Graph Reset selections Graph - Select OK from the alert box. OK Reset selections resets graph options to the default states. We Reset selections will spend some time to trace what the graph options from the menu now. For the time being, we will Defaults and look at Defaults Selections first. Selections Selections: __________ If you select Selections from the menu under Graph, the Selections Graph graph selections dialog box is shown. For this moment, we just concentrate on two options -- Graph type and Graph Graph type Graph output. It is Line graph we are going to draw. So, we select output LINE in the Graph type. We want our graph drawn on screen, LINE Graph type so, we select Screen on Graph output. We ignore the rest Screen Graph output stuff and click on OK to end our graph selections. Graph layout: ____________ If you select Graph layout, the layout dialog will be shown. Graph layout For the time being, we concentrate on the graph titles only. Checked box: Checked box You should notice a box on the left hand side of each title. If you click your mouse on any one of them, you should see a checked mark toggles on and off. These checked boxes are used to tell SHEET whether you want to use the titles. If the checked box besides Chart Chart Title is on, then the contents in the two lines beneath Title it will be used as chart's titles. If no checked mark on the checked box of Chart title, SHEET will ignore the contents in the two lines. Font dialog: Font dialog - move the mouse cursor over the first edit line of Chart title - press the left button of your mouse. A dialog box shows up. It asks for the Font name, Font Font name Font size and text effects. Its defaults are Swiss, 8, size text effects Swiss 8 Normal. We change them to Swiss, 12, and outline. Normal Swiss 12, and outline Snap to: Snap to G 2 SHEET -- Graph part By Chor-ming Lung October 31, 1989 L Put the titles to the left of the graph. If it is vertical title, it is snapped to the top of the graph. C Put the titles on the center of the graph. R Put the titles on the right of the graph. If it is vertical title, it is snapped to the bottom of the graph. The options and contents of our titles are: Title Box Contents Font name Font size Effects Title Box Contents Font name Font size Effects Chart Checked Power consumption Swiss 12 Outline in 87 and 88 Swiss 8 Normal HorizontalChecked Months Dutch 12 Bold Vertical Blank Data variables: ______________ We select Data Variable A from menu title Graph and the data Data Variable A Graph variable dialog box shows up. Our first data is stored in cells B5 to B16, so we enter B5..B16 in the edit field Range. We select Marker and Spline in the Use options. Range Marker Spline Use We select Data Variable B, enter C5..C16 in Range, select Data Variable B Range Marker and Spline in the Use options, select + sign under Marker Spline Use + the Marker options. Marker Scale: _____ We select Scale from menu title Graph and the scale dialog Scale Graph box shows up. Our labels for each months are stored in cells A5 to A16. So, we enter A5..A16 in the Range field of X-axis Range X-axis label. label Draw Graph: __________ If you select Draw Graph again, you will see the same graph Draw Graph which we try before. Fine tune the graph: ___________________ Before we go further, we would like to use Line instead of Line Spline curve to speed up the graph drawing operations. Spline - Select Data Variable A from Graph Data Variable A Graph - Select Line from Use option. Line Use - Select OK OK We do the same thing to Data Variable B and select Draw Data Variable B Draw Graph to see the new graph. Is it faster? It helps us to Graph spend our time more on enhancement rather than on waiting the graph being drawn. The first enhancement to our graph is adding legend. Legend: Legend Adding legend is simple. We know our legend stores in cell B4..C4 (1987,1988). Here is the steps to add legend: - Select Selections from Graph Selections Graph G 3 SHEET -- Graph part By Chor-ming Lung October 31, 1989 - Click on the checked box besides Legend Legend - Click on Push graph to select it Push graph - Enter B4..C4 in the Range Range - Press return to end the dialog - Select Draw Graph from Graph Draw Graph Graph The option Push graph actually squeezes the graph to Push graph leave space for our legend. If you de-select it, SHEET will not count the space occupied by legend. The rest options on Legend are self-explained. Feel free to Legend choose them and redraw the graph to see the effect. It is fun time now. Axes and Grids: Axes and Grids Adding grids are simple too. - Select Scale from Graph Scale Graph - Select Minor Grid on both X-axis and Y-axis Minor Grid - Press return to end the dialog - Select Draw Graph to redraw the graph Draw Graph Minor grids are displayed as dotted lines and Major Minor grids Major grids are displayed as solid lines. Major tic is twice grids Major tic longer than Minor tic. Minor and Major control the Minor tic Minor Major placement of tic marks and grid on the axis. Axis Axis controls the placement of the placement of X/Y axis. If you de-select Auto Scale, you can change the number Auto Scale Min, Max and Axis. Otherwise, Min, Max and Axis are Min, Max Axis Min Max Axis recalculated whenever you select Scale from the menu Scale title Graph. Graph Labels on Xaxis: Labels on Xaxis The default Format for X/Y axis is Fixed number with 0 Format decimals (integer). Line graph displays labels instead of number, so Format on X-axis has no effect on line Format graph. The Font option let you select font, size, and Font styles to display the labels. Step controls the Step placement of labels. If Step is 0 or 1, SHEET will put Step labels on each minor tic. If it is 2, SHEET will put labels on the multiple of 2. That is the 2nd tic mark, 4th tic mark.... Rotation controls the orientation of Rotation the labels. If it is 0, the labels are displayed horizontally. If it is 1, the labels are displayed vertically. Chart dimension: Chart dimension SHEET assumes that your paper maximum dimension is 8"x10.5", and the CRT is 8"x5" (no matter whether it is medium or high resolution). The chart dimension is stored in the Graph Layout dialog. Let us select Layout Graph Layout Layout from menu title Graph to look at the Graph Layout Graph dialog one more time to find out the Chart dimension. Here is the result: Left: 1.00 Left Top: 0.50 Top Right: 7.00 Right Bottom: 04.50 Bottom It means we draw the graph 1 inch from the left, 1 inch G 4 SHEET -- Graph part By Chor-ming Lung October 31, 1989 from the right, 0.5 inch from top and 0.5 inch from the bottom of your screen. You can change the numbers in the chart dimension to expand or shrink the area for the graph being drawn. NOTE: SHEET uses the minimum number between 8 and the number on Right, and uses the Right minimum number between 5 (10.5 if it is printer/meta- file output) and the number on Bottom to set up the Bottom viewport. White spaces on border: White spaces on border The numbers on White spaces on border shrinks the White spaces on border actually drawable area. The area is calculated as: Actual left = Chart left + White space left Actual right = Chart right - White space right Actual Top = Chart top + White space top Actual Bottom = Chart bottom - White space bottom the actual area for the graph is: (1.1, 0.6) to (6.9, 4.4) You can change the white space numbers to suit your appetite. Displacements from graph: Displacements from graph If we have some titles, we need some spaces to separate between the titles and the graph. So, they will not be too closed together. Displacements from graph control Displacements from graph these gaps from the graph to titles. You can change them if they are not appropriate in your graph. Graph defaults: Graph defaults The Graph Defaults dialog will be displayed if you Graph Defaults select menu item Defaults from menu title Graph. If you Defaults Graph find the marker is too large or too small, you should change the number on Marker size. The number on Tick Marker Tick control the length of the tic marks. LabelP controls LabelP the placement of labels on Pie chart. LabelX controls LabelX the placement of labels on X-axis. LabelY controls the LabelY placement of labels on Y-axis. Legend controls the gap Legend between legend and the graph. Pattern List controls the Pattern List patterns being used by Bar/Pie chart. BASIC output: ____________ No matter how many options I put into SHEET, some people will still find it does not meet their unusual needs. For example, you may want to add a text string like "Typical low consumption" on April somewhere above 83 (y value). In case like this, you need to generate the BASIC commands and add this string in your graphic routine. I am going to show you how to generate BASIC graph commands. - Load LINEG.SHT to SHEET - Select Selections from Graph Selections Graph - Select the checked box beside BASIC Output align to BASIC Output align to - Make sure Screen under BASIC output align to is Screen BASIC output align to selected. Make sure the Start cell is IB1 Start cell Press return to end the dialog box. G 5 SHEET -- Graph part By Chor-ming Lung October 31, 1989 Let us move our cell cursor to IB1 to make sure it is empty. - Press F5 and enter IB1 Now, we generate the BASIC commands: - Select Draw Graph from Graph Draw Graph Graph - Select Exit Graph from Graph Exit Graph Graph The graph commands generated is a subroutine. Our main program is in cell IA1 which will call subroutine IB1. IA1 :! SAVE SCREEN IA2 :! CLS IA3 :! GOSUB IB1 IA4 :! MOUSE_POS x,y IA5 :! RESTORE SCREEN IA6 :! EXITGRAPH IA7 :! END IA1: Save current screen image IA2: Clear screen IA3: Call subroutine IB1 to draw the graph IA4: Wait for mouse click or key press. IA5: Restore the screen image IA6: Restore the clip area and redraw the window IA7: End of main program. The following steps run the program in cell IA1: - Press and hold the key - Mouse click on cell IA1 - After the graph is drawn, press the mouse button You can enter @run IA1 instead of -mouse click to @run IA1 execute program on IA1. Now, we change cell IA3 to add the string to our graph: IA3:! GOSUB IB1: PTEXT 3,83.5,"Typical low consumption",0,0,0,8,1,3 With the BASIC commands, you know that there are a lot of way to fine tune your graph. Changing parameters is one way, adding other graph commands is another way. Now, you should feel that SHEET and SHEET BASIC are the most flexible graphic tool to draw charts. G 6 SHEET -- Graph part By Chor-ming Lung October 31, 1989 XY graph: ________ Let us make our first XY graph. The data of our graph are stored on the file SINE.SHT. So, the first step is to load file SINE.SHT. We are going to use a new method to enter the data range into the data variable dialog. From the data, we know that variable A is started from cell B2, B is from C2, and independent variable from cell A2. NOTE: the steps are numbered for easy reference. 1 Move mouse cursor over cell B2 2 Press the left button on your mouse to move cell cursor to B2 3 Press the key and hold the left button a while and then release it. The block from B2..B65 is selected. 4 Select Data Variable A from menu. NOTE: Range: B2..B65 is Data Variable A Range entered automatically. 5 Select Marker and Line in Use and press Marker Line Use First of all, let me explain the different kind of mouse clicks on a cell. Mouse click on a cell move the cell cursor to that specified cell and erase any block definitions. -Mouse click define the beginning of a block. -Mouse click define the end of a block. -Mouse click run a program starting from that cell. -Mouse drag if no block is defined, the drag block defines the column range and SHEET will stop row range within contiguous rows. For example, if you start dragging from cell B1 and stops on cell C3, SHEET will stop the block within contiguous rows. A contiguous rows are rows which does not break within the column range. In this example, our block is B1..C65. Now, let us look at the steps and see what we did in each step. 1 and 2 Move cell cursor to cell B2 and de-select any block defined. 3 If we press the mouse button and hold it for a while, it signals a drag action rather than a mouse click. Since we did not move the mouse cursor, so our column range is from column B to column B. Cell B2 down to cell B65 are contiguous. So, our block defined by step 3 is B2..B65. 4 If we select a block before calling Data Variable Data Variable dialog box, the definition of the block will be stored in the Range field automatically. Range 5 We make our selection and end our dialog session. G 7 SHEET -- Graph part By Chor-ming Lung October 31, 1989 We do step 1 to step 4 again. But instead of cell B2, we work on cell C2 and Data Variable B. Data Variable B 5 Select Marker, Line and + marker. Marker Line + We do step 1 to step 3 on cell A2. 4 Select Scale from menu title Graph. The X-axis range will be Scale Graph A2..A65 and it is entered automatically. Now, let us draw our quick and dirty graph -- select Draw Draw Graph. It does not look right. What is wrong? Well, the default Graph graph type is LINE. Our graph is supposed to be XY graph. That is LINE XY why the number on our X-axis is being displayed as labels. To correct our mistake, we select Selections from Graph and click on Selections Graph XY and press . XY The graph still does not look right. The sine and cosine curves are cramped on the left hand side and the numbers on X- axis seem strange to us. It seems it is running from 0 to 63. Well, LINE graphs are treated as 2-dimension graph. Each label LINE has a value on X-axis. The first has value of 0. The second has value of 1... It means the Scale on X-axis is faulty from our Scale previous LINE graph type. Let us select Scale again and see the LINE Scale number. The number on X-axis changes to Min: 0 and Max: 7. It Min Max means whenever you see the Scale dialog, the numbers are Scale automatically rescaled. So, make a habit to select Scale before Scale Draw Graph. Draw Graph Here are the improvements I made. - Select Scale under Graph Scale Graph - De-select auto-scale from X-axis X-axis - Change -1 of Axis of X-axis to 0 Axis X-axis - De-select auto-scale from Y-axis Y-axis - Change Max of Y-axis from 1.2 to 1 Max Y-axis - Select Format from Y-axis label Format Y-axis label - From Reformat dialog, change Decimal place to 1, and Reformat dialog Decimal place choose Fixed format. Fixed - Select Draw Graph under Graph. Draw Graph Graph Does it look better? You can add titles, legend... It is you who make the decision. G 8 SHEET -- Graph part By Chor-ming Lung October 31, 1989 Bar graph: _________ The data of our bar chart example is stored in BARDEMO.SHT. The data show us the profits of the sales of 4 products in 1st and 2nd quarters. In default, SHEET groups bars by columns (more on this later). Here are the steps to create our bar graph: - Select a block of B3..C3 (drag the mouse starts from B3 and B3..C3 stops on C3). - Select Selections under Graph Selections Graph - Choose BAR as graph type BAR - Enable Legend by clicking on the checked box besides legend Legend - Press - Select a block of B4..C7 - Select Data Variable A under Graph Data Variable A Graph - Press - Select a block of A4..A7 - Select Scale under Graph Scale Graph - Press - Select Draw Graph to draw the graph. Draw Graph SHEET groups bars by columns. So, the headers of each column are used as legend and the headers of each row are used as X-axis labels. Here are the steps to group bars by rows: - Select Selections under Graph Selections Graph - Choose Row from Group Bars by Row Group Bars by You should note that the range of legend is switched with the range of X-axis labels automatically. Now, let us press the function key F10. A new bar chart is drawn. F10 does the same thing the menu item Draw Graph does except redrawing the menu Draw Graph titles. You still need to choose Exit Graph to redraw the Exit Graph spreadsheet. BASIC graph subroutine: ______________________ The file BARDEMO2.SHT has the same data as BARDEMO.SHT. The difference is that cells IA1..IA7 contain a small BASIC program which calls subroutine starting from IB1. Here are the steps to generate our graphic subroutine: - Load BARDEMO2.SHT to SHEET - Select Selections from Graph Selections Graph - Select the checked box beside BASIC Output align to BASIC Output align to - Make sure Screen under BASIC output align to is selected. Screen BASIC output align to - Make sure the Start cell is IB1 Start cell - Press return to end the dialog box. - Select Draw Graph under Graph Draw Graph Graph - Select Exit Graph under Graph Exit Graph Graph - Select Selections from Graph Selections Graph G 9 SHEET -- Graph part By Chor-ming Lung October 31, 1989 - De-select the checked box of BASIC output BASIC output Let us look at the main program first (IA1..IA7). IA1 :! SAVE SCREEN IA2 :! CLS IA3 :! GOSUB IB1 IA4 :! MOUSE_POS x,y IA5 :! RESTORE SCREEN IA6 :! EXITGRAPH IA7 :! END IA1: Save current screen image to screen buffer IA2: Clear screen IA3: Call subroutine in cell IB1 IA4: Wait for mouse button or key press event. X and Y are dummy variables. IA5: Restore screen image from screen buffer IA6: Reset the clipping area to our current window and update it. IA7: End of program. Let us look at the graph subroutine generated by SHEET (IB1..IB29). IB1 :!_vx1=1:_vy1=0.5:_vx2=7:_vy2=4.5 IB2 :!_sx1=-0.950119:_sy1=2.253521:_sx2=8.152019:_sy2=92.112676 IB3 :! VIEWPORT _vx1,_vy1,_vx2,_vy2 IB4 :! SCALE _sx1,_sy1,_sx2,_sy2 IB5 :! BOX _sx1,_sy1,_sx2,_sy2 IB6 :! LINE 0,20,8,20,3 IB7 :! LINE 0,30,8,30,3 IB8 :! LINE 0,40,8,40,3 IB9 :! LINE 0,50,8,50,3 IB10 :! LINE 0,60,8,60,3 IB11 :! LINE 0,70,8,70,3 IB12 :! LINE 0,80,8,80,3 IB13 :! MARKY 0,20,80,10 IB14 :! LINE 0,20,8,20 IB15 :! LINE 0,20,0,80 IB16 :! FONT "DUTCH",12,1 IB17 :! PTEXT -0.798416,50.272007,"Thousand of dollars",0,0,900,0,1,5 IB18 :! FONT "DUTCH",12 IB19 :! PTEXT 3.999169,85.373239,"Products' Sale in",0,0,0,0,1,3 IB20 :! FONT "SWISS",8 IB21 :! PTEXT 3.999169,82.284331,"1st & 2nd Quarters",0,0,0,0,1,3 IB22 :! FONT "SWISS",8 IB23 :! FONT "SWISS",8 IB24 :! LABELY 0,20,80,10,"F0" IB25 :! FONT "DUTCH",12 IB26 :! LEGEND 3.999169,4.5,A4..A7,1,1,0,2 IB27 :! FONT "SWISS",8 IB28 :! BAR_CHART B4..C7,0,20,8,80,0,B3..C3 IB29 :! RETURN G 10 SHEET -- Graph part By Chor-ming Lung October 31, 1989 IB1: If you want to use variable names with number, you should use underscored before the name or use at least three alphabetical characters. This line sets the viewport variables. IB2: This line sets the scale numbers. IB3: Viewport statement. NOTE: the parameters are measured in inch. IB4: This command sets up the real world scale for our data. IB5: Draw a box to frame our graphic elements. IB6~IB12: These lines draw the minor grids on Y-axis. We can change them to a FOR loop. IB13: Mark the Y-axis IB14,IB15: Draw the X & Y axes. IB16: Change the font information. The first argument of FONT is the font name. 12 is its height in point size. 1 is text style (bold face). IB17: Plot text. 900 rotates the text in 90 degree. The last two numbers control the alignment of the text. 1 controls the horizontal alignment (center). 5 controls the vertical alignment (top line). IB18: Change font to "Dutch". Note: the text style argument in FONT is optional. If it is not provided, it is supposed to be 0 (no special style). IB19: Plot text. IB20: Change font information. IB21: Plot text. IB22: A redundant statement. IB23: Change font information for Y-axis labels. IB24: Add labels from 20 to 80 by increment of 10. The labels use fixed number with no decimal point. It means integer. IB25: Change font information for Legend. IB26: Add the legend. IB27: Change font information for Bar Chart statement IB28: Bar chart drawing command IB29: Return back to caller. G 11