Domanda

I am trying to make the Bilevel Partition in D3 work with log scale.

However, it doesn't seem to be working properly.

I have specified a log scale for angles:

    var angle1 = d3.scale.log()
        .base(2.0)
        .domain([0, 2 * Math.PI])
        .range([root.x, root.x + root.dx]);

However, this applies only when the angles are recalculated on zoom.

I have tried to modify the original partition scale, but with no success.

Any hints appreciated. See example code at the link below.

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

enter image description here

È stato utile?

Soluzione

The partition layout in D3 sums up the values of the leaf nodes in order to calculate layout of the the elements with children. By definition of layout it should word like that. Therefore, only leaf nodes values are taken into account when calling layout.nodes(). Hence, only leaf nodes can be scaled (for example as log(count + 1)). However, non-leaf nodes will be represented sums of underlying values. The only option for all nodes to scale logarithmically would be to write a new layout, that would take into account a value at each node, and not sum up the values of the children.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top