xdot.js parses GraphViz xdot formatted strings into Raphaël objects. This first version of xdot.py is a very close port of the lexer/parser code in xdot.py.
xdot is generated from dot files using one of the GraphViz layout commands. In this case, we'll just use the dot command.
> dot -Txdot -oexample.xdot example.dot
Include jQuery, Raphael and xdot.js. Create a new XDotParser object with your xdot formatted text, parse it, then draw it.
var graph = new XDotParser(text).parse();
graph.draw();
Or, you can get the xdot data via AJAX.
$.get('graph.xdot', function(text) {
var graph = new XDotParser(text).parse();
graph.draw();
});
- Decouple the parsing from the drawing. Ideally, we could use any capable drawing library, not just Raphael.
- Overall code cleanup. I'm not happy with how many variables are added to the global namespace.