Barplot, Streamgraph and hover effect

Dataviz logo representing a Bar chart.

This article is an addition to the barplot and Streamgraph sections of the gallery.

It dives into hover effects, and implements 2 different effects. If you want to learn about hover effects in general, there is a hover effect dedicated section in the gallery.

Now let's see how to highlight bars!

Useful links

Plot and code

Here is a code sandbox in case you want to jump straight into the code.

Note that the gallery provides an in-depth description of the process leading to a barplot. This page will just highlight the differences for the vertical version!

246810
2040608090Mark53Marion34Emily12Robert

Basic vertical barplot made with React and D3.js

How it works

There are several ways to implement a hover effect.

In this example, two charts are linked together using a shared state. This shared state keeps track of which group is currently highlighted. Both charts can update it via an updateHighlightedGroup function, and they also read from it through the highlightedGroup prop.

This approach is explained in detail in the hover effect section of the gallery!

Variation

Check those other barplot and stacked barplot that can interest you:

Picture of a horizontal barplot made with React and d3

Basic barplot

Most basic barplot built with React and d3

GIF of a data update on a React barplot

Barplot dataset transition

How to smoothly animate the transition between dataset

Picture of a stacked barchart made with react and d3

Horizontal Stacked Barplot

Represent group and subgroup values by stacking the data

Picture of a barplot made by the Economist

The Economist Barplot repro

Reproduction of a barplot made by The Economist

GIF of a streamgraph react component that supports hover effect

Streamgraph with hover effect

How to add a hover effect on a streamgraph to highlight a group

GIF of a streamgraph with multiple interactive features

Streamgraph application

Streamgraph with a slider to zoom on a time stamp and with interactive inline legends

Ranking

Contact

👋 Hey, I'm Yan and I'm currently working on this project!

Feedback is welcome ❤️. You can fill an issue on Github, drop me a message on Twitter, or even send me an email pasting yan.holtz.data with gmail.com. You can also subscribe to the newsletter to know when I publish more content!