Asp.net + Google Charts - 附加的html文件无法正确打开

时间:2009-07-21 21:23:57

标签: asp.net html google-visualization

我有一个包含一个网格和一个图像的Asp.Net页面。该图片是谷歌图表,其网址约为1600个字符。我一起出了一个包含网格和图像的.htm文件。对于网格,我使用RenderControl获取其html代码,对于图像,我只需添加一个img html标记并将url分配给它的src。然后我将此.htm文件作为电子邮件附件发送。

我的问题是,当您尝试打开附件时,除了图像外,您看到一切正常(它没有显示任何内容,当您查看页面的源代码时,img标签不会显示任何内容src无论如何 - 它只显示< img>(没有空格)。如果在将文件保存到磁盘后打开文件,那么一切正常,你会看到实际的img src。为什么???

这是我的html标题:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><META http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>

这是图像:

<img src="http://chart.apis.google.com/chart?chd=t:0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,420.95,0.00,2725.25,0.00,0.00,0.00,0.00,5036.96,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,47.82|0.0000,7.97,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,4.98,1.99,2.24,0.00,0.00,0.00,0.00,0.00,0.00,0.00,1.99,1.99|0.5100,34.04,0.00,0.00,0.00,0.00,0.00,0.00,1.00,0.00,0.00,0.00,0.00,0.00,0.00,36.77,18.01,18.26,0.00,0.00,0.00,0.00,0.00,8.99,0.00,20.06,14.01|0,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,2.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,4.00|3.0000,0.00,0.00,0.00,0.00,0.00,0.00,0.00,46.98,0.00,257.91,113.25,0.00,0.00,0.00,1.00,24.99,29.99,0.00,0.00,0.00,0.00,0.00,0.00,0.00,60.00,123.92|0,0.00,0.00,0.00,0.00,0.00,0.00,0.00,45.00,0.00,0.00,0.00,0.00,0.00,0.00,20.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,84.00|0,55.99,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,65.99&chdl=Type 1|Type 2|Type 3|Type 4|Type 5|Type 6|Type 7&chco=000000,CD7F32,A62A2A,0000FF,00FF00,FF6EC7,A8A8A8&chds=0,5037&chxl=0:|6/22|6/23|6/24|6/25|6/26|6/27|6/28|6/29|6/30|7/1|7/2|7/3|7/4|7/5|7/6|7/7|7/8|7/9|7/10|7/11|7/12|7/13|7/14|7/15|7/16|7/17|7/18|1:|0|503|1006|1509|2012|2515|3018|3521|4024|4527|5037|2:|Days|3:|Amount ($)&chls=3,1,0|3,1,0|3,1,0|3,1,0|3,1,0|3,1,0|3,1,0&chm=o,990066,0,-1,6.0|o,990066,1,-1,6.0|o,990066,2,-1,6.0|o,990066,3,-1,6.0|o,990066,4,-1,6.0|o,990066,5,-1,6.0|o,990066,6,-1,6.0&chg=3.85,0&cht=lc&chs=900x300&chxt=x,y,r,t"/>

如果问题是网址的大小,那么我的选择是什么,没有构建pdf文件并附加它?似乎我只需要一个html文件,我想保持简单。

2 个答案:

答案 0 :(得分:1)

你肯定会看到长URL问题。当我使用谷歌图表API(虽然在Rails而不是ASP.NET)时,这发生在我身上。我从来没有找到开始造成麻烦的确切URL大小,但有些人报告从1024开始遇到麻烦。

Google提供了几种不同的编码类型,您可以在输入数据上使用它来缩小它,但使用除文本编码之外的任何内容(您正在做的事情)将会禁用扩展数据的能力,如果您愿意的话。

如果无法缩放数据,如果数据在长时间段内保持最大值,或者如果要覆盖两个不同比例的图形,则可能会出现一些难看的图形。

请参阅Google Chart API文档中的data formats

答案 1 :(得分:0)

如果GET太长,你可以使用POST而不是16k的限制,这已经足够了。我已经使用下面的代码来生成您的图表并且它有效。所以是的,我猜你可以使用帖子并将其附加到电子邮件中。使用GET的问题可能是配置为不打开图像文件的电子邮件客户端的问题,您是否已在其他客户端中对其进行测试?

<form action='http://chart.apis.google.com/chart' method='POST' id='post_form'>
<input type="hidden" name="cht" value="lc"  />
<input type="hidden" name="chtt" value="Demo chart"  />
<input type="hidden" name="chg" value="3.85,0" />
<input type='hidden' name='chs' value='900x300' />
<input type="hidden" name="chxt" value="x,y,r,t" />
<input type="hidden" name="chds" value="0,5037" />
<input type="hidden" name="chxl" value="0:|6/22|6/23|6/24|6/25|6/26|6/27|6/28|6/29|6/30|7/1|7/2|7/3|7/4|7/5|7/6|7/7|7/8|7/9|7/10|7/11|7/12|7/13|7/14|7/15|7/16|7/17|7/18|1:|0|503|1006|1509|2012|2515|3018|3521|4024|4527|5037|2:|Days|3:|Amount ($)" />
<input type="hidden" name="chls" value="3,1,0|3,1,0|3,1,0|3,1,0|3,1,0|3,1,0|3,1,0" />
<input type="hidden" name="chm" value="o,990066,0,-1,6.0|o,990066,1,-1,6.0|o,990066,2,-1,6.0|o,990066,3,-1,6.0|o,990066,4,-1,6.0|o,990066,5,-1,6.0|o,990066,6,-1,6.0" />
<input type="hidden" name="chco" value="000000,CD7F32,A62A2A,0000FF,00FF00,FF6EC7,A8A8A8" />
<input type="hidden" name="chdl" value="Type 1|Type 2|Type 3|Type 4|Type 5|Type 6|Type 7" />
<input type='hidden' name='chd' value='t:0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,420.95,0.00,2725.25,0.00,0.00,0.00,0.00,5036.96,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,47.82|0.0000,7.97,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,4.98,1.99,2.24,0.00,0.00,0.00,0.00,0.00,0.00,0.00,1.99,1.99|0.5100,34.04,0.00,0.00,0.00,0.00,0.00,0.00,1.00,0.00,0.00,0.00,0.00,0.00,0.00,36.77,18.01,18.26,0.00,0.00,0.00,0.00,0.00,8.99,0.00,20.06,14.01|0,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,2.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,4.00|3.0000,0.00,0.00,0.00,0.00,0.00,0.00,0.00,46.98,0.00,257.91,113.25,0.00,0.00,0.00,1.00,24.99,29.99,0.00,0.00,0.00,0.00,0.00,0.00,0.00,60.00,123.92|0,0.00,0.00,0.00,0.00,0.00,0.00,0.00,45.00,0.00,0.00,0.00,0.00,0.00,0.00,20.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,84.00|0,55.99,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,65.99'/>
<input type="submit"  />