Public
Edited
Sep 16, 2020
Importers
16 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
async function emojiHash(input) {
const index = (await digest(input)) % emoji.length;
return emoji[index];
}
Insert cell
emojiHash(input)
Insert cell
Insert cell
async function colorHash(input) {
return colors(await digest(input));
}
Insert cell
colorHash(input)
Insert cell
colors = d3.scaleSequential(t => `hsl(${t * 360 % 360}, 100%, 90%)`).domain([0, 10])
Insert cell
Insert cell
async function digest(message) {
const msgUint8 = new TextEncoder().encode(message);
const hashBuffer = await crypto.subtle.digest("SHA-256", msgUint8);
return new DataView(hashBuffer).getUint32(); // first 4 bytes
}
Insert cell
Insert cell
import { text } from '@jashkenas/inputs'
Insert cell
import { emoji } from '@jashkenas/every-emoji@115'
Insert cell
d3 = require('d3-scale@3')
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more