如何将FusionChart导出为图片在ASP.Net [英] How to export a FusionChart to Image in ASP.Net

查看:184
本文介绍了如何将FusionChart导出为图片在ASP.Net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用的融合图的免费版和想知道的是有没有生成的图表图像输出,而无需使用任何第三方组件的方式。我们使用ASP.Net生成图表。

We are using the free version of fusion charts and want to know is there a way to export the generated chart to image without using any third party components. We are using the ASP.Net for generating the charts.

推荐答案

SOLUTION

在这个主题的研究后,我发现了一个有用的解决方案这一点。

After a research on this topic, I have found a useful solution for this.

有关,我们需要有从Bytecout一个免费的SWF转换为图像。这可以从这个链接下载。

For that we need to have a freeware from Bytecout to convert swf to image. This can be downloaded from this link.

这时我们就需要注册COM DLL和引用添加到我们的项目中。参考以下为进一步使用

Then we need to register the COM dlls and add the reference to our project. Refer to the below for further usage

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

下面动画=0中起着非常重要的作用,它指定,它必须在没有动画加载融合图表瑞士法郎。还最好是,如果我们睡code代表1或2秒瑞士法郎将完全加载并且图像被转换到所选择的格式。

Here animation='0' plays a very important role, it specifies the fusion chart swf that, it must be loaded without animation. Also it is advisable if we sleep the code for 1 or 2 sec the swf would be loaded completely and image is converted to the selected format.

希望这将是对我这样的人是有用的。 : - )

Hope this would be useful for someone like me. :-)

这篇关于如何将FusionChart导出为图片在ASP.Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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