Skip to content

Instantly share code, notes, and snippets.

@rokotyan
rokotyan / .block
Last active December 12, 2023 13:07
Export SVG D3 visualization to PNG or JPEG
license: mit
@couchand
couchand / README.md
Last active September 15, 2016 18:42 — forked from mbostock/.block
Adjustable ranges on color scale

An example illustrating a scale that allows the ranges to be adjusted by the user.

This example is based on this one.

This example demonstrates how to construct a key from a threshold scale, in the style of Ford Fessenden’s map of police stops involving force. A linear scale is used to set the x-position of each colored rectangle in the key. There is one rectangle per color in the threshold scale’s range, and one tick per value in the threshold scale’s domain. The linear scale’s domain sets the implied extent of the key, here spanning 0 to 100%.

@bmcbride
bmcbride / LeafletToWKT.js
Last active June 7, 2022 02:17
Leaflet layer to WKT
function toWKT(layer) {
var lng, lat, coords = [];
if (layer instanceof L.Polygon || layer instanceof L.Polyline) {
var latlngs = layer.getLatLngs();
for (var i = 0; i < latlngs.length; i++) {
latlngs[i]
coords.push(latlngs[i].lng + " " + latlngs[i].lat);
if (i === 0) {
lng = latlngs[i].lng;
lat = latlngs[i].lat;