home *** CD-ROM | disk | FTP | other *** search
- ' ------------------------------------------------------------------------
- ' Visual Basic for MS-DOS Presentation Graphics Toolkit
- ' Multi-data Series Line Chart Example
- '
- ' The Presentation Graphics Toolkit must be loaded to run
- ' this example (VBDOS /L CHART).
- '
- ' Copyright (C) 1982-1992 Microsoft Corporation
- '
- ' You have a royalty-free right to use, modify, reproduce
- ' and distribute the sample applications and toolkits provided with
- ' Visual Basic for MS-DOS (and/or any modified version)
- ' in any way you find useful, provided that you agree that
- ' Microsoft has no warranty, obligations or liability for
- ' any of the sample applications or toolkits.
- ' ------------------------------------------------------------------------
-
- DEFINT A-Z
-
- ' Include files containing declarations for called procedures.
- ' $INCLUDE: 'CHART.BI'
-
- DECLARE FUNCTION BestMode ()
-
- CONST HIGHESTMODE = 13
-
- DIM Env AS ChartEnvironment ' Variable to hold environment structure
- DIM AxisLabels(1 TO 4) AS STRING ' Array of categories
- DIM LegendLabels(1 TO 2) AS STRING ' Array of series labels
- DIM Values(1 TO 4, 1 TO 3) AS SINGLE ' 2-dimentsion array of values to plot
-
- DIM Col%(0 TO cPalLen) ' Define arrays to hold values retrieved with
- DIM Lines%(0 TO cPalLen) ' call to GetPaletteDef. By modifying these
- DIM Fill$(0 TO cPalLen) ' values, then calling ResetPaletteDef, you
- DIM Char%(0 TO cPalLen) ' can change colors, plot characters, borders,
- DIM Bord%(0 TO cPalLen) ' and even the line styles and fill patterns
-
- ' Read the data to display into the arrays
- FOR index = 1 TO 2: READ LegendLabels(index): NEXT index
- FOR index = 1 TO 4: READ AxisLabels(index): NEXT index
-
- FOR columnindex = 1 TO 2 ' The array has 2 columns, each of
- FOR rowindex = 1 TO 4 ' which has 4 rows. Each column rep-
- READ Values(rowindex, columnindex) ' resents 1 full data series. First,
- NEXT rowindex ' fill column 1, then fill column 2
- NEXT columnindex ' with values from the last DATA
- ' statement (below).
- CLS
-
- ' Pass the value returned by the BestMode function to the Presentation
- ' Graphics routine ChartScreen to set the graphics mode for charting
- ChartScreen (BestMode) ' Even if SCREEN is already set to an acceptable
- ' mode, you still have to set it with ChartScreen
-
- ' Retrieve current palette settings, then assign some new values
- GetPaletteDef Col%(), Lines%(), Fill$(), Char%(), Bord%()
- Col%(2) = (15) ' Assign white as color for second-series plot line
- Char%(1) = (4) ' Assign "" as plot character for 1st plot line
- Char%(2) = (18) ' Assign "" as plot character for 2nd plot line
-
- ' Reset the palettes with modified arrays
- SetPaletteDef Col%(), Lines%(), Fill$(), Char%(), Bord%() ' Enter the changes
-
- ' Set up multi-series line chart
- DefaultChart Env, cLine, cLines
-
- ' Display the chart
- ChartMS Env, AxisLabels(), Values(), 4, 1, 2, LegendLabels()
-
- SLEEP
-
- END
-
- ' Simulated data to be shown on chart
- DATA "First Quarter","Second Quarter"
- DATA "Administrative","Marketing","Production","Development"
- DATA 38,30,40,32,18,40,20,12
-
- ' Best graphics screenmode retrieval routine.
- '
- ' Determines the best graphics screenmode available
- ' for displaying the chart.
- '
- FUNCTION BestMode ()
-
- ' Set error trap for determining supported screenmodes.
- ON LOCAL ERROR GOTO ScreenError
-
- FOR TestValue = HIGHESTMODE TO 0 STEP -1
- DisplayError = FALSE
- SCREEN TestValue
- IF DisplayError = FALSE THEN
- SELECT CASE TestValue
- CASE 12, 13
- BestMode = 12
- CASE 9, 10, 11
- BestMode = 9
- CASE 8, 4, 3
- BestMode = TestValue
- CASE 2, 7
- BestMode = 2
- CASE 1
- BestMode = 1
- CASE ELSE
- PRINT "Graphics screenmode required to display charts."
- END
- END SELECT
- EXIT FUNCTION
- END IF
- NEXT TestValue
-
-
- EXIT FUNCTION
-
- ' Screenmode error trap
- ' Handles invalid SCREEN values.
- ScreenError:
- IF ERR = 5 THEN
- DisplayError = TRUE
- RESUME NEXT
- ELSE
- ERROR ERR
- END IF
- END FUNCTION
-
-