Entering edit mode
12.4 years ago
Whetting
★
1.6k
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!
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
If that is the issue, you'll need to install a web server on your machine, put the file somewhere in the web root then view it at http://localhost/path/to/myfile.html.
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!