아래에 표시된 일부 코드는 DataGridview를 통해 루프하고 데이터를 그래프로 나타냅니다. 문제는 간격이있을 때 데이터가 올바르게 정렬되지 않는 경우입니다. 데이터를 내 DataGridview로 침투하는 여러 장치가 있고 때로는 장치가 2 개의 보고서를보고하지 않으므로 데이터에 차이가 있지만 여전히 데이터가 올바르게 정렬되기를 원합니다. 이것을 어떻게 성취합니까? 아래 차트 그림은 문제를 더 잘 설명합니다. 나는 당신이 그렇지 않으면 차트 컨트롤은 간단하게 라벨을 사용하여 날짜 문자열 값의 정확한 변환을 수행해야 MSCharts, 윈폼, C# 및 .NET 4MS Charts C# Line Chart가 틈이있는 데이터에서 정확하지 않습니다.
//for each column in my datagridview
for (int i = 0; i < currentDGV.Rows.Count; i++)
{
//for each column in each row in my datagridview
for (int j = 2; j < currentDGV.Columns.Count - 5; j++)
{
//make sure the column is visible and isnt a outlier
if (currentDGV.Columns[j].Visible == true && (bool)currentDGV.Rows[i].Cells[OUTLIER_VALUE].Value != true)
{
string deviceName = currentDGV.Rows[i].Cells[DEVICE_NAME_VALUE].Value.ToString();
string currentSize = currentDGV.Columns[j].HeaderText;
string currentTime = currentDGV.Rows[i].Cells[DATETIME_VALUE].Value.ToString();
string currentSizeValue = currentDGV.Rows[i].Cells[j].Value.ToString();
createNewSeries(deviceName + " - " + currentSize);
plotValueOnSeries(deviceName + " - " + currentSize, currentTime, currentSizeValue);
}
}
}
private void createNewSeries(String SeriesName)
{
if (tempChart != null)
{
if (tempChart.Series.IsUniqueName(SeriesName))
{
tempChart.Series.Add(SeriesName);
//tempChart.Series[SeriesName].IsXValueIndexed = true;
//tempChart.Series[SeriesName].XValueType = ChartValueType.DateTime;
}
}
}
private void plotValueOnSeries(String SeriesName, string XValue, string YValue)
{
if (tempChart != null)
{
if (radioButtonStep.Checked == true)
tempChart.Series[SeriesName].ChartType = SeriesChartType.StepLine;
else if (radioButtonSpline.Checked == true)
tempChart.Series[SeriesName].ChartType = SeriesChartType.Spline;
else if (radioButtonPoint.Checked == true)
tempChart.Series[SeriesName].ChartType = SeriesChartType.Point;
else
tempChart.Series[SeriesName].ChartType = SeriesChartType.Line;
tempChart.Series[SeriesName].Points.AddXY(XValue, YValue);
}
}
감사합니다, 나는 내가이 문제를 해결할 수있을 거라고 생각하지 않았다. ToOADate를 사용하여 트릭을 수행합니다. – Baddack