Skip to content

Instantly share code, notes, and snippets.

View emeeks's full-sized avatar

Elijah Meeks emeeks

View GitHub Profile
@emeeks
emeeks / README.md
Last active July 3, 2018 02:44
Variable Offset Animated Links

Variable offset animation fun.

@emeeks
emeeks / README.md
Last active August 15, 2016 04:40
Particle Edges Dendrogram

Particle edges from d3_glyphEdges are the most difficult edge type to implement. Here's an example using a dendrogram and the connecting paths from the dendrogram. Remember that d3_glyphEdge.mutate.particle mutates the edge data object, spawning new particles, updating the position of existing particles and deleting particles that have reached the end of the path, and it's this array that you use to represent the particles (either with SVG as in this example or, if you're dealing with a lot of particles, probably canvas). As such, an edge object needs to have, along with .source and .target, .frequency (a positive number) to indicate the number of particles created per tick and .particles (an array) to hold the created particles.

d3_glyphEdge.mutate.particle does not include its own tick function so you need to create your own. This example uses d3.timer whereas this network example uses the built-in ti

@emeeks
emeeks / d3-glyphEdge.js
Last active October 3, 2016 03:37
d3_glyphEdge
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define('d3-glyphEdge', ['exports'], factory) :
factory((global.d3_glyphEdge = {}));
}(this, function (exports) { 'use strict';
function halfArrow(d, nodeTargetSize, bodySize, headSize) {
var diffX = d.target.y - d.source.y;
var diffY = d.target.x - d.source.x;
@emeeks
emeeks / index.html
Last active March 8, 2016 01:42
Clockface Edges
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Sankey Particles</title>
<style>
.node rect {
cursor: move;
@emeeks
emeeks / d3.sankey.js
Last active September 14, 2020 16:49
Sankey Particles IV
d3.sankey = function() {
var sankey = {},
nodeWidth = 24,
nodePadding = 8,
size = [1, 1],
nodes = [],
links = [];
sankey.nodeWidth = function(_) {
if (!arguments.length) return nodeWidth;
@emeeks
emeeks / d3.sankey.js
Last active April 20, 2023 15:23
Sankey Particles III
d3.sankey = function() {
var sankey = {},
nodeWidth = 24,
nodePadding = 8,
size = [1, 1],
nodes = [],
links = [];
sankey.nodeWidth = function(_) {
if (!arguments.length) return nodeWidth;
@emeeks
emeeks / d3.sankey.js
Last active September 13, 2018 15:59
Sankey Particles II
d3.sankey = function() {
var sankey = {},
nodeWidth = 24,
nodePadding = 8,
size = [1, 1],
nodes = [],
links = [];
sankey.nodeWidth = function(_) {
if (!arguments.length) return nodeWidth;
@emeeks
emeeks / d3.sankey.js
Last active December 31, 2021 13:45
Sankey Particles
d3.sankey = function() {
var sankey = {},
nodeWidth = 24,
nodePadding = 8,
size = [1, 1],
nodes = [],
links = [];
sankey.nodeWidth = function(_) {
if (!arguments.length) return nodeWidth;
@emeeks
emeeks / d3.hexbin.js
Last active May 12, 2018 12:24
Fog of War IV
(function() {
d3.hexbin = function() {
var width = 1,
height = 1,
r,
x = d3_hexbinX,
y = d3_hexbinY,
dx,
dy;
@emeeks
emeeks / d3.hexbin.js
Last active May 8, 2017 10:15
Fog of War III
(function() {
d3.hexbin = function() {
var width = 1,
height = 1,
r,
x = d3_hexbinX,
y = d3_hexbinY,
dx,
dy;