图表控制问题 [英] Chart control problem

查看:99
本文介绍了图表控制问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我正在尝试在asp.net 3.5中使用图表控件
我安装了MSChart.exe并实现了图表控件.
在本地中,它显示图像,但是在服务器中,它每次都不显示图像.
意思是:将代码上传到服务器后,图像有时会显示出来.

在一个页面中,我使用了两个图表控件.有时它显示第一个图表控件的图像,有时则显示其他图像.

显示错误IMAGE NOT FOUND.

在Web.Config文件中,我添加了

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.

推荐答案

http://www .dotnetcurry.com/ShowArticle.aspx?ID = 238 [ ^ ]


http://forums.asp.net/t/1434652.aspx/1 [ ^ ]

检查上面的链接以获取您的解决方案
http://www.dotnetcurry.com/ShowArticle.aspx?ID=238[^]


http://forums.asp.net/t/1434652.aspx/1[^]

check the above links to get your solution


在处理程序web.config下添加:
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>


在问题后进行编辑
请参阅此链接
http://asifhuddani.wordpress .com/2010/10/07/chart-control-asp-net-4-0-and-iis-7-problem/ [ 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 [


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[^]


这是我的代码,可以正常工作
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.


这篇关于图表控制问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