XY Chart NET 3 Control Reference > Properties > ChartData Property |
Use this property to return/set x & y data point values for all Profiles.
[Visual Basic] Property ChartData() As Object |
[C#] object XYChartNETCtl.ChartData |
[C++] property System::Object ^ XYChartNet::XYChartNETCtl::ChartData |
ChartData is a two-dimensional array (Number of Rows - 1, Number of Columns - 1) of double. The number of rows is the profile with the maximum NumSamples. The number of columns is 2 x NumProfiles.
Initially, all data values are 0. Two common methods to populate the ChartData array are:
' XYChartNETCtl1 is the name of the XY Chart NET control instance placed on the form. Dim arrData(4, 7) As Double Dim objDataArray As Object 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 arrData(0, 2) = 0 arrData(0, 3) = 0 arrData(1, 2) = -20 arrData(1, 3) = -10 arrData(2, 2) = -40 arrData(2, 3) = -50 arrData(3, 2) = -50 arrData(3, 3) = -60 arrData(4, 2) = -70 arrData(4, 3) = -80 arrData(0, 4) = 10 arrData(0, 5) = 0 arrData(1, 4) = 0 arrData(1, 5) = 10 arrData(2, 4) = 20 arrData(2, 5) = 20 arrData(3, 4) = 10 arrData(3, 5) = 10 arrData(4, 4) = 30 arrData(4, 5) = 30 arrData(0, 6) = 0 arrData(0, 7) = 10 arrData(1, 6) = 10 arrData(1, 7) = 50 arrData(2, 6) = 50 arrData(2, 7) = 30 arrData(3, 6) = 30 arrData(3, 7) = 80 arrData(4, 6) = 80 arrData(4, 7) = 70 With XYChartNETCtl1 .NumProfiles = 4 '4 profiles to plot .Profile(0).NumSamples = 5 '5 xy data points for Profile 0 .Profile(1).NumSamples = 5 '5 xy data points for Profile 1 .Profile(2).NumSamples = 5 '5 xy data points for Profile 2 .Profile(3).NumSamples = 5 '5 xy data points for Profile 3 .ChartData = arrData .Refresh 'Refresh required to re-generate graph with new values End With 'Get all datapoints objDataArray = XYChartNETCtl1.ChartData
// XYChartNETCtl1 is the name of the XY Chart NET control instance placed on the form. double [,] arrData = new double [5, 8]; 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; arrData[0, 2] = 0; arrData[0, 3] = 0; arrData[1, 2] = -20; arrData[1, 3] = -10; arrData[2, 2] = -40; arrData[2, 3] = -50; arrData[3, 2] = -50; arrData[3, 3] = -60; arrData[4, 2] = -70; arrData[4, 3] = -80; arrData[0, 4] = 10; arrData[0, 5] = 0; arrData[1, 4] = 0; arrData[1, 5] = 10; arrData[2, 4] = 20; arrData[2, 5] = 20; arrData[3, 4] = 10; arrData[3, 5] = 10; arrData[4, 4] = 30; arrData[4, 5] = 30; arrData[0, 6] = 0; arrData[0, 7] = 10; arrData[1, 6] = 10; arrData[1, 7] = 50; arrData[2, 6] = 50; arrData[2, 7] = 30; arrData[3, 6] = 30; arrData[3, 7] = 80; arrData[4, 6] = 80; arrData[4, 7] = 70; XYChartNETCtl1.NumProfiles = 4; //4 profiles to plot XYChartNETCtl1.get_Profile(0).NumSamples = 5; //5 xy data points for Profile 0 XYChartNETCtl1.get_Profile(1).NumSamples = 5; //5 xy data points for Profile 1 XYChartNETCtl1.get_Profile(2).NumSamples = 5; //5 xy data points for Profile 2 XYChartNETCtl1.get_Profile(3).NumSamples = 5; //5 xy data points for Profile 3 XYChartNETCtl1.ChartData = arrData; XYChartNETCtl1.Refresh(); //Refresh required to re-generate graph with new values //Get all datapoints objDataArray = XYChartNETCtl1.ChartData;
// XYChartNETCtl1 is the name of the XY Chart NET control instance placed on the form. double arrData __gc[,] = new double __gc[5, 8]; 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; arrData[0, 2] = 0; arrData[0, 3] = 0; arrData[1, 2] = -20; arrData[1, 3] = -10; arrData[2, 2] = -40; arrData[2, 3] = -50; arrData[3, 2] = -50; arrData[3, 3] = -60; arrData[4, 2] = -70; arrData[4, 3] = -80; arrData[0, 4] = 10; arrData[0, 5] = 0; arrData[1, 4] = 0; arrData[1, 5] = 10; arrData[2, 4] = 20; arrData[2, 5] = 20; arrData[3, 4] = 10; arrData[3, 5] = 10; arrData[4, 4] = 30; arrData[4, 5] = 30; arrData[0, 6] = 0; arrData[0, 7] = 10; arrData[1, 6] = 10; arrData[1, 7] = 50; arrData[2, 6] = 50; arrData[2, 7] = 30; arrData[3, 6] = 30; arrData[3, 7] = 80; arrData[4, 6] = 80; arrData[4, 7] = 70; XYChartNETCtl1->NumProfiles = 4; //4 profiles to plot XYChartNETCtl1->Profile[0]->NumSamples = 5; //5 xy data points for Profile 0 XYChartNETCtl1->Profile[1]->NumSamples = 5; //5 xy data points for Profile 1 XYChartNETCtl1->Profile[2]->NumSamples = 5; //5 xy data points for Profile 2 XYChartNETCtl1->Profile[3]->NumSamples = 5; //5 xy data points for Profile 3 XYChartNETCtl1->ChartData = arrData; XYChartNETCtl1->Refresh(); //Refresh required to re-generate graph with new values //Get all datapoints objDataArray = XYChartNETCtl1->ChartData;
' 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 = ".\" + CSVFileName iFileNumber = FreeFile() Microsoft.VisualBasic.FileOpen(iFileNumber, FilePathAndName, OpenMode.Input) With XYChartNETCtl1 .NumProfiles = 5 .Profile(0).NumSamples = 5 '5 xy data points for Profile 0 .Profile(1).NumSamples = 8 '8 xy data points for Profile 1 .Profile(2).NumSamples = 5 '5 xy data points for Profile 2 .Profile(3).NumSamples = 4 '4 xy data points for Profile 3 .Profile(4).NumSamples = 4 '4 xy data points for Profile 4 'Re-dimension the data array; Profile 1 has the maximum number of samples ReDim DataArray(.Profile(1).NumSamples - 1, 2 * .NumProfiles - 1) 'Populate the data array. The CSV file must contain 8 x & y data values for each profile. 'Dummy values are used for those profiles not requiring 8 samples. For Row = 0 To .Profile(1).NumSamples - 1 For Col = 0 To 2 * .NumProfiles - 1 Microsoft.VisualBasic.Input(FileNumber, DataArray(Row, Col)) Next Col Next Row .ChartData = 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 = 10; 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(".\\ChartData.csv"); //Populate the data array. The CSV file must contain 8 x & y data values for each profile. 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 = 5; XYChartNETCtl1.get_Profile(0).NumSamples = 5; //5 xy data points for Profile 0 XYChartNETCtl1.get_Profile(1).NumSamples = 8; //8 xy data points for Profile 1 XYChartNETCtl1.get_Profile(2).NumSamples = 5; //5 xy data points for Profile 2 XYChartNETCtl1.get_Profile(3).NumSamples = 4; //4 xy data points for Profile 3 XYChartNETCtl1.get_Profile(4).NumSamples = 4; //4 xy data points for Profile 4 XYChartNETCtl1.ChartData = 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 = 10; 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]; int myFontStyle = (int)Drawing::FontStyle::Bold | (int)Drawing::FontStyle::Italic; Drawing::Font* myFont = new Drawing::Font("Arial", 16, (Drawing::FontStyle)myFontStyle); //Filepath below assumes source file is in the same folder as the application sr = System::IO::File::OpenText(".\\Chart Data.csv"); //Populate the data array. The CSV file must contain 8 x & y data values for each profile. 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 = 5; XYChartNETCtl1->Profile[0]->NumSamples = 5; //5 xy data points for Profile 0 XYChartNETCtl1->Profile[1]->NumSamples = 8; //8 xy data points for Profile 1 XYChartNETCtl1->Profile[2]->NumSamples = 5; //5 xy data points for Profile 2 XYChartNETCtl1->Profile[3]->NumSamples = 4; //4 xy data points for Profile 3 XYChartNETCtl1->Profile[4]->NumSamples = 4; //4 xy data points for Profile 4 XYChartNETCtl1->ChartData = DataArray; XYChartNETCtl1->Refresh();