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.
Important note: This example does not update
the X and Y axis, it works only if the 2 datasets have the same groups
and same Y range. See
here for an upgraded
version. This example works with d3.js v4
and
v6
buttons
in the html part. When you click
the button, a function called update()
is
triggered.
update()
function updates the value of the
3 groups