Skip to content

Add property to define size of a node in Sankey Chart #11644

@peterviergutz

Description

@peterviergutz

What problem does this feature solve?

In the current implementation the node size in a Sankey chart is determined by the bigger number of incoming or outgoing edges. Our case involves a node size that is actually bigger than the connections between the nodes:

expected

What does the proposed API look like?

An optional new property size on the nodes' properties could offer a clean option to define the node's size

{
  "nodes": [
    {
      "name": "a1",
      "size": 100
    }
...

To get the node's size in the chart could then be determined by whatever is bigger: the sum of incoming and outgoing edges or the node's defined size in

https://github.com/apache/incubator-echarts/blob/fcfa95012ca561becab607b065a62b5f87220801/src/chart/sankey/sankeyLayout.js#L86

function computeNodeValues(nodes) {
  zrUtil.each(nodes, function (node) {
    var value1 = sum(node.outEdges, getEdgeValue);
    var value2 = sum(node.inEdges, getEdgeValue);
    var value = Math.max(value1, value2, node.size); // <-- node.size here
    node.setLayout({
      value: value
    }, true);
  });
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions