D3.js
D3.js is a JavaScript library for custom data visualizations, which I use when ready-made charts aren't enough.
How I use D3.js
It binds data to SVG elements on the page, so the same numbers can become maps, network diagrams or an entirely new kind of chart.
You get a view built for your data rather than a template: say, a map with figures by municipality or a diagram of connections, with zooming, filtering and tooltips on hover. It takes more work than a standard chart, so I only suggest it when it shows something a regular chart can't.
When I use it, I rely on scales and axes to turn values into pixels, geographic projections for maps and transitions when data changes; in React, D3 usually does the math while React renders the elements. I don't have a portfolio project built on D3.js, so I count it among the tools I use less often.
For standard charts like monthly revenue I reach for Chart.js first, since it's quicker to build, and keep D3.js for special cases.
Frequently asked questions about D3.js
What is D3.js?
D3.js is an open-source JavaScript library that binds data to page elements, usually SVG, and turns them into visualizations. Instead of ready-made chart types, it provides building blocks like scales, axes, map projections and transitions, so almost any view can be drawn.
D3.js or Chart.js: which should I use?
For standard charts like line, bar and pie, Chart.js is quicker and simpler. D3.js is the pick when you need a fully custom or unusual view, such as an interactive map or a network of connections, at the cost of more code and build time.
Do you build interactive visualizations with D3.js?
I can, but I use D3.js less often and don't have a portfolio project built on it. For most dashboards Chart.js is enough, and I suggest D3.js when the data calls for a view a ready-made chart can't provide.