XY Chart NET 3 Control Reference
ProfileData Property

Use this property to return/set the x & y data point values for a specific Profile.

Syntax
[Visual Basic]
Property ProfileData(ProfileIndex As Integer) As Object
[C#]
object XYChartNETCtl.get_ProfileData(int ProfileIndex)
void   XYChartNETCtl.set_ProfileData(int ProfileIndex, object Value)
[C++]
property System::Object ^ XYChartNet::XYChartNETCtl::ProfileData[int]
       
Parameters
ProfileIndex
The index of the profile to set/get the x & y data point values of.  Valid values are 0..(NumProfiles - 1).
Remarks

ProfileData is a two-dimensional array (Number of Rows - 1, Number of Columns - 1) of double.  The number of rows is Profile(idx).NumSamples, where idx is the profile index to set/get the x & y values for.  The number of columns is 2, one to store the x-data and one to store the y-data.

Initially, all data values are 0.  Two common methods to populate the ProfileData array are:

  1. Set ProfileData equal to a two-dimensional array.
  2. Read data from a CSV text file into a two-dimensional array, and then set ProfileData equal to the array.
Example 1: Set ProfileData equal to an array
' XYChartNETCtl1 is the name of the XY Chart NET control instance placed on the form.

Dim arrData(4, 1) As Double
Dim arrData2(8, 1) As Double
Dim objDataArray As Object

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

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

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

'Get each profile datapoints
objDataArray = XYChartNETCtl1.ProfileData(0)
objDataArray = XYChartNETCtl1.ProfileData(1)
// XYChartNETCtl1 is the name of the XY Chart NET control instance placed on the form.

double [,] arrData = new double [5, 2];
double [,] arrData2 = new double [7, 2];
object     objDataArray;

arrData[0, 0] = 0;
arrData[0, 1] = 0;
arrData[1, 0] = -10;
arrData[1, 1] = -10;
arrData[2, 0] = -20;
arrData[2, 1] = -20;
arrData[3, 0] = -30;
arrData[3, 1] = -30;
arrData[4, 0] = -40;
arrData[4, 1] = -40;

arrData2[0, 0] = 0;
arrData2[0, 1] = 0;
arrData2[1, 0] = -20;
arrData2[1, 1] = -10;
arrData2[2, 0] = -40;
arrData2[2, 1] = -50;
arrData2[3, 0] = -50;
arrData2[3, 1] = -60;
arrData2[4, 0] = -70;
arrData2[4, 1] = -80;
arrData2[5, 0] = 10;
arrData2[5, 1] = 0;
arrData2[6, 0] = 0;
arrData2[6, 1] = 10;

XYChartNETCtl1.NumProfiles = 2;
XYChartNETCtl1.get_Profile(0).NumSamples = 5;  //5 xy data points for Profile 0
XYChartNETCtl1.get_Profile(1).NumSamples = 7;  //7 xy data points for Profile 1
XYChartNETCtl1.set_ProfileData(0, arrData);
XYChartNETCtl1.set_ProfileData(1, arrData2);
XYChartNETCtl1.Refresh();                      //Refresh required to re-generate graph with new values

//Get each profile datapoints
objDataArray = XYChartNETCtl1.get_ProfileData(0);
objDataArray = XYChartNETCtl1.get_ProfileData(1);
// XYChartNETCtl1 is the name of the XY Chart NET control instance placed on the form.

double          arrData __gc[,] = new double __gc[5, 2];
double          arrData2 __gc[,] = new double __gc[7, 2];
System::Object* objDataArray;

arrData[0, 0] = 0;
arrData[0, 1] = 0;
arrData[1, 0] = -10;
arrData[1, 1] = -10;
arrData[2, 0] = -20;
arrData[2, 1] = -20;
arrData[3, 0] = -30;
arrData[3, 1] = -30;
arrData[4, 0] = -40;
arrData[4, 1] = -40;

arrData2[0, 0] = 0;
arrData2[0, 1] = 0;
arrData2[1, 0] = -20;
arrData2[1, 1] = -10;
arrData2[2, 0] = -40;
arrData2[2, 1] = -50;
arrData2[3, 0] = -50;
arrData2[3, 1] = -60;
arrData2[4, 0] = -70;
arrData2[4, 1] = -80;
arrData2[5, 0] = 10;
arrData2[5, 1] = 0;
arrData2[6, 0] = 0;
arrData2[6, 1] = 10;
           
XYChartNETCtl1->NumProfiles = 2;
XYChartNETCtl1->Profile[0]->NumSamples = 5;  //5 xy data points for Profile 0
XYChartNETCtl1->Profile[1]->NumSamples = 7;  //7 xy data points for Profile 1                                                                                                                                       
XYChartNETCtl1->set_ProfileData(0, arrData);
XYChartNETCtl1->set_ProfileData(1, arrData2);
XYChartNETCtl1->Refresh();                   //Refresh required to re-generate graph with new values

//Get each profile datapoints
objDataArray = XYChartNETCtl1->get_ProfileData(0);
objDataArray = XYChartNETCtl1->get_ProfileData(1);
Example 2: Read data from a CSV text file into an array, and then set ProfileData equal to the array
' XYChartNETCtl1 is the name of the XY Chart NET control instance placed on the form.

Dim FilePathAndName As String
Dim iFileNumber As Integer
Dim Row As Integer, Col As Integer
Dim DataArray(,) As Double

'Filepath below assumes source file is in the same folder as the application
FilePathAndName = App.Path + "\" + CSVFileName
iFileNumber = FreeFile()
Microsoft.VisualBasic.FileOpen(iFileNumber, FilePathAndName, OpenMode.Input)

With XYChartNETCtl1
   .NumProfiles = 1
   .Profile(0).NumSamples = 5   '5 xy data points for Profile 0

   ReDim DataArray(.Profile(0).NumSamples - 1, 1)

   For Row = 0 To .Profile(0).NumSamples - 1
      For Col = 0 To 1
         Microsoft.VisualBasic.Input(FileNumber, DataArray(Row, Col))
      Next Col
   Next Row

   .ProfileData(0) = DataArray
   .Refresh                     'Refresh required to re-generate graph with new values
End With
Microsoft.VisualBasic.FileClose(iFileNumber)
// XYChartNETCtl1 is the name of the XY Chart NET control instance placed on the form.

const int myNumSamples = 8;
const int myXYSet = 2;

System.IO.StreamReader sr;
string                 input;
string []              inputSplit;
string                 delimiterString = ",";
char []                delimiter = delimiterString.ToCharArray();
int                    Row = 0;
int                    Col;
double [,]             DataArray = new double [myNumSamples, myXYSet];

//Filepath below assumes source file is in the same folder as the application
sr = System.IO.File.OpenText(".\\ProfileData.csv");

//Populate the data array
while (((input=sr.ReadLine())!= null) && (Row < myNumSamples))
{
    inputSplit = input.Split (delimiter, myXYSet);
    for (Col = 0; Col < myXYSet; Col++)
    {
        DataArray[Row, Col] = Double.Parse(inputSplit[Col]);
    }
    Row++;
}
sr.Close();

XYChartNETCtl1.NumProfiles = 1;
XYChartNETCtl1.get_Profile(0).NumSamples = myNumSamples;
XYChartNETCtl1.set_ProfileData(0, DataArray);
XYChartNETCtl1.Refresh();
// XYChartNETCtl1 is the name of the XY Chart NET control instance placed on the form.

const int myNumSamples = 8;
const int myXYSet = 2;

System::IO::StreamReader* sr;
String*                   input;
String*                   inputSplit[];
String*                   delimiterString = S",";
Char                      delimiter[] = delimiterString->ToCharArray();
int                       Row = 0;
int                       Col;
double                    DataArray __gc[,] = new double __gc[myNumSamples, myXYSet];

//Filepath below assumes source file is in the same folder as the application
sr = System::IO::File::OpenText(".\\ProfileData.csv");

//Populate the data array
while (((input = sr->ReadLine())!= 0) && (Row < myNumSamples))
{
    inputSplit = input->Split (delimiter, myXYSet);
    for (Col = 0; Col < myXYSet; Col++)
    {
        DataArray[Row, Col] = Double::Parse(inputSplit[Col]);
    }
    Row++;
}
sr->Close();

XYChartNETCtl1->NumProfiles = 1;
XYChartNETCtl1->Profile[0]->NumSamples = myNumSamples;
XYChartNETCtl1->ProfileData[0] = DataArray;
XYChartNETCtl1->Refresh();
See Also

 

 


© 2003 - 2013 ControlEng Corporation. All rights reserved.