Skip to content

Instantly share code, notes, and snippets.

@ZJONSSON
ZJONSSON / index.html
Last active February 9, 2017 16:30
Nelson's rivers (d3_geoJSON plugin)
<!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="http://cdn.leafletjs.com/leaflet-0.5/leaflet.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5/leaflet.ie.css" />
@ZJONSSON
ZJONSSON / README.md
Last active April 28, 2016 07:18
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
ZJONSSON / app.js
Last active February 17, 2017 05:36
Icelandic population pyramid
var data;
d3.csv("data.csv",function(err,d) {
data = {};
d.forEach(function(d) {
var kyn = d.kyn, aldur = +d.aldur;
Object.keys(d)
.filter(function(d) { return d != 'kyn' && d != 'aldur';})
.forEach(function(e,i) {
var born = +e-aldur;
@ZJONSSON
ZJONSSON / README.md
Last active December 15, 2015 19:59
Node-mysql Query.stream test
@ZJONSSON
ZJONSSON / README.md
Last active April 29, 2016 16:39
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
ZJONSSON / queuewrite.js
Created March 18, 2013 17:51
QueueWrite - asynchronous queue for stream output
var stream = require("stream"),
util = require("util");
function QueueWrite(maxOpen,fn,options) {
this.maxOpen = maxOpen;
this.open = 0;
this.queue = [];
this.fn = fn;
stream.Writable.call(this,options);
}
@ZJONSSON
ZJONSSON / README.md
Last active December 14, 2015 09:59 — forked from mbostock/README.md

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
ZJONSSON / flakar.json
Last active March 2, 2023 13:26
Iceland TopoJSON -pan/zoom
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ZJONSSON
ZJONSSON / README.markdown
Created December 11, 2012 17:39 — forked from bewest/README.markdown
D3.js glucose levels