Public
Edited
Jan 26, 2023
6 forks
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
<p class='name'>John</p>
<p class='city'>New York</p>
<p class='name'>Mary</p>
<p class='city'>Rio de Janeiro</p>
<p class='name'>Peter</p>
<p id='serial-number'>Serial Number: 0123345</p>
Insert cell
Insert cell
<style>

/* .name{
background-color: green;
}
*/
.city{
background-color: red;
}

#serial-number{
border-style: solid;
border-color: purple;
}

</style>
Insert cell
Insert cell
Insert cell
<div id='testid'>
<p>Child 1</p>
<p>Child 2</p>
<p>Child 3</p>
</div>
Insert cell
{
const divreference = document.querySelector('#testid')
return divreference;
// return divreference.children[1].innerText;
}

Insert cell
{
const p = document.createElement('p');
p.textContent = 'INFOVIS123';

return p;
}
Insert cell
Insert cell
Insert cell
{
const div = document.createElement("div");
div.id = 'abc';
return div;
}
Insert cell
Insert cell
{
const div = document.querySelector('#abc');
div.style.height = '100px';
div.style.width = '100px';
div.style.backgroundColor = "red";
// div.style.borderRadius = '100%';

return 'div updated :)'
}
Insert cell
Insert cell
Insert cell
{
const width = 400;
const height = 200;

// element parameters
const radius = 20;
const svg = DOM.svg(width, height);

for (let id = 0; id < 20; id ++) {
const circle = DOM.element("svg:circle");

circle.setAttribute('cx', Math.random() * (width - 2 * radius) + radius);
circle.setAttribute('cy', Math.random() * (height - 2 * radius) + radius);
circle.setAttribute('r', radius * ( 0.5 * Math.random() + 0.5) );
circle.setAttribute('fill', 'blue');
circle.setAttribute('stroke', '#555');

svg.appendChild(circle);
}

return svg;
}
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more