D3.js
- frontend
- in current work
I discovered D3.js because I wanted to build visualizations that didn't look like every other dashboard on the internet. Chart.js and Recharts are fine when you want a bar chart in five minutes, but the moment you need something that actually thinks differently about data (force-directed graphs, custom transitions, layouts that don't exist in any library's menu), D3 is where you end up.
The learning curve is real. D3 doesn't hand you components. It hands you SVG primitives, scales, and a data-binding model that takes a while to click. I spent a lot of frustrated evenings before things started making sense. But once they did, it became the tool I reach for constantly. I used it to build the network graph on this very portfolio site, the data visualizations in LoS, market maps for the Companies Summary Generator, and player analytics charts in Gamers Career Matching.
The tradeoff is clear: D3 is verbose and demands you understand what's happening at every level. But for someone who wants full control over every pixel and transition, that's not a bug. It's the whole point.
const simulation = d3
.forceSimulation<NetworkNode>(nodes)
.force(
'link',
d3
.forceLink<NetworkNode, NetworkLink>(links)
.id((d) => d.id)
.distance((d) => (d.type === 'project-tool' ? 70 : 90))
.strength(0.25)
)
.force(
'charge',
d3
.forceManyBody<NetworkNode>()
.strength((d) => (d.type === 'project' ? -260 : -160))
.distanceMax(360)
)
// Pull everything gently towards the middle, harder vertically, so the layout
// comes out about as wide as the box it has to fit in.
.force('x', d3.forceX<NetworkNode>(0).strength(0.012))
.force('y', d3.forceY<NetworkNode>(0).strength(0.06 * (size().width / size().height)))
.force('labels', forceLabelCollide())
.velocityDecay(0.35)
.stop();