Skip to content

Instantly share code, notes, and snippets.

@mbostock
mbostock / .block
Last active January 31, 2024 11:52
Hexagonal Binning (Color)
license: gpl-3.0
redirect: https://observablehq.com/@d3/d3-hexbin
@mbostock
mbostock / .block
Last active July 20, 2019 01:01
Clipped Map Tiles
license: gpl-3.0
redirect: https://observablehq.com/@d3/clipped-map-tiles
@mbostock
mbostock / .block
Last active July 18, 2016 19:32
Pseudo-Demers Cartogram
license: gpl-3.0
@jasondavies
jasondavies / index.html
Created September 10, 2012 08:33
longscroll.js
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.longscroll {
overflow-y: auto;
width: 480px;
height: 500px;
float: left;
}
.longscroll .row {
@ZJONSSON
ZJONSSON / force_labels.js
Last active October 18, 2025 03:09
Automatic floating labels using d3 force-layout
(function() {
d3.force_labels = function force_labels() {
var labels = d3.layout.force();
// Update the position of the anchor based on the center of bounding box
function updateAnchor() {
if (!labels.selection) return;
labels.selection.each(function(d) {
var bbox = this.getBBox(),
x = bbox.x + bbox.width / 2,
@methodin
methodin / markovCluster.js
Created January 7, 2012 03:54
Markov Clustering
function round(n) {
return Math.round(n*100) / 100;
}
// Represents an edge from source to sink with capacity
var Edge = function(source, sink, capacity) {
this.source = source;
this.sink = sink;
this.capacity = capacity;
};
@mbostock
mbostock / .block
Last active February 26, 2019 22:38
Marimekko Chart
license: gpl-3.0
redirect: https://observablehq.com/@d3/d3-marimekko-chart