Accepted answer

Since the function is being called with the button's ID...


The task here is relatively simple.

First, set an array with all the IDs:

var ids = ["all", "region", "Change", "change_vs_net_value", "assets_on_map"];

Then, loop through it calling myBubbleChart.switchMode() function. Here is a very simple way, using d3.timeout, to call the function every 3 seconds (and changing the buttons appearance as well):

var index = 0;
d3.interval(function() {
    myBubbleChart.switchMode(ids[(index++) % 5])
    d3.selectAll(".button").classed("active", function(_, i) {
        return i === index % 5 - 1;
}, 3000)

Here is the demo bl.ocks:

Related Query