Public
Edited
Apr 4
Insert cell
Insert cell
d3 = require("d3@5") //D3v5
Insert cell
// 4 círculos, el componente g agrupa todos los elementos
html`<svg width="760" height="140">
<g transform="translate(70, 70)">
<circle r="40"></circle>
<circle r="40" cx="120"></circle>
<circle r="40" cx="240"></circle>
<circle r="40" cx="360"></circle>
<circle r="40" cx="480"></circle>
</g>
</svg>`
Insert cell
Insert cell
// Descomentá este código para ver el efecto
/*
d3.selectAll('circle')
.style('fill', 'orange')
.attr('r', function() {
return 10 + Math.random() * 40;
});
*/
Insert cell
Insert cell
// Descomentá este código para ver el efecto
/*
d3.select('circle')
.style('fill', 'orange')
.attr('r', function() {
return 10 + Math.random() * 40;
});
*/
Insert cell
Insert cell
Insert cell
Insert cell
html`<svg width="760" height="140">
<g class="item" transform="translate(70, 70)">
<circle r="40" style="opacity:1.0;fill:red;" />
</g>
<g class="item" transform="translate(190, 70)">
<circle r="40" style="opacity:1.0;fill:red;" />
</g>
<g class="item" transform="translate(310, 70)">
<circle r="40" style="opacity:1.0;fill:red;" />
</g>
</svg>`
Insert cell
Insert cell
d3.selectAll('g.item') // Selecciono grupos de clase item
.append('text')
.text(function(d, i) {
return i + 1;
});
Insert cell
Insert cell
html`<svg width="760" height="140">
<g class="iteminsert" transform="translate(70, 70)">
<circle r="40" style="opacity:0.5;fill:red;" />
</g>
<g class="iteminsert" transform="translate(190, 70)">
<circle r="40" style="opacity:0.5;fill:red;" />
</g>
<g class="iteminsert" transform="translate(310, 70)">
<circle r="40" style="opacity:1.0;fill:red;" />
</g>
</svg>`
Insert cell
d3.selectAll('g.iteminsert')
.insert('text', 'circle')
.text(function(d, i) {
return i + 1;
});
Insert cell
Insert cell
html`<svg width="760" height="140">
<g class="itemremove" transform="translate(70, 70)">
<circle r="40" style="opacity:1.0;fill:red;" />
</g>
<g class="itemremove" transform="translate(190, 70)">
<circle r="40" style="opacity:1.0;fill:red;" />
</g>
<g class="itemremove" transform="translate(310, 70)">
<circle r="40" style="opacity:1.0;fill:red;" />
</g>
</svg>`
Insert cell
d3.select('g.itemremove') // Remuevo el primero
.remove();
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