home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 128 - Disc 1 / dpcs1098a.iso / Ocx / VCFIMP / VCIMPRES.Z / drill1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-11-01  |  10.5 KB  |  281 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "First Impression Drill Down Example"
  4.    ClientHeight    =   6450
  5.    ClientLeft      =   1185
  6.    ClientTop       =   1785
  7.    ClientWidth     =   9435
  8.    Height          =   7200
  9.    Icon            =   "drill1.frx":0000
  10.    Left            =   1095
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   6450
  13.    ScaleWidth      =   9435
  14.    Top             =   1125
  15.    Width           =   9615
  16.    Begin VB.Data Data1 
  17.       Caption         =   "CPU Data"
  18.       Connect         =   "Access"
  19.       DatabaseName    =   ""
  20.       Exclusive       =   0   'False
  21.       Height          =   315
  22.       Left            =   6300
  23.       Options         =   0
  24.       ReadOnly        =   0   'False
  25.       RecordsetType   =   2  'Snapshot
  26.       RecordSource    =   ""
  27.       Top             =   5760
  28.       Visible         =   0   'False
  29.       Width           =   3075
  30.    End
  31.    Begin Threed.SSPanel pnlStatus 
  32.       Align           =   2  'Align Bottom
  33.       Height          =   330
  34.       Left            =   0
  35.       TabIndex        =   1
  36.       Top             =   6120
  37.       Width           =   9435
  38.       _Version        =   65536
  39.       _ExtentX        =   16642
  40.       _ExtentY        =   582
  41.       _StockProps     =   15
  42.       Caption         =   "Ready"
  43.       BackColor       =   12632256
  44.       BorderWidth     =   1
  45.       BevelInner      =   1
  46.       Alignment       =   1
  47.    End
  48.    Begin VCIFiLib.VtChart VtChart1 
  49.       Height          =   5655
  50.       Left            =   0
  51.       TabIndex        =   0
  52.       Top             =   0
  53.       Width           =   9255
  54.       _version        =   65536
  55.       _extentx        =   16325
  56.       _extenty        =   9975
  57.       _stockprops     =   96
  58.       filename        =   "drill1.frx":030A
  59.    End
  60.    Begin VB.Menu mnuPreviousChart 
  61.       Caption         =   "&Previous Chart!"
  62.    End
  63. Attribute VB_Name = "Form1"
  64. Attribute VB_Creatable = False
  65. Attribute VB_Exposed = False
  66. Option Explicit
  67. Dim gChartLevel%, gVendor$
  68. Function ScaleToPercent#(value#, max&, min&)
  69. '' Scales a number fit in 0 to 100 range given the range of
  70. '' the number and the max and min of the range.
  71. '' Eg max = 48, min = 15, 48 becomes 100 and 15 becomes 100.
  72.    ScaleToPercent = (value - min) * 100 / (max - min)
  73. End Function
  74. Private Sub SetupTopLevelChart()
  75.    Dim rows%, cols%, i%, j%
  76.    '' Fetch the data for the first query and refresh
  77.    pnlStatus.Caption = " Fetching data..."
  78.    pnlStatus.Refresh
  79.    Data1.RecordSource = "ModelCountByVendor"
  80.       
  81.    Data1.Refresh
  82.    '' Move the data into the chart. First size the FI DataGrid to the
  83.    '' dataset. The first column goes in the first row of labels. The
  84.    '' second column is the single pie's values and indicates how many
  85.    '' CPUs are available from each Vendor
  86.    pnlStatus.Caption = " Formatting chart..."
  87.    pnlStatus.Refresh
  88.    '' Load the template chart
  89.    VtChart1.ReadFromFile App.Path & "\template\pie1.vtc"
  90.    VtChart1.AllowSelections = True
  91.    VtChart1.AllowSeriesSelection = True
  92.    cols = Data1.Recordset.RecordCount
  93.    VtChart1.RowCount = 1
  94.    VtChart1.ColumnCount = cols
  95.    For i = 1 To cols
  96.       VtChart1.Column = i
  97.       VtChart1.ColumnLabel = Data1.Recordset!vendor
  98.       VtChart1.DataGrid.SetData 1, i, Data1.Recordset!CountOfVendor, False
  99.       Data1.Recordset.MoveNext
  100.    Next i
  101.    pnlStatus.Caption = " Ready..."
  102.    gChartLevel = 1
  103. End Sub
  104. Private Sub SetupSecondLevelChart(vendor$)
  105.    Dim rows%, cols%, i%, j%, Series As Object
  106.    '' Set a global Vendor so we can easily back up from the level 3 chart
  107.    Let gVendor = vendor
  108.       
  109.    '' Fetch the data for the second query and refresh. This chart shows
  110.    '' Performance, Cycle Time and Cache by model for the specified Vendor.
  111.    '' Notice that a pair of double quotes in a string insert a double quote
  112.    '' in the variable.
  113.    pnlStatus.Caption = " Fetching data..."
  114.    pnlStatus.Refresh
  115.    Data1.RecordSource = "SELECT Model, [Relative Performance], Cache, " & _
  116.       "[Machine Cycle Time] FROM Specification WHERE Vendor = """ & vendor & _
  117.       """ ORDER BY [Relative Performance] DESC;"
  118.       
  119.    Data1.Refresh
  120.    '' Move the data into the chart. First size the FI DataGrid to the
  121.    '' dataset. The line chart is laid out like the datagrid
  122.    pnlStatus.Caption = " Formatting chart..."
  123.    pnlStatus.Refresh
  124.    '' Load the template chart first so Form Load looks better
  125.    VtChart1.ReadFromFile App.Path & "\template\line1.vtc"
  126.    '' Turn series selections off since we only want data point activations
  127.    VtChart1.AllowSelections = True
  128.    VtChart1.AllowSeriesSelection = False
  129.    rows = Data1.Recordset.RecordCount
  130.    '' Show markers if there is only one model since a line chart
  131.    '' can't draw a line between one point. This doesn't need to
  132.    '' be reset since the chart template will reset it.
  133.    If rows = 1 Then
  134.       For Each Series In VtChart1.Plot.SeriesCollection
  135.          Series.SeriesMarker.Show = True
  136.       Next Series
  137.    End If
  138.    VtChart1.Title = "Performance and Key Indicators for " & vendor & " Models"
  139.    VtChart1.RowCount = rows
  140.    VtChart1.ColumnCount = 3
  141.    With Data1.Recordset
  142.       For i = 1 To rows
  143.          VtChart1.Row = i
  144.          VtChart1.RowLabel = !model
  145.          VtChart1.DataGrid.SetData i, 1, ![Relative Performance], False
  146.          VtChart1.DataGrid.SetData i, 2, !cache, False
  147.          VtChart1.DataGrid.SetData i, 3, ![Machine Cycle Time], False
  148.          .MoveNext
  149.       Next i
  150.    End With
  151.    pnlStatus.Caption = " Ready..."
  152.    gChartLevel = 2
  153. End Sub
  154. Private Sub SetupThirdLevelChart(vendor$, model$)
  155.    Dim rp#, ep#, cache#, maxMem#, minMem#, maxChan#, minChan#, cycleTime#
  156.    '' Fetch the data for the third query and refresh. This chart shows
  157.    '' all specifications for the specified Vendor and model. These are
  158.    '' displayed in a radar chart where all stats are normalized to a 0-100
  159.    '' scale according to a max and min for a given parameter. This makes the
  160.    '' radar chart purely relative to the data set.
  161.    pnlStatus.Caption = " Fetching data..."
  162.    pnlStatus.Refresh
  163.    '' First get the stats for the selected model
  164.    Data1.RecordSource = "SELECT * FROM specification WHERE Vendor = """ & _
  165.       vendor & """ AND Model = """ & model & """;"
  166.    Data1.Refresh
  167.    With Data1.Recordset
  168.       rp = ![Relative Performance]
  169.       ep = ![Estimated Performance]
  170.       cache = !cache
  171.       cycleTime = ![Machine Cycle Time]
  172.       maxMem = ![Max Main Memory]
  173.       minMem = ![Min Main Memory]
  174.       maxChan = ![Max Channels]
  175.       minChan = ![Min Channels]
  176.    End With
  177.    '' Now get the max and min for all parameters for scaling this
  178.    '' models values
  179.    Data1.RecordSource = "ParameterMaxMin"
  180.    Data1.Refresh
  181.    With Data1.Recordset
  182.       rp = ScaleToPercent(rp, !MaxRP, !MinRP)
  183.       ep = ScaleToPercent(ep, !MaxEP, !MinEP)
  184.       maxMem = ScaleToPercent(maxMem, !MaxMaxMem, !MinMaxMem)
  185.       minMem = ScaleToPercent(minMem, !MaxMinMem, !MinMinMem)
  186.       maxChan = ScaleToPercent(maxChan, !MaxMaxChan, !MinMaxChan)
  187.       minChan = ScaleToPercent(minChan, !MaxMinChan, !MinMinChan)
  188.       cache = ScaleToPercent(cache, !MaxCache, !MinCache)
  189.       cycleTime = ScaleToPercent(cycleTime, !MaxCT, !MinCT)
  190.    End With
  191.    '' Move the data into the chart. First size the FI DataGrid to the
  192.    '' dataset. The line chart is laid out like the datagrid
  193.    pnlStatus.Caption = " Formatting chart..."
  194.    pnlStatus.Refresh
  195.    '' Load the template chart
  196.    VtChart1.ReadFromFile App.Path & "\template\radar1.vtc"
  197.    VtChart1.Title = "Normalized Performance Indicators for " & vendor & " " & model
  198.    VtChart1.AllowSelections = False
  199.    'Exit Sub
  200.    With VtChart1.DataGrid
  201.       .SetData 1, 1, rp, False
  202.       .SetData 2, 1, ep, False
  203.       .SetData 3, 1, maxMem, False
  204.       .SetData 4, 1, minMem, False
  205.       .SetData 5, 1, maxChan, False
  206.       .SetData 6, 1, minChan, False
  207.       .SetData 7, 1, cache, False
  208.       .SetData 8, 1, cycleTime, False
  209.    End With
  210.    pnlStatus.Caption = " Ready..."
  211.    gChartLevel = 3
  212. End Sub
  213. Private Sub Form_Load()
  214.    gChartLevel = 1
  215.    Data1.DatabaseName = App.Path & "\machine.mdb"
  216.    SetupTopLevelChart
  217. End Sub
  218. Private Sub Form_Resize()
  219.    '' Repaint is set to False to stop multiple
  220.    '' paints for a single resize event
  221.    With VtChart1
  222.       .Repaint = False
  223.       .Width = ScaleWidth
  224.       .Height = ScaleHeight - pnlStatus.Height
  225.       .Repaint = True
  226.    End With
  227. End Sub
  228. Private Sub mnuPreviousChart_Click()
  229.    Select Case gChartLevel
  230.       Case 2
  231.          SetupTopLevelChart
  232.       Case 3
  233.          SetupSecondLevelChart gVendor
  234.    End Select
  235. End Sub
  236. Private Sub VtChart1_AxisLabelSelected(AxisId As Integer, AxisIndex As Integer, labelSetIndex As Integer, LabelIndex As Integer, MouseFlags As Integer, Cancel As Integer)
  237.    Cancel = True
  238. End Sub
  239. Private Sub VtChart1_AxisSelected(AxisId As Integer, AxisIndex As Integer, MouseFlags As Integer, Cancel As Integer)
  240.    Cancel = True
  241. End Sub
  242. Private Sub VtChart1_AxisTitleSelected(AxisId As Integer, AxisIndex As Integer, MouseFlags As Integer, Cancel As Integer)
  243.    Cancel = True
  244. End Sub
  245. Private Sub VtChart1_ChartSelected(MouseFlags As Integer, Cancel As Integer)
  246.    Cancel = True
  247. End Sub
  248. Private Sub VtChart1_FootnoteSelected(MouseFlags As Integer, Cancel As Integer)
  249.    Cancel = True
  250. End Sub
  251. Private Sub VtChart1_LegendSelected(MouseFlags As Integer, Cancel As Integer)
  252.    Cancel = True
  253. End Sub
  254. Private Sub VtChart1_PlotSelected(MouseFlags As Integer, Cancel As Integer)
  255.    Cancel = True
  256. End Sub
  257. Private Sub VtChart1_PointActivated(Series As Integer, DataPoint As Integer, MouseFlags As Integer, Cancel As Integer)
  258.    Cancel = True
  259.    If gChartLevel = 2 Then
  260.       VtChart1.Row = DataPoint
  261.       SetupThirdLevelChart gVendor, VtChart1.RowLabel
  262.    End If
  263.       
  264. End Sub
  265. Private Sub VtChart1_PointLabelSelected(Series As Integer, DataPoint As Integer, MouseFlags As Integer, Cancel As Integer)
  266.    Cancel = True
  267. End Sub
  268. Private Sub VtChart1_SeriesActivated(Series As Integer, MouseFlags As Integer, Cancel As Integer)
  269.    Cancel = True
  270.    If gChartLevel = 1 Then
  271.       SetupSecondLevelChart VtChart1.Plot.SeriesCollection.Item(Series).SeriesLabel.Text
  272.    End If
  273.       
  274. End Sub
  275. Private Sub VtChart1_SeriesLabelSelected(Series As Integer, MouseFlags As Integer, Cancel As Integer)
  276.    Cancel = True
  277. End Sub
  278. Private Sub VtChart1_TitleSelected(MouseFlags As Integer, Cancel As Integer)
  279.    Cancel = True
  280. End Sub
  281.