Published
Edited
May 11, 2021
1 fork
Insert cell
Insert cell
Insert cell
chart = svg`<svg width="${data.layout.width}" height="${data.layout.height}" style="background-color: ${background_color}">
<style>
text {
font-family: sans-serif;
font-size: 10px;
}
.node {
stroke-linecap: round;
}
.link {
fill: none;
}
</style>

${ data.bundles.map(b => {
let d = b.links.map(l => `
M${ l.xt } ${ l.yt }
L${ l.xb-l.c1 } ${ l.yt }
A${ l.c1 } ${ l.c1 } 90 0 1 ${ l.xb } ${ l.yt+l.c1 }
L${ l.xb } ${ l.ys-l.c2 }
A${ l.c2 } ${ l.c2 } 90 0 0 ${ l.xb+l.c2 } ${ l.ys }
L${ l.xs } ${ l.ys }`
).join("");
return `
<path class="link" d="${ d }" stroke="${background_color}" stroke-width="5"/>
<path class="link" d="${ d }" stroke="${ color(b.id) }" stroke-width="2"/>
`;
})}

${ data.nodes.map(n => `
<path class="selectable node" data-id="${n.id}" stroke="black" stroke-width="8" d="M${ n.x } ${ n.y-n.height/2 } L${ n.x } ${ n.y+n.height/2 }"/>
<path class="node" stroke="white" stroke-width="4" d="M${ n.x } ${ n.y-n.height/2 } L${ n.x } ${ n.y+n.height/2 }"/>

<text class="selectable" data-id="${n.id}" x="${ n.x+4}" y="${ n.y-n.height/2-4 }" stroke="${background_color}" stroke-width="2">${ n.id }</text>
<text x="${ n.x+4}" y="${ n.y-n.height/2-4 }" style="pointer-events: none;">${ n.id }</text>
`)}

</svg>`
Insert cell
levelsAuto = d3.stratify()
.id(d => d["quien"])
.parentId(d => d["vinculoCon"])(dataloaded)
Insert cell
levelsAuto.find(d=> d.id == "maestra")
Insert cell
levelsAuto.find(d=> d.id == "maestra").parent
Insert cell
levels = d3.groups(dataloaded, d=>d["dia de confirmado"]).map((d,i)=>{
return d[1].map(e=>{
if(i){
return {
id : e.quien,
parents : [levelsAuto.find(d=> d.id == e.quien).parent.id]}
}else{
return {
id : e.quien}
}
})
})
Insert cell
levelsold = [
[{id: 'Chaos'}],
[
{id: 'Gaea', parents: ['Chaos']},
{id: 'Uranus'}
],
[
{id: 'Oceanus', parents: ['Gaea', 'Uranus']},
{id: 'Thethys', parents: ['Gaea', 'Uranus']},
{id: 'Pontus'},
{id: 'Rhea', parents: ['Gaea', 'Uranus']},
{id: 'Cronus', parents: ['Gaea', 'Uranus']},
{id: 'Coeus', parents: ['Gaea', 'Uranus']},
{id: 'Phoebe', parents: ['Gaea', 'Uranus']},
{id: 'Crius', parents: ['Gaea', 'Uranus']},
{id: 'Hyperion', parents: ['Gaea', 'Uranus']},
{id: 'Iapetus', parents: ['Gaea', 'Uranus']},
{id: 'Thea', parents: ['Gaea', 'Uranus']},
{id: 'Themis', parents: ['Gaea', 'Uranus']},
{id: 'Mnemosyne', parents: ['Gaea', 'Uranus']}
],
[
{id: 'Doris', parents: ['Oceanus', 'Thethys']},
{id: 'Neures', parents: ['Pontus', 'Gaea']},
{id: 'Dionne'},
{id: 'Demeter', parents: ['Rhea', 'Cronus']},
{id: 'Hades', parents: ['Rhea', 'Cronus']},
{id: 'Hera', parents: ['Rhea', 'Cronus']},
{id: 'Alcmene'},
{id: 'Zeus', parents: ['Rhea', 'Cronus']},
{id: 'Eris'},
{id: 'Leto', parents: ['Coeus', 'Phoebe']},
{id: 'Amphitrite'},
{id: 'Medusa'},
{id: 'Poseidon', parents: ['Rhea', 'Cronus']},
{id: 'Hestia', parents: ['Rhea', 'Cronus']}
],
[
{id: 'Thetis', parents: ['Doris', 'Neures']},
{id: 'Peleus'},
{id: 'Anchises'},
{id: 'Adonis'},
{id: 'Aphrodite', parents: ['Zeus', 'Dionne']},
{id: 'Persephone', parents: ['Zeus', 'Demeter']},
{id: 'Ares', parents: ['Zeus', 'Hera']},
{id: 'Hephaestus', parents: ['Zeus', 'Hera']},
{id: 'Hebe', parents: ['Zeus', 'Hera']},
{id: 'Hercules', parents: ['Zeus', 'Alcmene']},
{id: 'Megara'},
{id: 'Deianira'},
{id: 'Eileithya', parents: ['Zeus', 'Hera']},
{id: 'Ate', parents: ['Zeus', 'Eris']},
{id: 'Leda'},
{id: 'Athena', parents: ['Zeus']},
{id: 'Apollo', parents: ['Zeus', 'Leto']},
{id: 'Artemis', parents: ['Zeus', 'Leto']},
{id: 'Triton', parents: ['Poseidon', 'Amphitrite']},
{id: 'Pegasus', parents: ['Poseidon', 'Medusa']},
{id: 'Orion', parents: ['Poseidon']},
{id: 'Polyphemus', parents: ['Poseidon']}
],
[
{id: 'Deidamia'},
{id: 'Achilles', parents: ['Peleus', 'Thetis']},
{id: 'Creusa'},
{id: 'Aeneas', parents: ['Anchises', 'Aphrodite']},
{id: 'Lavinia'},
{id: 'Eros', parents: ['Hephaestus', 'Aphrodite']},
{id: 'Helen', parents: ['Leda', 'Zeus']},
{id: 'Menelaus'},
{id: 'Polydueces', parents: ['Leda', 'Zeus']}
],
[
{id: 'Andromache'},
{id: 'Neoptolemus', parents: ['Deidamia', 'Achilles']},
{id: 'Aeneas(2)', parents: ['Creusa', 'Aeneas']},
{id: 'Pompilius', parents: ['Creusa', 'Aeneas']},
{id: 'Iulus', parents: ['Lavinia', 'Aeneas']},
{id: 'Hermione', parents: ['Helen', 'Menelaus']}
]
]
Insert cell
Insert cell
dataloaded = FileAttachment("grilla de contagios - Sheet1@1.csv").csv({typed: true})
Insert cell
Insert cell
background_color = 'white'
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