我们正在使用融合图表的免费版本,并想知道有没有办法将生成的图表导出到图像而不使用任何第三方组件。我们使用ASP.Net生成图表。
答案 0 :(得分:2)
<强>解强>
在对这个主题进行研究之后,我找到了一个有用的解决方案。
为此,我们需要从Bytecout获得免费软件将swf转换为图像。这可以从link下载。
然后我们需要注册COM dll并添加对项目的引用。请参阅以下内容以了解更多用途
Protected Sub btnSwf2ImgConverter_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim swfobj As New SWFToImage.SWFToImageObject
swfobj.InitLibrary("demo", "demo")
swfobj.InputSWFFileName = Server.MapPath("dumps/swf/") & "FCF_MSColumn3D.swf"
If ddlImageExtension.SelectedValue = "jpg" Then
swfobj.ImageOutputType = TImageOutputType.iotJPG
ext = ".jpg"
Else
If ddlImageExtension.SelectedValue = "gif" Then
swfobj.ImageOutputType = TImageOutputType.iotGIF
ext = ".gif"
Else
If ddlImageExtension.SelectedValue = "png" Then
swfobj.ImageOutputType = TImageOutputType.iotPNG
ext = ".png"
Else
If ddlImageExtension.SelectedValue = "bmp" Then
swfobj.ImageOutputType = TImageOutputType.iotBMP
ext = ".bmp"
End If
End If
End If
End If
filenm = "FCF_Column3D" & ext
swfobj.Execute_Begin()
'swfobj.Execute()
swfobj.Execute_SetVariable("dataXML", "<graph animation='0' formatNumber='1' divLineColor='ff5904' divLineAlpha='20' alternateHGridAlpha='5' canvasBorderColor='666666' baseFontColor='666666' showAlternateHGridColor='1' AlternateHGridColor='ff5904' anchorSides='3' rotateNames='1' caption='Daily Reports' yAxisMinValue='0' yAxisMaxValue='1' xAxisName='Day-Month-Year' yAxisName='Percentage' decimalPrecision='2' numdivlines='8' numVdivlines='16' showhovercap='1' formatNumberScale='0'> <categories> <category name='1-Jun-2010' showName='1' /> <category name='2-Jun-2010' showName='1' /> <category name='3-Jun-2010' showName='1' /> <category name='4-Jun-2010' showName='1' /> <category name='5-Jun-2010' showName='1' /> <category name='6-Jun-2010' showName='1' /> <category name='7-Jun-2010' showName='1' /> <category name='8-Jun-2010' showName='1' /> <category name='9-Jun-2010' showName='1' /> <category name='10-Jun-2010' showName='1' /> <category name='11-Jun-2010' showName='1' /> <category name='12-Jun-2010' showName='1' /> <category name='13-Jun-2010' showName='1' /> <category name='14-Jun-2010' showName='1' /> <category name='15-Jun-2010' showName='1' /> <category name='Aggregate' showName='1' /></categories><dataset showValues='0' alpha='80' showAnchors='1' seriesname='Answered Percent' color='#f07979' lineThickness='2'><set name='Month' value='97.6'/><set name='Month' value='98.2'/><set name='Month' value='99.3'/><set name='Month' value='99.6'/><set name='Month' value='95.2'/><set name='Month' value='99.3'/><set name='Month' value='99.3'/><set name='Month' value='98.8'/><set name='Month' value='97.5'/><set name='Month' value='96.3'/><set name='Month' value='98.6'/><set name='Month' value='99.1'/><set name='Month' value='99.3'/><set name='Month' value='99.6'/><set name='Month' value='99.2'/><set name='Month' value='98.38'/></dataset></graph>")
swfobj.Execute_SetVariable("chartWidth", "750")
swfobj.Execute_SetVariable("chartHeight", "600")
swfobj.ImageWidth = 600
swfobj.ImageHeight = 500
Threading.Thread.Sleep(10000)
swfobj.Execute_GetImage()
swfobj.SaveToFile(Server.MapPath("dumps/images/" & filenm))
swfobj.Execute_End()
Call DownloadImage(filenm)
End Sub
Public Sub DownloadImage(ByVal fn As String)
Image1.ImageUrl = "~/dumps/images/" & fn
Dim fi As New FileInfo(Server.MapPath("dumps/images/" & fn))
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", fn))
HttpContext.Current.Response.ContentType = "image/" & DropDownList1.SelectedValue
Response.WriteFile(fi.FullName)
Response.Flush()
fi.Delete()
Response.End()
End Sub
这里animation ='0'起着非常重要的作用,它指定了融合图表swf,它必须在没有动画的情况下加载。此外,如果我们将代码休眠1或2秒,则可以完全加载swf并将图像转换为所选格式。
希望这对像我这样的人有用。 : - )
答案 1 :(得分:0)
答案 2 :(得分:-1)
FusionCharts团队开发了一个.NET程序集,使您可以在服务器上导出图表而无需在浏览器中加载图表。
您可以通过http://www.fusioncharts.com/contact/写信给FusionCharts支持来获取它。
这仅适用于FusionCharts v3图表。