Created
January 1, 2009 01:00
-
-
Save xaviershay/42169 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
// Live tables! | |
// This example works on http://en.wikipedia.org/wiki/Table_(information) | |
// Paste into firebug console | |
require = function (src){ | |
var script = document.createElement('script'); | |
script.setAttribute('type', 'text/javascript'); | |
script.setAttribute('src', src); | |
// InsertBefore for IE. | |
// IE crashes on using appendChild before the head tag has been closed. | |
var head = document.getElementsByTagName('head').item(0); | |
head.insertBefore(script, head.firstChild); | |
} | |
css = function (src){ | |
var script = document.createElement('link'); | |
script.setAttribute('type', 'text/css'); | |
script.setAttribute('rel', 'stylesheet'); | |
script.setAttribute('href', src); | |
// InsertBefore for IE. | |
// IE crashes on using appendChild before the head tag has been closed. | |
var head = document.getElementsByTagName('head').item(0); | |
head.insertBefore(script, head.firstChild); | |
} | |
css("http://xaviershay.github.com/tufte-graph/tufte-graph.css"); | |
require("http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"); | |
require("http://xaviershay.github.com/tufte-graph/jquery.enumerable.js"); | |
require("http://xaviershay.github.com/tufte-graph/raphael.js"); | |
require("http://xaviershay.github.com/tufte-graph/jquery.tufte-graph.js"); | |
window.setTimeout(function() { | |
var j = jQuery; | |
var table = j(j('table.wikitable').get(0)); | |
table.after('<div class="graph" id="age-table" style="width: 500px; height: 200px; margin: 50px;"></div>'); | |
var column = function(element, n) { return j(element).find('td:nth-child(' + n + ')').text(); } | |
j('#age-table').tufteBar({ | |
data: table.find('tr:gt(0)').collect(function() { return [column(this, 3) * 1, column(this, 1) + ' ' + column(this, 2)]; }), | |
axisLabel: function() { return this[1] } | |
}) | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment