Created
September 12, 2012 17:58
-
-
Save lrowe/3708615 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*global document, jQuery */ | |
(function($) { | |
$(function() { | |
var g, renderer; | |
var width = $(document).width() - 20; | |
var height = $(document).height() - 60; | |
g = new Graph(); | |
/* add a simple node */ | |
g.addNode("apple"); | |
g.addNode("strawberry"); | |
g.addNode("cherry"); | |
/* connect nodes with edges */ | |
g.addEdge("strawberry", "cherry", {directed: true, label: 'to_cherry'}); | |
g.addEdge("cherry", "apple", {directed: true, label: 'to_apple'}); | |
g.addEdge("cherry", "apple", {directed: true, label: 'to_apple2'}) | |
/* layout the graph using the Spring layout implementation */ | |
var layouter = new Graph.Layout.Spring(g); | |
/* draw the graph using the RaphaelJS draw implementation */ | |
renderer = new Graph.Renderer.Raphael('canvas', g, width, height); | |
$('button#redraw').click(function () { | |
layouter.layout(); | |
renderer.draw(); | |
}); | |
}); | |
}(jQuery)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript" src="https://raw.github.com/strathausen/dracula/master/js/raphael-min.js"></script> | |
<script type="text/javascript" src="https://raw.github.com/strathausen/dracula/master/js/dracula_graffle.js"></script> | |
<script type="text/javascript" src="https://raw.github.com/strathausen/dracula/master/js/jquery-1.4.2.min.js"></script> | |
<script type="text/javascript" src="https://raw.github.com/strathausen/dracula/master/js/dracula_graph.js"></script> | |
<script type="text/javascript" src="example.js"></script> | |
</head> | |
<body> | |
<div id="canvas"></div> | |
<button id="redraw">redraw</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment