Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
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
HTML
<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
Comments
StianSandberg 16-Aug-12 8:36am    
http://forums.asp.net/t/1434652.aspx/1

This is my code and is working fine
C#
<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
C#
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.
 
Share this answer
 
v2
Comments
Mac12334 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?????
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

XML
<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[^]
 
Share this answer
 
v4
Comments
Mac12334 16-Aug-12 9:21am    
I have added above handler with that i have to add these handler ???
Anuja Pawar Indore 16-Aug-12 9:27am    
Yes under system.webserver add handlers
Mac12334 16-Aug-12 9:44am    
is permissions check is required???
Anuja Pawar Indore 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
Mac12334 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.
 
Share this answer
 

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