在Web应用程序中显示ASP.NET图表

问题描述:

我创建了一个显示ASP.NET图表的网页。我没有遇到任何错误,但我仍然无法在网页上看到图表。



我使用的代码是:



I have created a webpage to display ASP.NET charts. I am not facing any errors but still I am not able to see the Chart on webpage.

The code I am using is:

<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Web.UI.DataVisualization" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Web.UI.DataVisualization.Charting" %>
<%@ Page Language="C#" %>
<%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
<script  runat="server">

</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head  runat="server">
    <title>Charts-Dashboards</title>
</head>
<body>
    <form id="form1"  runat="server">
    <div>
     	 <asp:Chart ID="Chart1" runat="server" ImageLocation="~/TempImages/ChartPic_#SEQ(300,3)" Height="400px" Width="450px" >
         <Series>
          <asp:Series Name="Series1" ChartType="Pie" YValuesPerPoint="2" >
                    <Points>
                        <asp:DataPoint AxisLabel="4 letter" YValues="20,0" />
                        <asp:DataPoint AxisLabel="5 letter" YValues="10,0" />
                        <asp:DataPoint AxisLabel="6 letter" YValues="5,0" />
                        <asp:DataPoint AxisLabel="7 letter" YValues="16,0" />
                    </Points>  
           </asp:Series>
         </Series>
         <ChartAreas>
           <asp:ChartArea Name="ChartArea1"  >
           </asp:ChartArea>
         </ChartAreas>
  </asp:Chart> 
    </div>
    
    </form>
</body>
</html>





我还在web.config文件中添加了以下内容。如何使图表显示在页面上。我使用的是.NET Framework 4和ASP.NET 4.0。





I have also added the following to web.config file. How to make charts to be displayed on the page. I am using .NET Framework 4 and ASP.NET 4.0.

<appSettings>
     <add key="ChartImageHandler" value="storage=memory;timeout=30;" /> 
</appSettings>

<system.webServer>
    <handlers accessPolicy="Read, Script">
    <remove name="ChartImageHandler" />
    <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST"

        path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler,
        System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</handlers>
</system.webServer>