하나의 차트에 여러 Y 값을 플로팅하는 데 문제가 있습니다. 다음 코드는 단일 y 값에 대해 작동하지만 동일한 csv 데이터 파일에서 여러 y 값을 그릴 수 없습니다.하나의 CSV 파일에서 여러 y 값 계산
CSV 파일 형식은 : I 차트 CSV 파일의 모든 열 (Y) 데이터 포인트 대 날짜 스탬프를 표시 얻을 수 있지만 표시되지 3
날짜 스탬프, 값 1, 값 2, 값 다른 y 값.
예, 분명히 OOP 및 winforms에 새로운 것이지만 나는 노력하고 있습니다. 내가 프로그래밍 할 당시 PDP11의 Fortran이었습니다.
어쨌든, 차트하고 버튼되는 코드의이 조각은 여기 어딘가에서하지만 나는
양식을 찾고 답을 찾을 수 없어.
귀하의 도움에 감사드립니다.
7/27
이 코드는 작동하지만 여러 Y 값을로드하는 더 좋은 방법이 있습니까?
또한 코드는 개정판에서 분리되었습니다.
데이터 테이블에로드하는 경우 데이터 테이블을 차트에 바인딩하십시오. 이것이 메모리 공간을 차지하지 않을까요?
private void button1_Click(object sender, EventArgs e)
{
// Full path to the data source file
string file = "testlog2.csv";
string path = @"g:\";
// Create a connection string.
string filepPathConnectStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
path + ";Extended Properties=\"Text;HDR=No;FMT=CSVDelimited\"";
// Create Connection Object
OleDbConnection myConnection = new OleDbConnection(filepPathConnectStr);
// Create a database command on the connection using query
string mySelectQuery = "Select * from " + file;
OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection);
// Open the connection and create the reader
myCommand.Connection.Open();
OleDbDataReader myReader = myCommand.ExecuteReader();
// Column 1 is a time value, column 2 is a double
// databind the reader to the chart using the DataBindXY method
Chart1.Series["Series1"].Points.DataBindXY(myReader, "0", myReader, "1");
//Chart1.Series["Series2"].Points.DataBindY(myReader, "3");
myReader.Close();
myConnection.Close();
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
// Full path to the data source file
string file = "testlog2.csv";
string path = @"g:\";
// Create a connection string.
string filepPathConnectStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
path + ";Extended Properties=\"Text;HDR=No;FMT=CSVDelimited\"";
// Create Connection Object
OleDbConnection myConnection = new OleDbConnection(filepPathConnectStr);
// Create a database command on the connection using query
string mySelectQuery = "Select * from " + file;
OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection);
// Open the connection and create the reader
myCommand.Connection.Open();
OleDbDataReader myReader = myCommand.ExecuteReader();
// Column 1 is a time value, column 2 is a double
// databind the reader to the chart using the DataBindY method
Chart1.Series["Series2"].Points.DataBindY(myReader, "3");
myReader.Close();
myConnection.Close();
}
}
}
안녕하세요. 시간 내 주셔서 감사합니다. 이것은 당신이 염두에두고있는 것입니다. –