Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET Chart
Hi all
 
I am trying to use chart control in asp.net 3.5
 
I installed MSChart.exe and implemented the chart control.
In Local it is showing image but in Server it is not showing image every time.
Means:After Uploaded the code to the server the images are showing sometime.
 
In a page i have used two chart control.Some time it is showing image of 1st Chart control and sometime others.
 
It is showing error IMAGE NOT FOUND.
 
In the Web.Config file i have added
<add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
<add key="ChartImageHandler" value="Storage=file;Timeout=60;Url=~/tempImages/;"/>
Please help to solve this problem.
 
Thanks in advance.
Posted 16-Aug-12 2:28am
Mac123341.1K
Comments
AlluvialDeposit at 16-Aug-12 8:36am
   
http://forums.asp.net/t/1434652.aspx/1
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Add under handlers web.config:
 <handlers>
 <remove name="ChartImageHandler" />
 <add name="ChartImageHandler" precondition="integratedMode" verb="GET,HEAD">
       path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</add>
 
also check permissions
 
<location path="ChartImg.axd">
   <system.web>
     <authorization>
       <allow users="*"/>
     </authorization>
   </system.web>
 </location>
Edit after question
Refer this link
http://asifhuddani.wordpress.com/2010/10/07/chart-control-asp-net-4-0-and-iis-7-problem/[^]
 
More link for reference
I suggest refer this thread too
http://codecorner.galanter.net/2010/04/26/asp-net-chart-control-is-not-rendering-image/[^]
http://stackoverflow.com/questions/7933830/asp-net-charting-control-not-working-on-production-server[^]
  Permalink  
v4
Comments
MAC123456 at 16-Aug-12 9:21am
   
I have added above handler with that i have to add these handler ???
Anuja Pawar Indore at 16-Aug-12 9:27am
   
Yes under system.webserver add handlers
MAC123456 at 16-Aug-12 9:44am
   
is permissions check is required???
Anuja Pawar Indore at 16-Aug-12 9:47am
   
If your page is only accessed by logged in user's or may be your folder access problem. Check both
MAC123456 at 16-Aug-12 9:59am
   
I am doing in local and its working fine.
I will inform you if it will not show any error in server.
 
Thanks for immediate reply.
Thanks a ton.
MAC123456 at 16-Aug-12 10:09am
   
Hi Anuja
Can you share why it is not showing the image???
MAC123456 at 16-Aug-12 10:11am
   
Can you please share the full description why not the images are not showing and why after use that one it is showing ???
MAC123456 at 17-Aug-12 1:22am
   
It is not working in server again .
 
These codes are already written in the server code.
MAC123456 at 17-Aug-12 1:23am
   
Please improve your solution.
Anuja Pawar Indore at 17-Aug-12 1:27am
   
MAC its permission issue, pls check ur folder and path permission. May be server path generating is wrong.
MAC123456 at 17-Aug-12 2:05am
   
I am not using MAC.
How to Solve the server path generating.
My problem:
I have made an User Control in which i have used two Chart Controls.
In Chrome and FireFox the images are coming Sometime.But in IE it is showing two images.
In Chrome and FireFox Sometime one image is showing and sometime nothing is showing means NO IMAGE FOUND.
Please solve this
Anuja Pawar Indore at 17-Aug-12 4:14am
   
Added some more references, if still having problem then share your code
MAC123456 at 17-Aug-12 7:19am
   
My Code: ASPX Page
 
<%@ Register Assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
<p>
<asp:Chart ID="chartLeadAssociation" runat="server" Width="1000px" ImageLocation="~/TempImages/ChartPic_#SEQ(300,3)">

<asp:Series Name="seriesLeadAssociation" XValueMember="LEADER_NAME" XValueType="String"
YValueMembers="START_DATE, END_DATE" YValueType="DateTime" ChartType="RangeBar">
<Points>
</Points>



<asp:ChartArea Name="chartAreaLeadAssociation">



<LabelStyle Angle="-90" />




<asp:Chart ID="chartProjectAssociation" runat="server" Width="1000px" ImageLocation="~/TempImages/Chart1Pic_#SEQ(300,3)">

