apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.63k stars 19.61k forks source link

Sankey chart - Not able to control display order of nodes #9820

Closed spime-web closed 4 years ago

spime-web commented 5 years ago

General Questions

Issue Type

Issue Details

As per the https://github.com/apache/incubator-echarts/issues/4986, order of the nodes displayed in the Sankey chart will be based on the series.data. But the latest version (4.2.0) doesn't work as expected.

Expected Behavior

When below option is specified for Sankey charts, the order of nodes should be AAAAAAA, CCCCCCC and DDDDDD.

var data = [{"name":"AAAAAAA","value":7},
              {"name":"CCCCCCC","value":6},
              {"name":"DDDDDD","value":5},
              {"name":"EEEEEE","value":4},
              {"name":"FFFFFF","value":3},
              {"name":"BBBBBB","value":2}];
var links = [
            {"source":"DDDDDD","target":"EEEEEE","value":1},
            {"source":"CCCCCCC","target":"FFFFFF","value":1},
            {"source":"AAAAAAA","target":"BBBBBB","value":1},
            {"source":"AAAAAAA","target":"EEEEEE","value":1}]

myChart.setOption(option = {
    title: {
        text: 'Sankey Diagram'
    },
    tooltip: {
        trigger: 'item',
        triggerOn: 'mousemove'
    },
    series: [
        {
            type: 'sankey',
            data: data,
            links: links,
            focusNodeAdjacency: 'allEdges',
            itemStyle: {
                normal: {
                    borderWidth: 1,
                    borderColor: '#aaa'
                }
            },
            lineStyle: {
                normal: {
                    color: 'source',
                    curveness: 0.5
                }
            }
        }
    ]
});

Current Behavior

But the nodes are in different order as shown in the below image:

sankey-chart-actual

Online Example

Go to https://ecomfe.github.io/echarts-examples/public/editor.html?c=sankey-energy and replace the left panel code with the code snippet provided in the "Expected behavior" section and click Run.

Topics

Anything Else We Need to Know

A similar issue has been reported earlier (https://github.com/apache/incubator-echarts/issues/4986) but as that issue has been closed, I am creating a this issue.

Environment

spime-web commented 5 years ago

Hi,

It would be great if you could provide some rough idea on when the fix would be available.

Thanks & Regards, Bala

deqingli commented 4 years ago

Hi,

It would be great if you could provide some rough idea on when the fix would be available.

Thanks & Regards, Bala

Hi @spime-web, you can set layoutIterations = 0.