Skip to content

Instantly share code, notes, and snippets.

View shancarter's full-sized avatar

Shan Carter shancarter

View GitHub Profile
@shancarter
shancarter / index.html
Last active December 12, 2015 08:28
Wavy Map Outlines
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
background: white;
}
.land {
fill: #00ff00;
@shancarter
shancarter / .block
Last active November 28, 2019 02:01
Mister Nester
license: mit
height: 700
@shancarter
shancarter / README.md
Last active November 28, 2016 00:37
A Simple HTML Slider With D3

DESCRIPTION

A simple d3.js slider

@shancarter
shancarter / index.html
Last active August 29, 2015 14:08
Pointer Lines
<!DOCTYPE html>
<meta charset="utf-8">
<style type="text/css">
.graphic {
font-family: Helvetica;
padding: 10px 0;
margin: 0 auto;
}
@shancarter
shancarter / index.html
Last active February 18, 2016 01:55
Testing data join pattern
<!DOCTYPE html>
<script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script>
<style media="screen">
.child {
margin: 10px 0;
color: white;
}
button {
@shancarter
shancarter / index.html
Last active February 8, 2018 21:13
Clustered Force Layout 4.0
<!doctype html>
<meta charset="utf-8">
<body>
<script src="//d3js.org/d3.v4.min.js"></script>
<script>
let margin = {top: 100, right: 100, bottom: 100, left: 100};
let width = 960,
height = 500,
@shancarter
shancarter / article.md
Created August 22, 2016 18:55 — forked from doug/article.md
dumb test

Hello

This is not an article.

@shancarter
shancarter / README.md
Last active June 7, 2019 11:42
Using d3 to generate SVGs in node.js

In order to generate some svg with d3 in node.js, you need a dom. This is a bare bones example of using jsdom for said dom.

@shancarter
shancarter / README.md
Last active November 7, 2016 19:29
Using d3 to generate canvas png in node.js

In order to generate a raster image with d3 in node.js, you need a canvas context. This is a bare bones example of using a node-based canvas for said context.

@shancarter
shancarter / README.md
Last active November 28, 2019 02:02
Calculating the relative angle difference between two vectors

Here are the math-y bits, courtesy of @ch402:

var a2 = Math.atan2(source.y, source.x);
var a1 = Math.atan2(compare.y, compare.x);
var sign = a1 > a2 ? 1 : -1;
var angle = a1 - a2;
var K = -sign * Math.PI * 2;
var angle = (Math.abs(K + angle) < Math.abs(angle))? K + angle : angle;