This file contains hidden or 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
| var data = [5, 25, 40, 20, 10]; | |
| var sw = parseInt(svg.style("width"), 10); | |
| var sh = parseInt(svg.style("height"), 10); | |
| var r = Math.min(sw, sh)/2; | |
| var color = d3.scale.category20(); | |
| var arc = d3.svg.arc().outerRadius(r); | |
| var donut = d3.layout.pie(); |
This file contains hidden or 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
| //Try changing all these parameters | |
| //Layout properties | |
| var w = 700 | |
| , h = 500 | |
| , n = 25 | |
| , m = 40 | |
| , spacing = 65 | |
| , opacity = 0.8 | |
| , stroke_width = 15 |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script type="text/javascript" src="http://mbostock.github.com/d3/d3.v2.js"></script> | |
| <script type="text/javascript" src="http://canvg.googlecode.com/svn/trunk/rgbcolor.js"></script> | |
| <script type="text/javascript" src="http://canvg.googlecode.com/svn/trunk/canvg.js"></script> | |
| <script type="text/javascript" src="http://www.nihilogic.dk/labs/canvas2image/canvas2image.js"></script> | |
| <script type="text/javascript" src="http://www.nihilogic.dk/labs/canvas2image/base64.js"></script> | |
| </head> |
This file contains hidden or 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
| // Boid flocking based on http://harry.me/2011/02/17/neat-algorithms---flocking | |
| var boid = (function() { | |
| function boid() { | |
| var position = [0, 0], | |
| velocity = [0, 0], | |
| w = 960, | |
| h = 500, | |
| gravityCenter = null, | |
| gravityMultiplier = 1, | |
| neighborRadius = 50, |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
| <style> | |
| #svg { | |
| position: absolute; | |
| top: 10px; | |
| left: 10px; | |
| } |
This file contains hidden or 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
| // chord diagram from http://mbostock.github.com/d3/ex/chord.html | |
| // colors from the twilight theme: http://bit.ly/wufWv1 | |
| var chord = d3.layout.chord() | |
| .padding(0.05) | |
| .sortSubgroups(d3.descending) | |
| .matrix([ | |
| [11975, 5871, 8916, 2868], | |
| [ 1951, 10048, 2060, 6171], |
This file contains hidden or 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
| import SimpleHTTPServer | |
| class CORSHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
| def send_head(self): | |
| """Common code for GET and HEAD commands. | |
| This sends the response code and MIME headers. | |
| Return value is either a file object (which has to be copied | |
| to the outputfile by the caller unless the command was HEAD, | |
| and must be closed by the caller under all circumstances), or |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Line Chart</title> | |
| <script src="http://mbostock.github.com/d3/d3.v2.js"></script> | |
| <link href="lineplot.css" rel="stylesheet" type="text/css"> | |
| </head> | |
| <body> | |
| <script type="text/javascript"> | |
| function linePlot() { |
This file contains hidden or 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
| var x = 42; |
This file contains hidden or 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
| var test = 5; |