Jump to content

Embed XML SWF FusionChartsFree


MartiniThePilot
 Share

Recommended Posts

Hi,

weaponx inspired me with his embed XML SWF Graphics UDF to resume a 'postponed' project, still lacking of some result graphics. Posted Image

While the graphics of the chart engine used above look excellent, they are not animated and a click will always direct a browser window to the vendor home page. The licensed version of this product does not have these restrictions. To use it within freeware, you would have to buy the bulk license for 599 US$.

When looking for an alternative, I stopped at the free version of FusionChartsv3, called FusionChartsFree. They are licensed under MIT and/or GNU and are open source, even the flash source code (.fla) is included.

Homepage: http://www.fusioncharts.com/free/

Gallery: http://www.fusioncharts.com/free/gallery/

Documentation: http://www.fusioncharts.com/free/Docs/

License: http://www.fusioncharts.com/free/license/

Download: http://www.fusioncharts.com/free/download/

My original idea was, to start with a copy of weaponx' UDF and adapt it to FusionChartsFree. Just by changing the #include (and the chart engine), you may switch from one chart engine to the other without changing your AutoIt code. Even somehow possible, this is not as simple as I though - so I just converted a small part to give an usable example.

There are some major differences between XML/SWF Charts and FusionChartsFree:

  • FusionChartsFree has its own chart engine for each type of graphic (bar, line, etc.), so data and graphics are separated.
  • The path to the XML data file must be URI encoded (http://en.wikipedia.org/wiki/Url_encode), otherwise you get an 'Error on Loading Data'. Thanks to Prog@ndy for his _URIEncode function.
  • The XML input data has different tags.
  • The flash parameters (FlashVars) must be passed to the flash object prior starting the .swf file with the .Movie method. Sounds logical, but is different for the code mentioned above.
The .zip file below contains:

  • The XML input data Example1.xml
  • HTML files Chart1.htm and Chart2.htm to demonstrate the usage from HTML, both using the same input Example1.xml. The HTML files are not required for the AutoIt code.
  • The AutoIt GUI example Example1.au3 displaying two charts created from the same input data Example1.xml
  • The chart engines from FusionChartsFree FCF_MSLine.swf and FCF_MSColumn3D.swf
  • Example1.jpg - how it should look like
Enjoy!

Martin

post-28368-12524094031207_thumb.jpg

Example1.zip

Link to comment
Share on other sites

  • 10 months later...

ACalcutt

Posted 11 September 2009 - 09:00 PM

Looks good...

Is there any way to tell the graph to re-read the xml file?

Just pass the flash vars to it again:

$oChart1 = _CreateFusionChart("FCF_MSLine.swf",     @ScriptDir & "\Example1.xml", 0,   0, 600, 300)
    $oChart2 = _CreateFusionChart("FCF_StackedColumn3D.swf", @ScriptDir & "\Example1.xml", 0, 300, 600, 300)
    sleep(3000)
    $oChart1 = _CreateFusionChart("FCF_MSLine.swf",     @ScriptDir & "\Example2.xml", 0,   0, 600, 300, 1)

And the change in function (just for example):

Func _CreateFusionChart($sFusionChartFile, $sFusionChartPath, $iFusionChartL, $iFusionChartT, $iFusionChartW, $iFusionChartH, $sFusionChartBGColor = "505050", $isupdate = 0)
        if $isupdate = 0 then
        $oFusionChart = ObjCreate("ShockwaveFlash.ShockwaveFlash")
        $oFusionChartActiveX = GUICtrlCreateObj($oFusionChart, $iFusionChartL, $iFusionChartT, $iFusionChartW, $iFusionChartH)
        With $oFusionChart
            $sFlashVars = "&chartWidth=" & $iFusionChartW & "&chartHeight=" & $iFusionChartH & "&dataURL=" & _URIEncode($sFusionChartPath)
            ;MsgBox(0, "_CreateFusionChart", "FlashVars=" & $sFlashVars)    ;Trace flash parms
            .FlashVars =  $sFlashVars
            .Movie = @ScriptDir & "\" & $sFusionChartFile
            .ScaleMode = 3 ;0 showall, 1 noborder, 2 exactFit, 3 noscale
            .bgcolor = $sFusionChartBGColor
            .Loop = "True"
            .WMode = "transparent"
            .allowScriptAccess = "Always"
        EndWith     ;of With $oFusionChart
        Else
            $sFlashVars = "&chartWidth=" & $iFusionChartW & "&chartHeight=" & $iFusionChartH & "&dataURL=" & _URIEncode($sFusionChartPath)
            $oFusionChart.FlashVars = $sFlashVars
        EndIf

        Return $oFusionChart
    EndFunc     ;of Func _CreateFusionChart()

Works like a charm :blink:

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

  • 3 years later...

Just pass the flash vars to it again:

$oChart1 = _CreateFusionChart("FCF_MSLine.swf",     @ScriptDir & "\Example1.xml", 0,   0, 600, 300)
    $oChart2 = _CreateFusionChart("FCF_StackedColumn3D.swf", @ScriptDir & "\Example1.xml", 0, 300, 600, 300)
    sleep(3000)
    $oChart1 = _CreateFusionChart("FCF_MSLine.swf",     @ScriptDir & "\Example2.xml", 0,   0, 600, 300, 1)

And the change in function (just for example):

Func _CreateFusionChart($sFusionChartFile, $sFusionChartPath, $iFusionChartL, $iFusionChartT, $iFusionChartW, $iFusionChartH, $sFusionChartBGColor = "505050", $isupdate = 0)
        if $isupdate = 0 then
        $oFusionChart = ObjCreate("ShockwaveFlash.ShockwaveFlash")
        $oFusionChartActiveX = GUICtrlCreateObj($oFusionChart, $iFusionChartL, $iFusionChartT, $iFusionChartW, $iFusionChartH)
        With $oFusionChart
            $sFlashVars = "&chartWidth=" & $iFusionChartW & "&chartHeight=" & $iFusionChartH & "&dataURL=" & _URIEncode($sFusionChartPath)
            ;MsgBox(0, "_CreateFusionChart", "FlashVars=" & $sFlashVars)    ;Trace flash parms
            .FlashVars =  $sFlashVars
            .Movie = @ScriptDir & "\" & $sFusionChartFile
            .ScaleMode = 3 ;0 showall, 1 noborder, 2 exactFit, 3 noscale
            .bgcolor = $sFusionChartBGColor
            .Loop = "True"
            .WMode = "transparent"
            .allowScriptAccess = "Always"
        EndWith     ;of With $oFusionChart
        Else
            $sFlashVars = "&chartWidth=" & $iFusionChartW & "&chartHeight=" & $iFusionChartH & "&dataURL=" & _URIEncode($sFusionChartPath)
            $oFusionChart.FlashVars = $sFlashVars
        EndIf

        Return $oFusionChart
    EndFunc     ;of Func _CreateFusionChart()

Works like a charm :blink:

 

It doesn't work. Only pass the vars to Flash can't re-read the xml. Do you have other method?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...