Public
Edited
Jan 27, 2023
1 fork
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mdn_colors = {
let h = html`${response_text}`;
let tables = d3.select(h).selectAll("table").nodes();
let colors = [];
d3.range(3).map((i) =>
d3
.select(tables[i])
.selectAll("tr")
.nodes()
.forEach(function (row, i) {
if (i > 0) {
let row_data = d3.select(row).selectAll("td").nodes();
if (row_data.length > 1) {
let color_name = row_data[0].innerText;
let match = color_name.match(/\(.*\)/);
if (match) {
let idx = match.index;
color_name = color_name.slice(0, idx);
}
colors.push({
color_name,
hex_value: row_data[1].innerText
});
}
}
})
);

return colors;
}
Insert cell
response_text = fetch(
"https://corsproxy.io/?https://developer.mozilla.org/en-US/docs/Web/CSS/named-color"
).then((r) => r.text())
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