home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a044 / 3.ddi / MISC / GRAPHS.PRG < prev    next >
Encoding:
Text File  |  1993-08-31  |  2.9 KB  |  118 lines

  1. *GRAPHS.PRG
  2.  
  3. erase
  4.  
  5. chkevent()
  6.  
  7. @ 24,0
  8.  
  9. declare ttle[10]
  10. declare nums[10]
  11. declare num2[10]
  12. declare lbl[2]
  13. declare pies[5]
  14. declare pilbl[5]
  15.  
  16.  
  17. *This first bit of code creates some dummy data for the three graph types.
  18. *Normally, you would use FILL ARRAY to extract the data from a real 
  19. *data base.
  20. *
  21. *Create dummy data for the PIE chart
  22.  
  23. store 1 to count
  24. do while count <= 5
  25.   pies[count] = count
  26.   pilbl[count] = 'Sect '+str(count,1)
  27.   inc count
  28. enddo
  29.  
  30. lbl[1] = 'Actual'
  31. lbl[2] = 'Projected'
  32. store 1 to count
  33. mdate = {01/15/89}
  34.  
  35. *Create dummy data for bar and line graphs.
  36. *The bar and line graphs will have ten elements
  37.  
  38. do while count <= 10
  39.   *dummy numbers for both line and bar graph
  40.   nums[count] = count * 11.25
  41.   *dummy numbers for line graph
  42.   num2[count] = nums[count] + 50
  43.   *Titles for both bar and line graph
  44.   ttle[count] = substr(cmonth(mdate),1,3)
  45.   inc count
  46.   mdate = mdate + 30
  47. enddo
  48.  
  49. *Set picture frame sets the bounding rectangle in which the
  50. *graph is drawn.  If there is no set picture frame command
  51. *active, the entire window is used.
  52. set picture frame to 5,10,21,70
  53.  
  54. *Here is a BAR GRAPH
  55. *Syntax is 
  56. *draw bargraph [HORIZONTAL <expC>] [VERTICAL <expC>] arrayN, arrayC
  57.  
  58. draw bargraph horizontal 'Months' vertical "Sales" nums,ttle
  59. @ 0,0
  60. set message to 'Press any key or click the mouse to continue'
  61. wait ' '
  62.  
  63. erase
  64. @ 22,0
  65.  
  66. *Here is a PIE CHART.
  67. *Syntax is 
  68. *draw piechart [HORIZONTAL <expC>] [VERTICAL <expC>] arrayN, arrayC
  69.  
  70. draw piechart horizontal 'Months' pies, pilbl
  71. set message to 'Press any key or click the mouse to continue'
  72. wait ' '
  73. erase
  74. @ 22,0
  75.  
  76. *This next graph is a LINE graph
  77. *Syntax for line graph is
  78. *draw graph [HORIZONTAL <expC>] [VERTICAL <expC>] arrayN[,arrayN2 ...arrayN10]
  79. *      , arrayLable, arrayTitle
  80. *There should be one element in array label for each of arrayN - arrayN10
  81. *Each of arrayN1 through arrayN10 is a line of data points.  In this case
  82. *we have two, nums and num2
  83.  
  84. set picture frame to 5,5,21,75
  85. draw graph horizontal 'Months' vertical "Sales" nums,num2,ttle,lbl
  86.  
  87. wait 'About to draw on the printer. Click the close box to not print the graph.'
  88.  
  89.  
  90. *Set the frame to the entire window
  91. set picture frame to 
  92.  
  93.  
  94. set device to printer
  95. set printer to graphics
  96.  
  97. *Note that set picture frame issued AFTER set printer to graphics
  98. *A FRAME created a SCREEN device is not used for the PRINTER device.
  99.  
  100. set picture frame to 5,10,21,70 
  101.  
  102. draw bargraph horizontal 'Months' vertical "Sales" nums,ttle
  103. eject       |Required to get the spooler to spit out a page
  104.  
  105. draw piechart horizontal 'Months' pies, pilbl
  106. eject
  107.  
  108. draw graph horizontal 'Months' vertical "Sales" nums,num2,ttle,lbl
  109. eject
  110.  
  111. set device to screen   |Don't leave the device to printer
  112. set printer to 1       |And turn the spooler off
  113.  
  114. *Reset the frame to the entire window
  115. set picture frame to 
  116.  
  117.  
  118.