0
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

创建图表给出错误添加代码。谁能帮我解决

4

1 回答 1

2

将浮点数转换为正确的格式:

float YVal=float.Parse(row[columnName].ToString(), CultureInfo.InvariantCulture.NumberFormat);
于 2014-04-04T06:05:12.530 回答