Skip to content

Instantly share code, notes, and snippets.

@nowherenearithaca
nowherenearithaca / prependanimate.js
Last active December 11, 2015 10:38
Snippet for blog; this snippet is from Cletus' answer to this stack overflow post: http://stackoverflow.com/questions/3034752/jquery-appending-an-li-to-a-ul-and-then-animating-that-li
$("<li>This is my item</li>")
.hide()
.prependTo("#news-feed")
.slideDown();
@nowherenearithaca
nowherenearithaca / README.md
Last active April 11, 2016 04:22
Making a Heat Map Legend with D3 - a Simple Example

This is an example of creating what could be a legend for a heat map, demonstrating the simple use of a data-driven linear gradient with D3.

var d3_nsPrefix = {
svg: "http://www.w3.org/2000/svg",
xhtml: "http://www.w3.org/1999/xhtml",
xlink: "http://www.w3.org/1999/xlink",
xml: "http://www.w3.org/XML/1998/namespace",
xmlns: "http://www.w3.org/2000/xmlns/"
};
qualify: function(name) {
var i = name.indexOf(":"),
prefix = name;
if (i >= 0) {
prefix = name.substring(0, i);
name = name.substring(i + 1);
}
return d3_nsPrefix.hasOwnProperty(prefix)
? {space: d3_nsPrefix[prefix], local: name}
: name;
{space: "http://www.w3.org/2000/svg", local: "svg"}
@nowherenearithaca
nowherenearithaca / gist:2852297
Created June 1, 2012 13:49
d3 "append" definition
d3_selectionPrototype.append = function(name) {
name = d3.ns.qualify(name);
function append() {
return this.appendChild(document.createElementNS(this.namespaceURI, name));
}
function appendNS() {
return this.appendChild(document.createElementNS(name.space, name.local));
}
@nowherenearithaca
nowherenearithaca / gist:2852155
Created June 1, 2012 13:29
html generated from vis
<svg class="vis">
vis = d3.select("body").append("svg:svg").attr("class", "vis");