home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l391_1 / 2.ddi / PGLINEMS.BA$ / PGLINEMS.bin
Encoding:
Text File  |  1992-08-19  |  4.3 KB  |  126 lines

  1. ' ------------------------------------------------------------------------
  2. ' Visual Basic for MS-DOS Presentation Graphics Toolkit
  3. ' Multi-data Series Line Chart Example
  4. '
  5. ' The Presentation Graphics Toolkit must be loaded to run
  6. ' this example (VBDOS /L CHART).
  7. '
  8. ' Copyright (C) 1982-1992 Microsoft Corporation
  9. '
  10. ' You have a royalty-free right to use, modify, reproduce
  11. ' and distribute the sample applications and toolkits provided with
  12. ' Visual Basic for MS-DOS (and/or any modified version)
  13. ' in any way you find useful, provided that you agree that
  14. ' Microsoft has no warranty, obligations or liability for
  15. ' any of the sample applications or toolkits.
  16. ' ------------------------------------------------------------------------
  17.  
  18. DEFINT A-Z
  19.  
  20. ' Include files containing declarations for called procedures.
  21. ' $INCLUDE: 'CHART.BI'
  22.  
  23. DECLARE FUNCTION BestMode ()
  24.  
  25. CONST HIGHESTMODE = 13
  26.  
  27. DIM Env AS ChartEnvironment           ' Variable to hold environment structure
  28. DIM AxisLabels(1 TO 4) AS STRING      ' Array of categories
  29. DIM LegendLabels(1 TO 2) AS STRING    ' Array of series labels
  30. DIM Values(1 TO 4, 1 TO 3) AS SINGLE  ' 2-dimentsion array of values to plot
  31.  
  32. DIM Col%(0 TO cPalLen)          ' Define arrays to hold values retrieved with
  33. DIM Lines%(0 TO cPalLen)        ' call to GetPaletteDef. By modifying these
  34. DIM Fill$(0 TO cPalLen)         ' values, then calling ResetPaletteDef, you
  35. DIM Char%(0 TO cPalLen)         ' can change colors, plot characters, borders,
  36. DIM Bord%(0 TO cPalLen)         ' and even the line styles and fill patterns
  37.  
  38. ' Read the data to display into the arrays
  39. FOR index = 1 TO 2: READ LegendLabels(index): NEXT index
  40. FOR index = 1 TO 4: READ AxisLabels(index): NEXT index
  41.  
  42. FOR columnindex = 1 TO 2                ' The array has 2 columns, each of
  43.   FOR rowindex = 1 TO 4                 ' which has 4 rows. Each column rep-
  44.     READ Values(rowindex, columnindex)  ' resents 1 full data series. First,
  45.   NEXT rowindex                         ' fill column 1, then fill column 2
  46. NEXT columnindex                        ' with values from the last DATA
  47.                                         ' statement (below).
  48. CLS
  49.  
  50. ' Pass the value returned by the BestMode function to the Presentation
  51. ' Graphics routine ChartScreen to set the graphics mode for charting
  52. ChartScreen (BestMode)      ' Even if SCREEN is already set to an acceptable
  53.                             ' mode, you still have to set it with ChartScreen
  54.  
  55. ' Retrieve current palette settings, then assign some new values
  56. GetPaletteDef Col%(), Lines%(), Fill$(), Char%(), Bord%()
  57. Col%(2) = (15)          '  Assign white as color for second-series plot line
  58. Char%(1) = (4)          '  Assign  "" as plot character for 1st plot line
  59. Char%(2) = (18)         '  Assign  "" as plot character for 2nd plot line
  60.  
  61. ' Reset the palettes with modified arrays
  62. SetPaletteDef Col%(), Lines%(), Fill$(), Char%(), Bord%()   ' Enter the changes
  63.  
  64. ' Set up multi-series line chart
  65. DefaultChart Env, cLine, cLines
  66.  
  67. ' Display the chart
  68. ChartMS Env, AxisLabels(), Values(), 4, 1, 2, LegendLabels()
  69.  
  70. SLEEP
  71.           
  72. END
  73.  
  74. ' Simulated data to be shown on chart
  75. DATA "First Quarter","Second Quarter"
  76. DATA "Administrative","Marketing","Production","Development"
  77. DATA 38,30,40,32,18,40,20,12
  78.  
  79. ' Best graphics screenmode retrieval routine.
  80. '
  81. ' Determines the best graphics screenmode available
  82. ' for displaying the chart.
  83. '
  84. FUNCTION BestMode ()
  85.  
  86. ' Set error trap for determining supported screenmodes.
  87. ON LOCAL ERROR GOTO ScreenError
  88.  
  89. FOR TestValue = HIGHESTMODE TO 0 STEP -1
  90.     DisplayError = FALSE
  91.     SCREEN TestValue
  92.     IF DisplayError = FALSE THEN
  93.         SELECT CASE TestValue
  94.             CASE 12, 13
  95.                 BestMode = 12
  96.             CASE 9, 10, 11
  97.                 BestMode = 9
  98.             CASE 8, 4, 3
  99.                 BestMode = TestValue
  100.             CASE 2, 7
  101.                 BestMode = 2
  102.             CASE 1
  103.                 BestMode = 1
  104.             CASE ELSE
  105.                 PRINT "Graphics screenmode required to display charts."
  106.                 END
  107.         END SELECT
  108.         EXIT FUNCTION
  109.     END IF
  110. NEXT TestValue
  111.  
  112.  
  113. EXIT FUNCTION
  114.  
  115. ' Screenmode error trap
  116. ' Handles invalid SCREEN values.
  117. ScreenError:
  118.     IF ERR = 5 THEN
  119.         DisplayError = TRUE
  120.         RESUME NEXT
  121.     ELSE
  122.         ERROR ERR
  123.     END IF
  124. END FUNCTION
  125.  
  126.