This post describes how to build a button that changes the input dataset of a barplot. You need to understand how to draw a basic barplot first. It is a good way to understand the enter()
and exit
functions of d3. This example works with d3.js v4
and v6
update()
function also update the X and Y axis. Thus, number of groups and Y axis range can differ from one dataset to the other.