Public
Edited
Nov 30, 2020
Insert cell
Insert cell
Insert cell
network = {
const links = data.links.map(d => Object.create(d));
const nodes = data.nodes.map(d => Object.create(d));

const simulation = d3.forceSimulation(nodes)
.force("center", d3.forceCenter().x(width/2).y(height/2))
.force("link", d3.forceLink(links).id(d => d.id))
.force("charge", d3.forceManyBody().strength(-edgelength))
.force("x", d3.forceX())
.force("y", d3.forceY());

const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height])
.style("font", "14px sans-serif");
// link attributes
const link = svg.append("g")
.attr("fill", "none")
.selectAll("path")
.data(links)
.join("path")
.attr("class", "tooltip")
.attr("stroke", "green")
.attr("stroke-width", d => 2*node_ff*Math.sqrt(d.n))
.attr("stroke-opacity", 0.25)
.attr("data-tippy-content", d => `${d.s} ↔ ${d.t}<br>${d.n} co-occurrences`)

// node attributes
const node = svg.append("g")
.attr("fill", "currentColor")
.attr("stroke-linecap", "round")
.attr("stroke-linejoin", "round")
.selectAll("g")
.data(nodes)
.join("g")
.call(drag(simulation));

node.append("circle")
.attr("class", "tooltip")
.attr("stroke", "none")
// .attr("stroke-width", 2)
.attr("r", d => node_ff*Math.sqrt(d.n))
.attr("data-tippy-content", d => `${d.id}<br>${d.n} issues`)

node.append("text")
.attr("x", d => 15 + 0.6*node_ff*Math.sqrt(d.n))
.attr("y", "0.35em")
.text(d => d.id)
.clone(true).lower() // background shadow effect
.attr("fill", "none")
.attr("stroke", "white")
.attr("stroke-width", 4);

simulation.on("tick", () => {
link.attr("d", linkArc);
node.attr("transform", d => `translate(${d.x},${d.y})`);
});

invalidation.then(() => simulation.stop());

return svg.node();
}
Insert cell
Insert cell
height = 800
Insert cell
edgelength = 3500
Insert cell
radius_of_curvature = 100
Insert cell
node_ff = 2
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
d3 = require("d3@6")
Insert cell
tippy = require("tippy.js")
Insert cell
import { paretochart } from "@caocscar/jira-root-causes-pareto-chart"
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