ProfileData

 

Use this property to set x/y data point values for a specific Profile.  Specify the profile number in the parameter list, that is, ProfileData(index), where index is the profile number to set the x/y values for. 

ProfileData uses an array (rows, columns) of double.  The number of rows is Profile(index).NumSamples.  The number of columns is 2.  

Three common methods to populate the ProfileData array are:

  1. Set ProfileData equal to a named range in an Excel file
  2. Set ProfileData equal to an array
  3. Read data from a CSV text file into an array, and then set ProfileData equal to the array

NOTE:   For all methods, the source data must be of proper dimension specified by:
                    a) Rows = Profile(index).NumSamples, where index is the profile number to set the x/y values for  
                    b) Columns = 2

 

Example 1: Set ProfileData equal to a named range in an Excel file

'wb is the name of an Excel workbook object

'Data1 is a Defined Name in the Excel file of same dimension as ProfileData(1)

XYChartCtl1.ProfileData(1) = wb.Names("Data1").RefersToRange.Value

XYChartCtl1.Refresh         'Refresh required to re-generate graph with new values

 

 

Example 2: Set ProfileData equal to an array

Dim arrData(1 To 5, 1 To 2) As Double
Dim arrData2(1 To 9, 1 To 2) As Double

arrData(1, 1) = 0
arrData(1, 2) = 0
arrData(2, 1) = -0.1
arrData(2, 2) = -0.105
arrData(3, 1) = -0.2
arrData(3, 2) = -0.222
arrData(4, 1) = -0.3
arrData(4, 2) = -0.356
arrData(5, 1) = -0.4
arrData(5, 2) = -0.435

arrData2(1, 1) = 10
arrData2(1, 2) = 10
arrData2(2, 1) = 20
arrData2(2, 2) = 34
arrData2(3, 1) = 22
arrData2(3, 2) = 46
arrData2(4, 1) = 33.5
arrData2(4, 2) = 46.5
arrData2(5, 1) = 51
arrData2(5, 2) = 53
arrData2(6, 1) = 65
arrData2(6, 2) = 54
arrData2(7, 1) = 66
arrData2(7, 2) = 59
arrData2(8, 1) = 68
arrData2(8, 2) = 62.6
arrData2(9, 1) = 75
arrData2(9, 2) = 89

With XYChartCtl1
    .NumProfiles = 2

    .Profile(1).NumSamples = 5   '5 xy data points for Profile 1
    .Profile(2).NumSamples = 9   '9 xy data points for Profile 2
    .ProfileData(1) = arrData
    .ProfileData(2) = arrData2
    .Refresh 'Refresh required to re-generate graph with new values
End With 

 

Example 3: Read data from a CSV text file into an array, and then set ProfileData equal to the array

 

' Read data from a CSV file and populate DataArray
Dim FilePathAndName As String

' NOTE: File path below assumes source file is in the same folder as the application
FilePathAndName = App.Path + "\" + FileName

Dim iFileNumber As Integer
iFileNumber = FreeFile

Open FilePathAndName For Input As #iFileNumber


With XYChartCtl1

     .Profile(1).NumSamples = 5
     Dim Row As Integer, Col As Integer
     ReDim DataArray(1 To .Profile(1).NumSamples, 1 To 2)
     For Row = 1 To .Profile(1).NumSamples
          For Col = 1 To 2
               Input #iFileNumber, DataArray(Row, Col)
          Next Col
     Next Row

     Close #iFileNumber

 

     .ProfileData(1) = DataArray

 

     .Refresh 'Refresh required to re-generate graph with new values

 

End With

See Also

Properties    ProfileClass     ChartData     ProfileXData     ProfileYData