foreach(DataRow row in dtRpt.Rows)
{
// For each Row add a new series
string seriesName = row["vchCompetency"].ToString();
chart.Series.Add(seriesName);
chart.Series[seriesName].ChartType = SeriesChartType.Line;
chart.Series[seriesName].BorderWidth = 2;
for (int colIndex = 4; colIndex < dtRpt.Columns.Count; colIndex++)
{
// For each column (column 1 and onward) add the value as a point
string columnName = dtRpt.Columns[colIndex].ColumnName;
float YVal = (float)row[columnName];
chart.Series[seriesName].Points.AddXY(columnName, YVal);
}
}
数据表:
vchCompetency vchSubject intKidUserID intGradeID Average KiaAverage
Animals EVS 172 3 98.8695652173913 97.8260869565217
Animals EVS 173 3 98.8695652173913 99.9130434782609
Animals EVS 172 4 86.6891891891892 86.4864864864865
Animals EVS 173 4 86.6891891891892 86.8918918918919
Animals EVS 172 5 16.5179060071445 16.4184005492701
Animals EVS 173 5 16.5179060071445 16.6174114650189
Animals EVS 172 6 69.1805555555555 64.4444444444444
Animals EVS 173 6 69.1805555555555 73.9166666666667
Animals EVS 172 7 98.9130434782609 97.8260869565217
Animals EVS 173 7 98.9130434782609 100
创建图表,提供错误添加代码。任何人都可以帮我解决
答案 0 :(得分:2)
将float转换为适当的格式:
float YVal=float.Parse(row[columnName].ToString(), CultureInfo.InvariantCulture.NumberFormat);