Skip to content

Instantly share code, notes, and snippets.

ZJONSSON / index.html
Last active Feb 9, 2017
Nelson's rivers (d3_geoJSON plugin)
View index.html
<!DOCTYPE html>
<html lang="en"><head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0"/>
<title>Leaflet vector tile map of rivers</title>
<link rel="stylesheet" href="" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="" />
Last active Apr 28, 2016
D3 GeoJSON in Leaflet

UPDATE: The Vector Tiles are not being served at this time by Openstreetmap. Try later or a different provider (example) Services seem to have resumed

A simple test of extending the L.TileLayer to fetch geoJSON tiles from openstreetmap and render them with d3. This is probably not the most efficient way to do this, as we accept empty image tags (from the standard TileLayer) and use them as containers for the data/requests.

ZJONSSON / app.js
Last active Feb 17, 2017
Icelandic population pyramid
View app.js
var data;
d3.csv("data.csv",function(err,d) {
data = {};
d.forEach(function(d) {
var kyn = d.kyn, aldur = +d.aldur;
.filter(function(d) { return d != 'kyn' && d != 'aldur';})
.forEach(function(e,i) {
var born = +e-aldur;
Last active Dec 15, 2015
Node-mysql test
Last active Apr 29, 2016
Brownian Bridge

Pan and Zoom (mousewheel) to explore the randomized data.

This experiment uses d3.js, dpl.js and pyfy.js to simulate geometric brownian motion with brownian bridge between any "known points" (either given values or already-randomized values). Active caching is utilized to ensure that any base random number stays in place until the world is re-randomized (i.e. I keep filling in missing information). This means that when volatility or drift is changed, the path is recalculated using the previously established Gaussian random outcomes.

The blue dots are known monthly closing values for APPL and the gray line is the simulated brownian motion Pan and zoom to look deeper and further. As you move around the cache will grow larger, but pressing "randomize" will reset the world to a new initial vector.

ZJONSSON / queuewrite.js
Created Mar 18, 2013
QueueWrite - asynchronous queue for stream output
View queuewrite.js
var stream = require("stream"),
util = require("util");
function QueueWrite(maxOpen,fn,options) {
this.maxOpen = maxOpen; = 0;
this.queue = [];
this.fn = fn;,options);

Changes in this fork:

  • index.html : Original file looped through all nodes: point.each(function(d) { d.scanned = d.selected = false; }); This version only touches the nodes scanned by the quadtree (and the previous selection), resulting in faster response
  • quadtree.js : Experiment in internalizing the area (x1,x2,y1,y2) of each quadrant within each node-object

See original here

ZJONSSON / flakar.json
Last active Mar 30, 2020
Iceland TopoJSON -pan/zoom
View flakar.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.