Published
Edited
Jan 5, 2022
1 fork
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data_nested2 = ({
name: "participants",
children: [
{
name: "toutes les éditions",
children: [ { name : "2019, 2020, 2021", weight: 81 }]
},
{
name: "2 éditions",
children: [
{ name : "2019, 2020", weight: 64 },
{ name : "2019, 2021", weight: 45 },
{ name : "2020, 2021", weight: 180 },
]
},
{
name: "une édition",
children: [
{ name : "2019", weight: 441 },
{ name : "2020", weight: 475 },
{ name : "2021", weight: 928 },
]
},
]
});
Insert cell
colorItem = function(item) {
const colors = {
"2019, 2020, 2021": "#fcbf49",
"2019, 2020": "#bbdefb",
"2019, 2021": "#64b5f6",
"2020, 2021": "#2196f3",
"2019": "#ffcad4",
"2020": "#f4acb7",
"2021": "#9d8189",
};
return colors[item];
}
Insert cell
function colorHierarchy(hierarchy) {
if(hierarchy.depth >= 1){
hierarchy.color = colorItem(hierarchy.data.name);
}
if(hierarchy.children) {
hierarchy.children.forEach( child => colorHierarchy(child))
}
}
Insert cell
Insert cell
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