桑基图节点从低到高排序

Sort sankey chart nodes from low to high

const dataSeries = [{
        "name": "Containerburg"
      },
      {
        "name": "HTCont1"
      },
      {
        "name": "Kranstrom"
      },
      {
        "name": "Wago3"
      },
      {
        "name": "Wago5"
      },
      {
        "name": "Wago2"
      },
      {
        "name": "Heinrich Campus "
      },
      {
        "name": "SubCont1"
      },
      {
        "name": "Heinrich Campus"
      }
    ];

    const seriesLinks = [{
        "source": "Containerburg",
        "target": "HTCont1",
        "value": 20.874000000000024
      },
      {
        "source": "Kranstrom",
        "target": "Wago3",
        "value": 44.253999999999905
      },
      {
        "source": "Containerburg",
        "target": "Wago5",
        "value": 126.2489999999998
      },
      {
        "source": "Kranstrom",
        "target": "Wago2",
        "value": 151.63200000000006
      },
      {
        "source": "Heinrich Campus ",
        "target": "Kranstrom",
        "value": 195.88599999999997
      },
      {
        "source": "Containerburg",
        "target": "SubCont1",
        "value": 745.3199999999997
      },
      {
        "source": "Heinrich Campus",
        "target": "Containerburg",
        "value": 892.4429999999995
      }
    ];

option = {
  series: [
    {
      type: "sankey",
      data: dataSeries,
      links: seriesLinks,
    },
  ],
};

Apache ECharts 自动将它从高值排序到低值(SubCont1 < HTCont1),但我想反转排序,以便 HTCont1 在顶部,SubCont1 在底部。

这是一个可以粘贴到 https://echarts.apache.org/examples/en/editor.html or can be viewed here http://jsfiddle.net/y7emL1np/

的工作示例

您可以使用 layoutIterations 参数来实现此目的。将其设置为 0(零)会禁用所有基于 weight/value 的布局调整。 http://jsfiddle.net/yj5u9htb/

    var option = {
      series: [{
        type: "sankey",
        data: dataSeries,
        links: seriesLinks,
        layoutIterations: 0
      }]
    };

    myChart.setOption(option);
series: [{
  // ...
  layoutIterations: 0,
  // ...
}]

您禁用了布局优化,现在您需要change order by yourself :)

const seriesLinks = [{
  // ...
}].reverse() // <--- this

看了一下fixed example: