创建asp:Chart时出错
本文关键字:出错 Chart asp 创建 | 更新日期: 2023-09-27 18:19:35
我正在尝试创建具有2个系列和2个ChartArea的Chart。我有以下代码:
protected void DisplayData()
{
var surveyResult = SurveyResult.ListSurveyResult(this.SurveyID);
for (int i = 0; i < surveyResult.Count; i++)
{
Series series = new Series();
series.Name = i.ToString();
series.ChartArea = "ChartArea" + i.ToString();
series.ChartType = SeriesChartType.Pie;
DataPoint point = new DataPoint();
point.SetValueY(Convert.ToInt32(surveyResult[i].Person_Count));
point.AxisLabel = surveyResult[i].Answer;
series.Points.Add(point);
ChartArea chartArea = new ChartArea();
chartArea.Name = "ChartArea" + i.ToString();
Chart1.ChartAreas.Add(chartArea);
Chart1.Series.Add(series);
}
Chart1.DataBind();
}
我收到"执行ChartImg.axd的子请求时出错。"错误。我也试着加入
<add key="ChartImageHandler" value="storage=file;timeout=20;" />
在web.config文件中,但没有成功。有人知道这个问题是怎么回事吗?
在网上进一步搜索后,我发现我应该添加以下代码:
<add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
到web.config文件。