Area Chart using React.js d3.js & TypeScript with the help of d3-brush for interaction

Eli Elad Elrom
Master React
Published in
7 min readAug 1, 2021


To create brush interactivity of the mouse following the plotted data there is d3 has an API d3-brush that can help us. In this tutorial, I will show you how to work with thed3-brushto zoom into a specific date.

You can see the final result of this tutorial below;

Setting up your project

I will be using CRA (SPA) using the MHL template to get TS, SCSS, formatting, templates, linting, etc.

$ yarn create react-app area-brush --template must-have-libraries

Add d3, d3-cloud and types;

$ yarn add d3 @types/d3


A good place to start when working with charts is from the data. The data is made out of two metrics: date, value values.



To creating the components we will be using my templates to speed up development;

$ npx generate-react-cli component Brush --type=d3WidgetComponent$ npx generate-react-cli component ChartWidget --type=d3Widget