This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Jsphylosvg Error

Hi,
I am playing around with the tutorials on jsPhyloSVG I downloaded the code for "3.1 Add Interactive Features"

<html>
<head>
<link type="text/css" rel="stylesheet" href="/js/yui/build/cssfonts/fonts-min.css" /> 
<script type="text/javascript" src="/js/raphael/raphael-min.js" ></script> 
<script type="text/javascript" src="/js/yui/build/yui/yui.js"></script> 
<script type="text/javascript" src="/js/jsphylosvg-min.js"></script> 
<!-- unitip -->
<link rel="stylesheet" type="text/css" href="/js/unitip/css/unitip.css" > 
<script type="text/javascript" src="/js/unitip/js/unitip.js"></script>     
<script type="text/javascript">
window.onload = function(){
    YUI().use('oop', 'json-stringify', 'io-base', 'event', 'event-delegate', function(Y){
        var uri = "/trees/3-coffee.xml";
        function complete(id, o, args) {
            var data = o.responseXML; // Response data.
            var dataObject = {
                        xml: data,
                        fileSource: true
                    };        
            phylocanvas = new Smits.PhyloCanvas(
                dataObject,
                'svgCanvas', 
                800, 800,
                'circular'                
            );
            init(); //unitip
        };
        Y.on('io:complete', complete, Y);
        var request = Y.io(uri);
    });
};
</script>
</head>
<body>
    <div id="svgCanvas"> </div>
</body>
</html>

When I open the html file I get the following error

Please set the format of input data

I do not understand where the error is coming from
As always, any and all help will be appreciated!

phylogeny

sorry, why does the html part of the code look all weird?

There's a formatting issue with HTML/XML code at BioStar, unfortunately. I guess the site developers are working on it.

Are you loading this from your computer or are you loading this from a http server? AJAX doesn't work if you are loading it just off your computer's file directory. Read up on browser's same-origin policy. You can try to script inject by converting your data into JSON and load it as a pseudo javascript library.

@DK, I was just loading directly from my local machine. That could be the problem! Thanks! I'll look into that

Easiest way to deal with this problem in my experience without much fuss is to just run:

python -m SimpleHTTPServer

That will create a httpserver at the directory that you run the command. Your localhost will now point to that directory.

If you are interested in browser visualizations in javascript. I've written some blog posts on that topic: http://blog.nextgenetics.net/?c=data-visualization

I've just posted an entry on heatmap visualization in javascript today actually.

@DK, that's pretty sweet. I'll check it out!

1 answer

Turns out that the problem was a lot simpler than that!
I just changed

var uri = "/trees/3-coffee.xml"

to

var uri = "trees/3-coffee.xml"

thanks for all the help!!

Log in to answer this question.