Skip to content
This repository was archived by the owner on Nov 7, 2018. It is now read-only.
This repository was archived by the owner on Nov 7, 2018. It is now read-only.

The position of node is wrong when node has a layer not be the last layer #138

Description

@natee

When a node has a 'layer' and it doesn't have a target node,the position will automatic move to the last layer . Actually, if I set a 'layer',why it didn't display belong to the layer?

The reason why I need to do this is that when I add some labels for each column(layer),the position all goes mess.

sankey data:

{"nodes":[{"layer":0,"name":"L0S0"},{"layer":0,"name":"L0S1"},{"layer":1,"name":"L1S2"},{"layer":1,"name":"L1S3"},{"layer":1,"name":"L1S4"},{"layer":2,"name":"L2S5"},{"layer":2,"name":"L2S6"},{"layer":3,"name":"L3S7"},{"layer":3,"name":"L3S8"}],"links":[{"source":0,"target":2,"value":3},{"source":4,"target":7,"value":1},{"source":0,"target":3,"value":1},{"source":1,"target":4,"value":4},{"source":2,"target":6,"value":2},{"source":4,"target":5,"value":2},{"source":2,"target":8,"value":1}]}

Here is default display: http://output.jsbin.com/huvujefezo/2 , the layer 2 and layer 1 moved to layer 3 position.

So I chaned the source code,like this:

function scaleNodeBreadths(kx) {
        nodes.forEach(function(node) {
            if(node.layer){
                node.x = node.layer
            }
            node.x *= kx;

        });
    }

After this,the chart display as what I want.
http://output.jsbin.com/kisuwi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions