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
Visit the tooltip section of the gallery to understand the general logic behind tooltip.
Here, the tricky part is to recover the subgroup name. The trick is to use 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.