Published
Edited
Feb 19, 2020
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
p = getRandomPalette()
Insert cell
palette = shuffle(p)
// palette = ['black', 'white']
Insert cell
Insert cell
svg`<svg width="${w}" height="${h}">
<rect x="0" y="0" width="${w}" height="${h}" stroke="none" fill="${palette[0]}"></rect>
${layer(randInt(5, 30))}
<rect x="0" y="0" width="${w}" height="${h}" stroke="none" fill="${palette[0]}" opacity="0.1"></rect>
${layer(randInt(40, 80))}
<rect x="0" y="0" width="${w}" height="${h}" stroke="none" fill="${palette[0]}" opacity="0.1"></rect>
${layer(randInt(100,300))}
</svg>`
Insert cell
layer = n => array(n).map(i => {
const y = i * h / n
const sw = h / n - 3
const dashes = array(50).map(() => `${expRand(1, 150, 8)|0} ${random(1, 25)|0}`).join(' ')
const offset = randInt(1, 5)
return `<g opacity="1">
<polyline
opacity="0.5"
points="${-10 - offset} ${y + sw/2 + 1 + offset} ${w + 10 - offset} ${y + sw/2 + 1 + offset}"
fill="none"
stroke="black"
stroke-width="${sw}"
stroke-dasharray="${dashes}"
/>
<polyline
points="-10 ${y + sw/2 + 1} ${w + 10} ${y + sw/2 + 1}"
fill="none"
stroke="${palette[randInt(palette.length)]}"
stroke-width="${sw}"
stroke-dasharray="${dashes}"
/>
</g>`
}).join('\n')
Insert cell
Insert cell
Insert cell
Insert cell
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