Member-only story
5 Steps To Render D3.js With React Functional Components
A complete guide on how to use D3 inside React

Data visualization is the graphical representation of information and data. It utilizes visual elements to present trends, outliers, and patterns in data. It is particularly efficient when the data is numerous, such as in a time series, which is a series of data points indexed in time order.
D3.js is a JavaScript library for visualizing data using web standards. D3 stands for “data-driven documents.” It binds arbitrary data to a Document Object Model (DOM) and then applies data-driven transformations to the document. We can use D3 to generate an HTML table from an array of numbers. Or we can use the same data to create an interactive SVG (Scalable Vector Graphics) bar chart with smooth transitions and interactions.
In a previous article, we noted that C3 allows us to build charts quickly without knowing all the complexity of D3. Using C3 to create a chart requires just a few lines of code. However, it takes extra effort to implement the same chart using D3 since you must consider the X and Y axes, each data point’s shape, size, and position, etc.
Why do we want to dive into the complexity and nitty-gritty details of D3?
Because D3 provides rich features to construct graphical representations. For a chart, D3 can customize every detail of axes, shapes, tooltips, texts, colors, and animation.
In this article, we are going to build the bubble image above as an example. We will use React for the working environment and create a svg
tag to host these orange and blue circles that are managed by D3.
5 Steps To Render D3 in React
React is a declarative, efficient, and flexible JavaScript library for building user interfaces. Both D3 and React are opinionated libraries that manipulate the DOM. Since we are using React for the working environment, D3 only manipulates the DOM in data visualization areas. For those D3-managed areas, we relinquish what React would offer in terms of performance and efficiency.
It takes five steps to render D3 in React:
- Build uncontrolled components.