Tactician Jenro
Tactician Jenro

Reputation: 89

D3.js Bilevel Partition - initial chart load zoomed on slice

I'd like to know if there's a way to start a D3.js Bilevel Partition zoomed in on a slice, instead of on the default where all values are shown. Is this possible?

Bilevel Partition: http://bl.ocks.org/mbostock/5944371

A possible solution is to write some code that automatically clicks one of the slices.

Another backup solution is to create separate charts instead - one with just the data in the zoomed slice and a separate button that loads the second chart.

Or instead there's an update button, where the zoomed in slices are the only data present at first, and by clicking that button the rest of the data are added. (How to implement this though?)

Upvotes: 2

Views: 161

Answers (1)

Cyril Cherian
Cyril Cherian

Reputation: 32327

Algo for "A possible solution is to write some code that automatically clicks one of the slices."

This will select the node you wish like this:

  path[0].every(function(p){
    var d = d3.select(p).data();
    //put the name of the node you wish to zoom on i have put "Arrays"
    if (d[0].name == "Arrays"){
      var k = d[0];
      zoomIn(k);
      return false;
    }
    return true;
  });

Full working code here

Hope this helps!

Upvotes: 1

Related Questions