Published
Edited
Feb 10, 2019
1 fork
1 star
Insert cell
Insert cell
chart = {
const root = tree(d3.hierarchy(data)
.sort((a, b) => (a.height - b.height) || a.data.name.localeCompare(b.data.name)));

const svg = d3.select(DOM.svg(width, width))
.style("width", "100%")
.style("height", "auto")
.style("padding", "8px")
.style("box-sizing", "border-box")
.style("font", "10px sans-serif");
const g = svg.append("g");
const link = g.append("g")
.attr("fill", "none")
.attr("stroke", "#161616")
.attr("stroke-opacity", 0.2)
.attr("stroke-width", 1.5)
.selectAll("path")
.data(root.links())
.enter().append("path")
.attr("d", d3.linkRadial()
.angle(d => d.x)
.radius(d => d.y));
const node = g.append("g")
.attr("stroke-linejoin", "round")
.attr("stroke-width", 3)
.selectAll("g")
.data(root.descendants().reverse())
.enter().append("g")
.attr("transform", d => `
rotate(${d.x * 180 / Math.PI - 90})
translate(${d.y},0)
`);
node.append("circle")
.attr("stroke", d => d.children ? "#34C97C" : "#161616")
.attr("fill",d => d.children ? "#34C97C" : "#161616")
.attr("stroke-width", d=> d.children ? 2 : 1)
.attr("r", d => d.children ? 3:2);
node.append("text")
.attr("dy", "0.31em")
.attr("x", d => d.x < Math.PI === !d.children ? 8 : -8)
.attr("text-anchor", d => d.x < Math.PI === !d.children ? "start" : "end")
.attr("transform", d => d.x >= Math.PI ? "rotate(180)" : null)
.style("font", d => d.children ? "10px sans-serif": "11px sans-serif")
.style("font-weight", d => d.children ? "bold": "normal")
.attr("fill", d => d.children ? "#161616": "#161616")
.text(d => d.data.name)
.filter(d => d.children)
.clone(true).lower()
.attr("stroke", "white")
.attr("stroke-width", 4);
document.body.appendChild(svg.node());

const box = g.node().getBBox();

svg.remove()
.attr("width", box.width)
.attr("height", box.height)
.attr("viewBox", `${box.x} ${box.y} ${box.width} ${box.height}`);

return svg.node();
}
Insert cell
data = ({
name: 'Solaris Inc.',
children: [
{
name: 'Oce',
children: [
{name: 'IT Department'},
{name: 'HR Department'},
{name: 'Sales'},
{name: 'Operations'},
{name: 'Logistics'},
{name: 'Administration'},
{name: 'Marketing'},
{name: 'Sales'},
{name: 'Operations'},
{name: 'Logistics'}
]
},
{
name: 'Offices',
children: [
{name: 'Legal office'},
{name: 'Sales office'},
{name: 'IT Office'},
{name: 'Marketing office'},
{name: 'Sales office (London)'},
{name: 'Legal office'},
{name: 'Sales office'},
{name: 'IT Office'},
{name: 'Marketing office'},
{name: 'Sales office (London)'}
]
},
{
name: 'Procedures',
children: [
{name: 'Password management (v.1)'},
{name: 'Breach management (v.2)'},
{name: 'Using of IT devices (v.3)'},
{name: 'The exercise of rights of data subjects (v.3)'},
{name: 'Password management (v.1)'},
{name: 'Breach management (v.2)'},
{name: 'Using of IT devices (v.3)'},
{name: 'The exercise of rights of data subjects (v.3)'}
]
},
{
name: 'Joint controllers',
children: [
{name: 'Flyer Ltd.'},
{name: 'Samsaga Inc.'},
{name: 'Apple Inc.'},
{name: 'Microsoft Inc.'},
{name: 'IBM Co.'},
{name: 'Flyer Ltd.'},
{name: 'Samsaga Inc.'},
{name: 'Apple Inc.'},
{name: 'Microsoft Inc.'},
{name: 'IBM Co.'}
]
},
{
name: 'Representatives',
children: [
{name: 'Flyer Ltd.'},
{name: 'Samsaga Inc.'},
{name: 'Apple Inc.'},
{name: 'Microsoft Inc.'},
{name: 'IBM Co.'},
{name: 'Flyer Ltd.'},
{name: 'Samsaga Inc.'},
{name: 'Apple Inc.'},
{name: 'Microsoft Inc.'},
{name: 'IBM Co.'}
]
},
{
name: 'Processors',
children: [
{name: 'Flyer Ltd.'},
{name: 'Samsaga Inc.'},
{name: 'Apple Inc.'},
{name: 'Microsoft Inc.'},
{name: 'IBM Co.'},
{name: 'Flyer Ltd.'},
{name: 'Samsaga Inc.'},
{name: 'Apple Inc.'},
{name: 'Microsoft Inc.'},
{name: 'IBM Co.'}
]
},
{
name: 'Sys. admins',
children: [
{name: 'Andrea Garganico'},
{name: 'Giovanni Storti'},
{name: 'Luca Semplicini'},
{name: 'Eleonora Benedetti'},
{name: 'Samuele Piombini'},
{name: 'Andrea Garganico'},
{name: 'Giovanni Storti'},
{name: 'Luca Semplicini'},
{name: 'Eleonora Benedetti'},
{name: 'Samuele Piombini'},
]
},
{
name: 'DPOs',
children: [
{name: 'Luisa Freddi'}
]
},
{
name: 'Privacy contacts',
children: [
{name: 'Andrea Sartori'},
{name: 'Luca Bonora'},
{name: 'Manuel Pezzi'},
{name: 'Andrea Sartori'},
{name: 'Luca Bonora'},
{name: 'Manuel Pezzi'}
]
},
{
name: 'Asset',
children: [
{name: 'Asset 01'},
{name: 'Asset 02'},
{name: 'Asset 03'},
{name: 'Asset 04'},
{name: 'Asset 05'},
{name: 'Asset 06'},
{name: 'Asset 07'},
{name: 'Asset 08'},
{name: 'Asset 09'},
{name: 'Asset 10'},
{name: '...e altri 30'},
]
},
{
name: 'Proc. activities',
children: [
{name: 'Acquisition, consultation, storage of CV'},
{name: 'Employees technical support'},
{name: 'Absences management'},
{name: 'Mail marketing'},
{name: 'Buying assistance'},
{name: 'Employees technical support'},
{name: 'Acquisition, consultation, storage of CV'},
{name: 'Absences management'},
],
},
{
name: 'Privacy policies',
children: [
{name: 'Employes'},
{name: 'Customers'},
{name: 'Providers'},
{name: 'Consultants'},
{name: 'Employes'},
{name: 'Customers'},
{name: 'Providers'},
{name: 'Consultants'},
],
},
{
name: 'DPIA',
children: [
{name: 'Employes'},
{name: 'Customers'},
{name: 'Providers'},
{name: 'Consultants'},
{name: 'Employes'},
{name: 'Customers'},
{name: 'Providers'},
{name: 'Consultants'},
],
},
{
name: 'Data breaches',
children: [
{name: 'Employes'},
{name: 'Customers'},
{name: 'Providers'},
{name: 'Consultants'},
{name: 'Employes'},
{name: 'Customers'},
{name: 'Providers'},
{name: 'Consultants'},
],
},
]
})
Insert cell
width = 800
Insert cell
radius = width / 2
Insert cell
tree = d3.cluster().size([2 * Math.PI, radius - 100])
Insert cell
d3 = require("d3@5")
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