ProfileYData

 

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

ProfileYData uses an array (rows) of double.  The number of rows is Profile(index).NumSamples.  

Two common methods to populate the ProfileYData array are:

  1. Set ProfileYData equal to an array
  2. Read data from a CSV text file into an array, and then set ProfileYData equal to the array

 

Example 1: Set ProfileYData equal to an array

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

arrData(1) = 0
arrData(2) = -0.1
arrData(3) = -0.2
arrData(4) = -0.3
arrData(5) = -0.4

arrData2(1) = 10
arrData2(2) = 20
arrData2(3) = 22
arrData2(4) = 33.5
arrData2(5) = 51
arrData2(6) = 65
arrData2(7) = 66
arrData2(8) = 68
arrData2(9) = 75

With XYChartCtl1
    .NumProfiles = 2

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

 

Example 2: Read data from a CSV text file into an array, and then set ProfileYData 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
     ReDim DataArray(1 To .Profile(1).NumSamples)


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

     Close #iFileNumber

 

     .ProfileYData(1) = DataArray

 

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

 

End With

See Also

Properties    ProfileClass     ChartData     ProfileData     ProfileXData