home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / ch_code / appx_b / chart / grctrl.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-07-03  |  19.3 KB  |  584 lines

  1. VERSION 5.00
  2. Object = "{02B5E320-7292-11CF-93D5-0020AF99504A}#2.0#0"; "MSCHRT20.OCX"
  3. Object = "{FE0065C0-1B7B-11CF-9D53-00AA003C9CB6}#2.0#0"; "MSCOMCT2.OCX"
  4. Begin VB.Form frmGRAPHData 
  5.    Caption         =   "Chart Control - Basic Properties"
  6.    ClientHeight    =   7770
  7.    ClientLeft      =   60
  8.    ClientTop       =   345
  9.    ClientWidth     =   10560
  10.    LinkTopic       =   "Form2"
  11.    ScaleHeight     =   7770
  12.    ScaleWidth      =   10560
  13.    StartUpPosition =   3  'Windows Default
  14.    Begin MSChartLib.MSChart MSChart1 
  15.       Height          =   4770
  16.       Left            =   60
  17.       OleObjectBlob   =   "GrCtrl.frx":0000
  18.       TabIndex        =   0
  19.       Top             =   60
  20.       Width           =   10380
  21.    End
  22.    Begin VB.OptionButton ChartType 
  23.       Caption         =   "2D X-Y"
  24.       BeginProperty Font 
  25.          Name            =   "Verdana"
  26.          Size            =   9
  27.          Charset         =   0
  28.          Weight          =   400
  29.          Underline       =   0   'False
  30.          Italic          =   0   'False
  31.          Strikethrough   =   0   'False
  32.       EndProperty
  33.       Height          =   270
  34.       Index           =   16
  35.       Left            =   8445
  36.       TabIndex        =   28
  37.       Top             =   7245
  38.       Width           =   1440
  39.    End
  40.    Begin VB.OptionButton ChartType 
  41.       Caption         =   "2D Pie"
  42.       BeginProperty Font 
  43.          Name            =   "Verdana"
  44.          Size            =   9
  45.          Charset         =   0
  46.          Weight          =   400
  47.          Underline       =   0   'False
  48.          Italic          =   0   'False
  49.          Strikethrough   =   0   'False
  50.       EndProperty
  51.       Height          =   270
  52.       Index           =   14
  53.       Left            =   8445
  54.       TabIndex        =   27
  55.       Top             =   6885
  56.       Width           =   1440
  57.    End
  58.    Begin VB.OptionButton ChartType 
  59.       Caption         =   "2D Combination"
  60.       BeginProperty Font 
  61.          Name            =   "Verdana"
  62.          Size            =   9
  63.          Charset         =   0
  64.          Weight          =   400
  65.          Underline       =   0   'False
  66.          Italic          =   0   'False
  67.          Strikethrough   =   0   'False
  68.       EndProperty
  69.       Height          =   270
  70.       Index           =   9
  71.       Left            =   8445
  72.       TabIndex        =   26
  73.       Top             =   6525
  74.       Width           =   1830
  75.    End
  76.    Begin VB.OptionButton ChartType 
  77.       Caption         =   "3D Combination"
  78.       BeginProperty Font 
  79.          Name            =   "Verdana"
  80.          Size            =   9
  81.          Charset         =   0
  82.          Weight          =   400
  83.          Underline       =   0   'False
  84.          Italic          =   0   'False
  85.          Strikethrough   =   0   'False
  86.       EndProperty
  87.       Height          =   270
  88.       Index           =   8
  89.       Left            =   8445
  90.       TabIndex        =   25
  91.       Top             =   6180
  92.       Width           =   1815
  93.    End
  94.    Begin VB.OptionButton ChartType 
  95.       Caption         =   "2D Step"
  96.       BeginProperty Font 
  97.          Name            =   "Verdana"
  98.          Size            =   9
  99.          Charset         =   0
  100.          Weight          =   400
  101.          Underline       =   0   'False
  102.          Italic          =   0   'False
  103.          Strikethrough   =   0   'False
  104.       EndProperty
  105.       Height          =   270
  106.       Index           =   7
  107.       Left            =   8445
  108.       TabIndex        =   24
  109.       Top             =   5820
  110.       Width           =   1440
  111.    End
  112.    Begin VB.OptionButton ChartType 
  113.       Caption         =   "3D Step"
  114.       BeginProperty Font 
  115.          Name            =   "Verdana"
  116.          Size            =   9
  117.          Charset         =   0
  118.          Weight          =   400
  119.          Underline       =   0   'False
  120.          Italic          =   0   'False
  121.          Strikethrough   =   0   'False
  122.       EndProperty
  123.       Height          =   270
  124.       Index           =   6
  125.       Left            =   8445
  126.       TabIndex        =   23
  127.       Top             =   5460
  128.       Width           =   1440
  129.    End
  130.    Begin VB.OptionButton ChartType 
  131.       Caption         =   "2D Area"
  132.       BeginProperty Font 
  133.          Name            =   "Verdana"
  134.          Size            =   9
  135.          Charset         =   0
  136.          Weight          =   400
  137.          Underline       =   0   'False
  138.          Italic          =   0   'False
  139.          Strikethrough   =   0   'False
  140.       EndProperty
  141.       Height          =   270
  142.       Index           =   5
  143.       Left            =   6720
  144.       TabIndex        =   22
  145.       Top             =   7245
  146.       Width           =   1440
  147.    End
  148.    Begin VB.OptionButton ChartType 
  149.       Caption         =   "3D Area"
  150.       BeginProperty Font 
  151.          Name            =   "Verdana"
  152.          Size            =   9
  153.          Charset         =   0
  154.          Weight          =   400
  155.          Underline       =   0   'False
  156.          Italic          =   0   'False
  157.          Strikethrough   =   0   'False
  158.       EndProperty
  159.       Height          =   270
  160.       Index           =   4
  161.       Left            =   6720
  162.       TabIndex        =   21
  163.       Top             =   6885
  164.       Width           =   1440
  165.    End
  166.    Begin VB.OptionButton ChartType 
  167.       Caption         =   "2D Line"
  168.       BeginProperty Font 
  169.          Name            =   "Verdana"
  170.          Size            =   9
  171.          Charset         =   0
  172.          Weight          =   400
  173.          Underline       =   0   'False
  174.          Italic          =   0   'False
  175.          Strikethrough   =   0   'False
  176.       EndProperty
  177.       Height          =   270
  178.       Index           =   3
  179.       Left            =   6720
  180.       TabIndex        =   20
  181.       Top             =   6525
  182.       Width           =   1440
  183.    End
  184.    Begin VB.OptionButton ChartType 
  185.       Caption         =   "3D Line"
  186.       BeginProperty Font 
  187.          Name            =   "Verdana"
  188.          Size            =   9
  189.          Charset         =   0
  190.          Weight          =   400
  191.          Underline       =   0   'False
  192.          Italic          =   0   'False
  193.          Strikethrough   =   0   'False
  194.       EndProperty
  195.       Height          =   270
  196.       Index           =   2
  197.       Left            =   6720
  198.       TabIndex        =   19
  199.       Top             =   6180
  200.       Width           =   1440
  201.    End
  202.    Begin VB.OptionButton ChartType 
  203.       Caption         =   "2D Bar"
  204.       BeginProperty Font 
  205.          Name            =   "Verdana"
  206.          Size            =   9
  207.          Charset         =   0
  208.          Weight          =   400
  209.          Underline       =   0   'False
  210.          Italic          =   0   'False
  211.          Strikethrough   =   0   'False
  212.       EndProperty
  213.       Height          =   270
  214.       Index           =   1
  215.       Left            =   6735
  216.       TabIndex        =   18
  217.       Top             =   5820
  218.       Value           =   -1  'True
  219.       Width           =   1440
  220.    End
  221.    Begin VB.OptionButton ChartType 
  222.       Caption         =   "3D Bar"
  223.       BeginProperty Font 
  224.          Name            =   "Verdana"
  225.          Size            =   9
  226.          Charset         =   0
  227.          Weight          =   400
  228.          Underline       =   0   'False
  229.          Italic          =   0   'False
  230.          Strikethrough   =   0   'False
  231.       EndProperty
  232.       Height          =   270
  233.       Index           =   0
  234.       Left            =   6720
  235.       TabIndex        =   17
  236.       Top             =   5460
  237.       Width           =   1440
  238.    End
  239.    Begin VB.Frame Frame3 
  240.       Caption         =   "3D Chart Appearance"
  241.       BeginProperty Font 
  242.          Name            =   "Verdana"
  243.          Size            =   9.75
  244.          Charset         =   0
  245.          Weight          =   400
  246.          Underline       =   0   'False
  247.          Italic          =   0   'False
  248.          Strikethrough   =   0   'False
  249.       EndProperty
  250.       Height          =   1665
  251.       Left            =   135
  252.       TabIndex        =   8
  253.       Top             =   5955
  254.       Width           =   6195
  255.       Begin VB.CommandButton Command4 
  256.          Caption         =   "Add Light"
  257.          Enabled         =   0   'False
  258.          BeginProperty Font 
  259.             Name            =   "Verdana"
  260.             Size            =   9
  261.             Charset         =   0
  262.             Weight          =   400
  263.             Underline       =   0   'False
  264.             Italic          =   0   'False
  265.             Strikethrough   =   0   'False
  266.          EndProperty
  267.          Height          =   360
  268.          Left            =   4800
  269.          TabIndex        =   13
  270.          Top             =   1200
  271.          Width           =   1215
  272.       End
  273.       Begin VB.HScrollBar HScroll2 
  274.          Height          =   255
  275.          LargeChange     =   10
  276.          Left            =   2340
  277.          Max             =   360
  278.          TabIndex        =   12
  279.          Top             =   1305
  280.          Width           =   2235
  281.       End
  282.       Begin VB.HScrollBar HScroll1 
  283.          Height          =   255
  284.          LargeChange     =   10
  285.          Left            =   2340
  286.          Max             =   360
  287.          TabIndex        =   11
  288.          Top             =   630
  289.          Width           =   2235
  290.       End
  291.       Begin VB.CheckBox Check1 
  292.          Caption         =   "Visible Edges"
  293.          Enabled         =   0   'False
  294.          BeginProperty Font 
  295.             Name            =   "Verdana"
  296.             Size            =   9
  297.             Charset         =   0
  298.             Weight          =   400
  299.             Underline       =   0   'False
  300.             Italic          =   0   'False
  301.             Strikethrough   =   0   'False
  302.          EndProperty
  303.          Height          =   240
  304.          Left            =   210
  305.          TabIndex        =   9
  306.          Top             =   1215
  307.          Width           =   1740
  308.       End
  309.       Begin ComCtl2.UpDown UpDown1 
  310.          Height          =   330
  311.          Left            =   1800
  312.          TabIndex        =   10
  313.          Top             =   510
  314.          Width           =   240
  315.          _ExtentX        =   423
  316.          _ExtentY        =   582
  317.          _Version        =   393216
  318.          Enabled         =   0   'False
  319.       End
  320.       Begin VB.Label Label2 
  321.          Caption         =   "Rotate Horizontally"
  322.          BeginProperty Font 
  323.             Name            =   "Verdana"
  324.             Size            =   9
  325.             Charset         =   0
  326.             Weight          =   400
  327.             Underline       =   0   'False
  328.             Italic          =   0   'False
  329.             Strikethrough   =   0   'False
  330.          EndProperty
  331.          Height          =   240
  332.          Left            =   2340
  333.          TabIndex        =   16
  334.          Top             =   1080
  335.          Width           =   1845
  336.       End
  337.       Begin VB.Label Label1 
  338.          Caption         =   "Rotate Horizontally"
  339.          BeginProperty Font 
  340.             Name            =   "Verdana"
  341.             Size            =   9
  342.             Charset         =   0
  343.             Weight          =   400
  344.             Underline       =   0   'False
  345.             Italic          =   0   'False
  346.             Strikethrough   =   0   'False
  347.          EndProperty
  348.          Height          =   240
  349.          Left            =   2340
  350.          TabIndex        =   15
  351.          Top             =   390
  352.          Width           =   1845
  353.       End
  354.       Begin VB.Label Label3 
  355.          Caption         =   "Ambient Light 0"
  356.          Enabled         =   0   'False
  357.          BeginProperty Font 
  358.             Name            =   "Verdana"
  359.             Size            =   9
  360.             Charset         =   0
  361.             Weight          =   400
  362.             Underline       =   0   'False
  363.             Italic          =   0   'False
  364.             Strikethrough   =   0   'False
  365.          EndProperty
  366.          Height          =   270
  367.          Left            =   180
  368.          TabIndex        =   14
  369.          Top             =   555
  370.          Width           =   1650
  371.       End
  372.    End
  373.    Begin VB.Frame Frame2 
  374.       Caption         =   "Data Count"
  375.       BeginProperty Font 
  376.          Name            =   "Verdana"
  377.          Size            =   9.75
  378.          Charset         =   0
  379.          Weight          =   400
  380.          Underline       =   0   'False
  381.          Italic          =   0   'False
  382.          Strikethrough   =   0   'False
  383.       EndProperty
  384.       Height          =   840
  385.       Left            =   135
  386.       TabIndex        =   2
  387.       Top             =   4995
  388.       Width           =   6165
  389.       Begin VB.CheckBox Check2 
  390.          Caption         =   "Data In Rows"
  391.          BeginProperty Font 
  392.             Name            =   "Verdana"
  393.             Size            =   9
  394.             Charset         =   0
  395.             Weight          =   400
  396.             Underline       =   0   'False
  397.             Italic          =   0   'False
  398.             Strikethrough   =   0   'False
  399.          EndProperty
  400.          Height          =   240
  401.          Left            =   180
  402.          TabIndex        =   4
  403.          Top             =   375
  404.          Width           =   1680
  405.       End
  406.       Begin ComCtl2.UpDown UpDown2 
  407.          Height          =   345
  408.          Left            =   3525
  409.          TabIndex        =   3
  410.          Top             =   345
  411.          Width           =   240
  412.          _ExtentX        =   423
  413.          _ExtentY        =   609
  414.          _Version        =   393216
  415.          Value           =   12
  416.          Max             =   12
  417.          Min             =   1
  418.          Enabled         =   -1  'True
  419.       End
  420.       Begin ComCtl2.UpDown UpDown3 
  421.          Height          =   345
  422.          Left            =   5550
  423.          TabIndex        =   5
  424.          Top             =   345
  425.          Width           =   240
  426.          _ExtentX        =   423
  427.          _ExtentY        =   609
  428.          _Version        =   393216
  429.          Value           =   3
  430.          Min             =   1
  431.          Enabled         =   -1  'True
  432.       End
  433.       Begin VB.Label Label4 
  434.          Caption         =   "Rows: 12"
  435.          BeginProperty Font 
  436.             Name            =   "Verdana"
  437.             Size            =   9
  438.             Charset         =   0
  439.             Weight          =   400
  440.             Underline       =   0   'False
  441.             Italic          =   0   'False
  442.             Strikethrough   =   0   'False
  443.          EndProperty
  444.          Height          =   285
  445.          Left            =   2265
  446.          TabIndex        =   7
  447.          Top             =   375
  448.          Width           =   1215
  449.       End
  450.       Begin VB.Label Label5 
  451.          Caption         =   "Columns: 3"
  452.          BeginProperty Font 
  453.             Name            =   "Verdana"
  454.             Size            =   9
  455.             Charset         =   0
  456.             Weight          =   400
  457.             Underline       =   0   'False
  458.             Italic          =   0   'False
  459.             Strikethrough   =   0   'False
  460.          EndProperty
  461.          Height          =   285
  462.          Left            =   4275
  463.          TabIndex        =   6
  464.          Top             =   375
  465.          Width           =   1215
  466.       End
  467.    End
  468.    Begin VB.Frame Frame1 
  469.       Caption         =   "Chart Type "
  470.       BeginProperty Font 
  471.          Name            =   "Verdana"
  472.          Size            =   9.75
  473.          Charset         =   0
  474.          Weight          =   400
  475.          Underline       =   0   'False
  476.          Italic          =   0   'False
  477.          Strikethrough   =   0   'False
  478.       EndProperty
  479.       Height          =   2625
  480.       Left            =   6585
  481.       TabIndex        =   1
  482.       Top             =   4995
  483.       Width           =   3900
  484.    End
  485. Attribute VB_Name = "frmGRAPHData"
  486. Attribute VB_GlobalNameSpace = False
  487. Attribute VB_Creatable = False
  488. Attribute VB_PredeclaredId = True
  489. Attribute VB_Exposed = False
  490. '  ******************************
  491. '  ******************************
  492. '  ** MASTERING VB6            **
  493. '  ** by Evangelos Petroutos   **
  494. '  ** SYBEX, 1998              **
  495. '  ******************************
  496. '  ******************************
  497. Private Sub ChartType_Click(Index As Integer)
  498. '   Change the chart's type and enable/disable certain controls on the Form
  499. '   according to whether the chart is 2D or 3D (can't rotate 2 2D chart, for example)
  500.     If Left(ChartType(Index).Caption, 2) = "2D" Then
  501.         Label3.Enabled = False
  502.         UpDown1.Enabled = False
  503.         Check1.Enabled = False
  504.         Command4.Enabled = False
  505.     Else
  506.         Label3.Enabled = True
  507.         UpDown1.Enabled = True
  508.         Check1.Enabled = True
  509.         Command4.Enabled = True
  510.     End If
  511.     MSChart1.ChartType = Index
  512. End Sub
  513. Private Sub Check1_Click()
  514. '   Make edges visible
  515.     MSChart1.Plot.Light.EdgeIntensity = Check1.Value
  516. End Sub
  517. Private Sub Check2_Click()
  518. '   Swap the order of data sets and data points
  519. '   by setting the DataSeriesInRow property
  520. '   This will swap the labels and legends too
  521.     If Check2.Value Then
  522.         MSChart1.Plot.DataSeriesInRow = True
  523.     Else
  524.         MSChart1.Plot.DataSeriesInRow = False
  525.     End If
  526. End Sub
  527. Private Sub Command4_Click()
  528.     MSChart1.Plot.Light.LightSources(1).Set Rnd() * 10, Rnd() * 10, Rnd() * 10, Rnd()
  529. End Sub
  530. Private Sub Form_Load()
  531.     DisplayLabels
  532. End Sub
  533. Private Sub HScroll1_Change()
  534. '   Adjust the viewing angle of 3D charts
  535.     MSChart1.Plot.View3d.Set HScroll1.Value, HScroll2.Value
  536. End Sub
  537. Private Sub HScroll2_Change()
  538. '   Adjust the viewing angle of 3D charts
  539.     MSChart1.Plot.View3d.Set HScroll1.Value, HScroll2.Value
  540. End Sub
  541. Private Sub MSChart1_SeriesSelected(Series As Integer, MouseFlags As Integer, Cancel As Integer)
  542. '    redClr = MSChart1.Plot.SeriesCollection(Series).Pen.VtColor.Red
  543. '    greenClr = MSChart1.Plot.SeriesCollection(Series).Pen.VtColor.Green
  544. '    blueClr = MSChart1.Plot.SeriesCollection(Series).Pen.VtColor.Blue
  545. '    Debug.Print "The selected series color is (" & redClr & ", " & greenClr & ", " & blueClr & ")"
  546. End Sub
  547. Private Sub UpDown1_Change()
  548. '   Adjust intensity of ambient light
  549.     MSChart1.Plot.Light.EdgeVisible = True
  550.     MSChart1.Plot.Light.AmbientIntensity = UpDown1.Value / 10
  551.     If UpDown1.Value = 0 Then MSChart1.Plot.Light.EdgeVisible = False
  552.     Label3.Caption = "Ambient Light " & UpDown1.Value
  553. End Sub
  554. Private Sub UpDown2_Change()
  555. '   change number of rows
  556.     Label4.Caption = "Rows: " & UpDown2.Value
  557.     MSChart1.RowCount = UpDown2.Value
  558. ' every time the number of rows/cols is changed the labels must be redisplayed
  559.     DisplayLabels
  560. End Sub
  561. Private Sub UpDown3_Change()
  562. '   change number of columns
  563.     Label5.Caption = "Columns: " & UpDown3.Value
  564.     MSChart1.ColumnCount = UpDown3.Value
  565. ' every time the number of rows/cols is changed the labels must be redisplayed
  566.     DisplayLabels
  567. End Sub
  568. Sub DisplayLabels()
  569. '   This subroutine displays the labels of the chart
  570. '   The following loop scans all columns and
  571. '   labels them as "1998", "19919" and "2000"
  572.     For i = 1 To MSChart1.ColumnCount
  573.         MSChart1.Column = i
  574.         MSChart1.ColumnLabel = i + 1997
  575.     Next
  576. '       then scans all rows and label each data value
  577. '       with the first 3 characters of the month's name
  578. '       The control can't label more than 12 data sets
  579.     For i = 1 To MSChart1.RowCount
  580.         MSChart1.Row = i
  581.         MSChart1.RowLabel = Left(MonthName(i), 3)
  582.     Next
  583. End Sub
  584.