Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:

ASP.NET
<%@ 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>


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.

HTML
<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>
Posted
Updated 23-May-14 1:53am
v2
Comments
manvendra patel 24-May-14 2:00am    
try this link-http://www.dotnetfox.com/articles/bind-Asp-Net-chart-control-from-database-using-C-Sharp-1056.aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900