DataGrid Object Example

The following example sets the chart parameters for a three-dimensional bar chart, fills the chart with random data and labels the data grid columns.

Option Explicit
Option Base 1

Private Sub Command1_Click()
   Dim rowLabelCount, columnLabelCount, rowCount As Integer
   Dim columnCount, labelIndex, Column, Row As Integer
   MSChart1.ChartType = VtChChartType3dBar
   With MSChart1.DataGrid
   ' Set Chart parameters using methods.
      rowLabelCount = 2
      columnLabelCount = 2
      rowCount = 6
      columnCount = 6
      .SetSize RowLabelCount, columnLabelCount, _
      RowCount, ColumnCount
      ' Randomly fill in the data.
      .RandomDataFill
      ' Then assign labels to second Level.
      labelIndex = 2
      column = 1
      .ColumnLabel(column, labelIndex) = "Product 1"
      column = 4
      .ColumnLabel(column, labelIndex) = "Product 2"
      row = 1
      .RowLabel(row, labelIndex) = "1994"
      row = 4
      .RowLabel(row, labelIndex) = "1995"
   End With
End Sub