Skip to content

Instantly share code, notes, and snippets.

@mbostock
mbostock / .block
Last active February 26, 2019 22:38
Marimekko Chart
license: gpl-3.0
redirect: https://observablehq.com/@d3/d3-marimekko-chart
@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;
};
@ZJONSSON
ZJONSSON / force_labels.js
Last active May 18, 2023 08:52
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,
@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 {
@mbostock
mbostock / .block
Last active July 18, 2016 19:32
Pseudo-Demers Cartogram
license: gpl-3.0
@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 January 31, 2024 11:52
Hexagonal Binning (Color)
license: gpl-3.0
redirect: https://observablehq.com/@d3/d3-hexbin
@mbostock
mbostock / .block
Last active October 22, 2018 01:30 — forked from mbostock/.block
Hexagonal Binning (Area)
license: gpl-3.0
redirect: https://beta.observablehq.com/@mbostock/d3-hexbin-area
@balamuru
balamuru / gensim_scikit_kmeans.py
Last active December 27, 2019 10:52
gensim + scikit clustering vs scipy clustering (DEBUG)
import logging
from scipy.odr import models
from sklearn import metrics
import unittest
import os
import os.path
import tempfile
import numpy
from matplotlib.pyplot import plot, show
@dgerber
dgerber / Makefile
Last active May 2, 2017 22:00
Reusable Non-Contiguous Cartogram
swiss-cantons.topo.json: lib/swiss-maps/topojson/swiss-cantons.json
topojson --properties --id-property abbr \
-o $@ \
lib/swiss-maps/topojson/swiss-cantons.json