Fw: RaVis with dynamic XML datasource?

7 views
Skip to first unread message

Michael Pelz-Sherman

unread,
Nov 25, 2008, 3:56:02 PM11/25/08
to flexviz...@googlegroups.com
Once again, I've answered my own question. :-)

Instead of this:

<mx:XML id="xmldata" source="data/graph.xml" />

... do the following. Note that you must have a crossdomain.xml file accessible somewhere on your server or you will get security errors when trying to load the XML.

(Apologies for the formatting.)


    <mx:HTTPService id="xmlHttpService" url="http://myserver/myurl"
                    result="xmlResultSuccess( event )" resultFormat="e4x" fault="xmlResultFailure( event );" />

    <mx:Script>
<![CDATA[
import org.un.cava.birdeye.ravis.graphLayout.data.Graph;
import org.un.cava.birdeye.ravis.components.ui.controls.vgraphControls.NodeRendererSelector;
import org.un.cava.birdeye.ravis.components.ui.controls.vgraphControls.EdgeRendererSelector;
import org.un.cava.birdeye.ravis.components.ui.controls.vgraphControls.DegreesOfSeparation;
import org.un.cava.birdeye.ravis.assets.icons.EmbeddedIcons;
            import mx.controls.Alert;
            import mx.rpc.events.FaultEvent;
            import mx.rpc.events.ResultEvent;

            [Bindable]
            private var xmldata:XML;

            /* Init function, initiates the HTTP
* request. All further initalisation is done
* in the event handler for the HTTP Service */
private function init():void {
                Security.loadPolicyFile("http://myserver/crossdomain.xml");                   
                xmlHttpService.send();                
}

            private function xmlResultSuccess( event:ResultEvent ):void
            {
                xmldata = event.result as XML;
                initData();
            }

            private function xmlResultFailure( event:FaultEvent ):void
            {
                Alert.show( event.fault.message, "Error loading XML" );
            }
            

            /**
* event handler for HTTPService, does all the remaining required
       * initialisation */
private function initData():void {

                /* init a graph object with the XML data */
vgraph.graph = new Graph("XMLAsDocsGraph",false,xmldata);


From: Michael Pelz-Sherman <mpelzs...@gmail.com>
To: flexviz...@googlegroups.com
Sent: Tuesday, November 25, 2008 2:39:57 PM
Subject: RaVis with dynamic XML datasource?

Are there any examples of using RaVis with a dynamic XML data source (loaded at runtime from an HTTP request to a web service) as opposed to a static file?

Thanks!

- Michael

JB

unread,
Nov 26, 2008, 8:27:44 AM11/26/08
to BirdEye
Michael,

Well, looks like you found your own answer. If your still looking to
other options, you can find an interesting example using JSON here:

http://ccgi.arutherford.plus.com/blog/wordpress/?p=170

JB
Reply all
Reply to author
Forward
Message has been deleted
0 new messages