ASP.Net MS图表:缺少图像
我正试图让我的第一张MS图表出现——只是一条简单的线。但是,当我单击debug(VS2010)时,我得到的只是网页上缺少的一个图像图标(无论浏览器如何)。该图表已从MS图表示例中复制 我的第一个想法是MS Chart没有正确安装,但是在调试示例环境时,所有示例都工作得很好。只是我自己的测试页面无法呈现图像 我哪里做错了 以下是web.config文件:ASP.Net MS图表:缺少图像,asp.net,c#-4.0,mschart,Asp.net,C# 4.0,Mschart,我正试图让我的第一张MS图表出现——只是一条简单的线。但是,当我单击debug(VS2010)时,我得到的只是网页上缺少的一个图像图标(无论浏览器如何)。该图表已从MS图表示例中复制 我的第一个想法是MS Chart没有正确安装,但是在调试示例环境时,所有示例都工作得很好。只是我自己的测试页面无法呈现图像 我哪里做错了 以下是web.config文件: <?xml version="1.0"?> <!-- For more information on how to con
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
</appSettings>
<system.webServer>
<handlers>
<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>
<system.web>
<httpHandlers>
<add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
validate="false" />
</httpHandlers>
<roleManager enabled="true"/>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
<pages theme="xxx">
<controls>
<add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting"
assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</controls>
</pages>
</configuration>
以下是页面代码:
<asp:chart id="chart1" runat="server" imagetype="Png" BackColor="WhiteSmoke" BorderWidth="2" BackGradientStyle="TopBottom" BackSecondaryColor="White" Palette="BrightPastel" BorderDashStyle="Solid" BorderColor="26, 59, 105" Height="296px" Width="412px">
<titles>
<asp:title ShadowColor="32, 0, 0, 0" Font="Trebuchet MS, 12pt, style=Bold" ShadowOffset="3" Text="Two series with 20000 points each." ForeColor="26, 59, 105">
</asp:title>
</titles>
<legends>
<asp:legend Enabled="False" IsTextAutoFit="False" Name="Default" BackColor="Transparent" Font="Trebuchet MS, 8.25pt, style=Bold"></asp:legend>
</legends>
<borderskin skinstyle="Emboss"></borderskin>
<series>
<asp:series Name="Series1" ChartType="FastLine" ShadowColor="Black" BorderColor="180, 26, 59, 105"></asp:series>
<asp:series Name="Series2" ChartType="FastLine" ShadowColor="Black" BorderColor="180, 26, 59, 105" Color="224, 64, 10"></asp:series>
</series>
<chartareas>
<asp:chartarea Name="ChartArea1" BorderColor="64, 64, 64, 64" BorderDashStyle="Solid" BackSecondaryColor="White" BackColor="Gainsboro" ShadowColor="Transparent" BackGradientStyle="TopBottom">
<area3dstyle Rotation="10" perspective="10" Inclination="15" IsRightAngleAxes="False" wallwidth="0" IsClustered="False"></area3dstyle>
<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" IsLabelAutoFit="False">
<labelstyle font="Trebuchet MS, 8.25pt, style=Bold" />
<majorgrid linecolor="64, 64, 64, 64" />
</axisx>
</asp:chartarea>
</chartareas>
</asp:chart>
代码隐藏:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.DataVisualization.Charting;
using System.Drawing;
public partial class reporting : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
double yValue = 50.0;
Random random = new Random();
for (int pointIndex = 0; pointIndex < 20000; pointIndex++)
{
yValue = yValue + (random.NextDouble() * 10.0 - 5.0);
chart1.Series["Series1"].Points.AddY(yValue);
}
chart1.Series["Series1"].ChartType = SeriesChartType.FastLine;
}
}
使用系统;
使用System.Collections.Generic;
使用System.Web;
使用System.Web.UI;
使用System.Web.UI.WebControl;
使用System.Web.UI.DataVisualization.Charting;
使用系统图;
公共部分类报告:System.Web.UI.Page
{
受保护的无效页面加载(对象发送方、事件参数e)
{
双Y值=50.0;
随机=新随机();
对于(int pointIndex=0;pointIndex<20000;pointIndex++)
{
yValue=yValue+(random.NextDouble()*10.0-5.0);
图表1.系列[“系列1”].点数.添加(Y值);
}
chart1.系列[“系列1”]。ChartType=系列ChartType.FastLine;
}
}
新年快乐 上次我使用MS Chart时,我必须为web配置中的图像提供一个物理路径。否则我只会得到一个破碎的图像。除了创建c:\tempimages文件夹并设置此值外,其他选项都无法始终工作
此外,请确保该计算机的IIS用户具有写入文件夹的权限。通过IIS而不是windows资源管理器授予权限 您必须提供一个文件夹,并授予IIS用户访问该文件夹的权限。需要访问的用户因Windows和IIS版本而异,因此您必须进行检查