This document describes how to build a stacked barplot with subgroup highlighting available on hover. It follows the previous basic stacked barplot. Main stacked barchar caveats is that subgroups can be hard to compare since not aligned. Highlighting one allows to counter balance this issue. This example works with d3.js v4
and v6
d3.select(this.parentNode).datum().key
. Then it is easy to change the opacity of all rects to something low, and highlight the selected subgroup with a higher opacity.