Notebooks 2.0 is here.

Public
Edited
Jan 15, 2024
Importers
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function swatch(color, size="1em") {
return html`<div title="${color}" style="
display: inline-block;
width: ${size};
height: ${size};
background: ${color};
"></div>`;
}
Insert cell
function swatches(colors, size="1em") {
return html`${colors.map(c => `<div title="${c}" style="
display: inline-block;
margin-right: 3px;
width: ${size};
height: ${size};
background: ${c};
"></div>`)}`;
}
Insert cell
function named_swatch(size, value, key, map) {
return html`<div title="${key}" style="
display: inline-block;
margin-right: 1em;
width: ${size};
height: ${size};
background: ${value};
">
<p style="vertical-align: middle; text-align: center">
${key}
</p>
</div>`
}
Insert cell
function swatches_with_names(color_map, size="1em") {
var swatches = "";
var i = 0;
color_map.forEach((value, key, map) => {
swatches += `<div title="${key}" style="
display: inline-block;
margin-right: 1em;
width: ${size};
height: ${size};
background: ${value};
">
<p style="vertical-align: baseline; text-align: center; font-weight: 600">
${key}
</p>
<p style="vertical-align: baseline; text-align: center; font-weight: 600">
${i}
</p>
</div>`;
i += 1;
});
return html`${swatches}`;
}
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