Skip to content

Instantly share code, notes, and snippets.

@ZJONSSON
ZJONSSON / README.md
Created October 15, 2012 20:09 — forked from syntagmatic/README.md
Avg Price Histories (force_labels)
@ZJONSSON
ZJONSSON / README.md
Created October 19, 2012 13:59 — forked from mbostock/.block
d3.legend example

d3.legend

d3.legend is a quick hack to add a legend to a d3 chart. Simply add a g and .call(d3.legend). Any elements that have a title set in the "data-legend" attribute will be included when d3.legend is called. Each title will appear only once (even when multiple items define the same data-legend) as the process uses a set based on a existing names, not an array of all items.

Color

By default the color in the legend will try to match the fill attribute or the stroke attribute of the relevant items. Color can be explicitly defined by attribute "data-legend-color"

Order

The order of items in the legend will be sorted using the top of the bounding box for each included item. The order can be explicitly defined by attribute "data-legend-pos"

@ZJONSSON
ZJONSSON / README.markdown
Created December 11, 2012 17:39 — forked from bewest/README.markdown
D3.js glucose levels
@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.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 / 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 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 / README.md
Last active December 15, 2015 19:59
Node-mysql Query.stream test
@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 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.