<asp:Series Name="seriesProjectAssociation" XValueMember="PROJECT_NAME" XValueType="String"
YValueMembers="START_DATE, END_DATE" YValueType="DateTime" ChartType="RangeBar" Color="Orange">
<Points>
</Points>



<asp:ChartArea Name="chartAreaProjectAssociation">



<LabelStyle Angle="-90" />




<asp:Label ID="lblError" runat="server">
</p>
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

This is my code and is working fine
<asp:Chart ID="chartColumn" runat="server" BackColor="WhiteSmoke" BackSecondaryColor="White"BackGradientStyle="TopBottom" BorderDashStyle="Solid" Palette="BrightPastel"
BorderColor="26, 59, 105" Height="460px" Width="530px" BorderWidth="2" ImageLocation="~/TempImages/ChartPic_#SEQ(300,3)">
<Legends><asp:Legend Name="Default" BackColor="Transparent" Font="Trebuchet MS, 8pt, style=Bold"
AutoFitMinFontSize="6" Docking="Top" LegendStyle="Table" ForeColor="Red"> </asp:Legend>
 </Legends><BorderSkin SkinStyle="Emboss"></BorderSkin> <Series> </Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1" BorderColor="64, 64, 64, 64" BorderDashStyle="Solid" BackSecondaryColor="White" BackColor="Gainsboro" ShadowColor="Transparent" BackGradientStyle="TopBottom">
 <Position Height="85" Width="90" X="4" Y="5" />
<AxisY LineColor="64, 64, 64, 64" IsLabelAutoFit="False"><LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" />
<MajorGrid LineColor="64, 64, 64, 64" />
</AxisY>
<AxisX LineColor="64, 64, 64, 64">
<LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" IntervalType="Auto" /><MajorGrid Interval="Auto" IntervalType="Auto" LineColor="64, 64, 64, 64" />
<MajorTickMark IntervalType="Auto" />
</AxisX>
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
Method code behind
public void FillChart(int DId)
    {
        // Set legend docking i.e position of the legends
        chartColumn.Legends["Default"].Docking = Docking.Bottom;
        // Set legend alignment
        chartColumn.Legends["Default"].Alignment = System.Drawing.StringAlignment.Center;
        // Set legend style Column / Row / Table
        chartColumn.Legends["Default"].LegendStyle = LegendStyle.Table;
        PID = Convert.ToInt32(ViewState["PatId"].ToString());
        CmsIdentity objIdentity = (CmsIdentity)Context.User.Identity;
        DataSet dsChart = new DataSet();
        clsPatientEPRResultsDb objResultDb = new clsPatientEPRResultsDb();
        
           dsChart = objResultDb.GetTestResultForChart(DId, PID, objIdentity.AccountInfoID, "");
          
        
        if (dsChart.Tables[0].Rows.Count > 0)
        {
            chartColumn.Visible = true;
            DataView dv = dsChart.Tables[0].DefaultView;
            seriesname = "Result";
            chartColumn.Series.Add(seriesname);
            chartColumn.Series[seriesname].ChartArea = "ChartArea1";
            chartColumn.Series[sername].ChartType =   SeriesChartType.Column;
            chartColumn.Series[sername].Palette = ChartColorPalette.BrightPastel;
            chartColumn.Series[seriesname].Name = seriesname;
            chartColumn.Series[seriesname].Color = System.Drawing.Color.Red;
            chartColumn.Series[seriesname].IsValueShownAsLabel = true;
            chartColumn.Series[seriesname].Points.DataBindXY(dv, "ResultDate1", dv, "Result");
            string CharPic = Server.MapPath("TempPDF/") + "Result(" + DateTime.Now.ToString("ddMMMyyyyhhmmss") + ").jpeg";
            chartColumn.SaveImage(CharPic, ChartImageFormat.Jpeg);
            chartColumn.Series[seriesname].Points.DataBindXY(dv, "ResultDate1", dv, "Result");
        } 
            
        
    }
Please see if this solves your problem, as i cannot see any problem in your code.
  Permalink  
v2
Comments
MAC123456 at 20-Aug-12 3:44am
   
Actually i am using two chart control in a page.
Is that showing problem??
I have to do this using two Chart Control?????

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



Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 17 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100