Published
Edited
Mar 3, 2022
1 star
Insert cell
Insert cell
generateRandomHexColor = () =>
`#${Math.floor(Math.random() * 0xffffff).toString(16)}`;
Insert cell
color = {
yield generateRandomHexColor()
}
Insert cell
out = html`${myTable()}`
Insert cell
myTable = () => {
let output = `<table >${renderRow(12)}</table>`

return output
}
Insert cell
renderRow = (rows) => {
let out = ``
for(let i = 0; i < rows; i++){
out = `${out} <tr>${renderCell(12)}</tr>`
}
return out
}
Insert cell
renderCell = (cells) => {
let out = ``;
for(let i = 0; i < cells; i++){
let color = generateRandomHexColor()
out = `${out} <td style="background-color:${color}">${color}</td>`;
}
return out;
}
Insert cell
<style>
td{
padding: 6px;
}
td {
border: 1px solid black;
}
</style>
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