为什么highcharts sankey chart有时会将多个节点名称相同但Id不同的节点合并为一个并隐藏线条?

Why does highcharts sankey chart sometimes combine multiple nodes with same node name but different Id into one and hide the lines?

对于下面的片段,

const data = [
  {"from":"step2_FRANCE","to":"step3_SPAIN","weight": 2},
  {"from":"step3_SPAIN","to":"step4_PORTUGAL","weight":2},
  {"from":"step2_PORTUGAL","weight":1, to: "step3_SPAIN" },
  {"from":"step2_FRANCE","weight":1},
  {"from":"step2_SPAIN","weight":1},
  {"from":"step2_ENG","weight":1},
  {"from":"step2_PORTUGAL","weight":1, to: "step3_SPAIN"},
  {"from":"step2_FRANCE","weight":1},
];

const nodes = [
  {"id":"step2_PORTUGAL","name":"Portugal","column":1, "color":"#ede042"},
  {"id":"step2_FRANCE","name":"France","column":1, "color":"#cb65dc"},
  {"id":"step2_SPAIN","name":"Spain","column":1,, "color":"#6493f1"},
  {"id":"step2_ENG","name":"England", "column":1, "color":"#6ed4eb"},
  {"id":"step3_SPAIN","name":"Spain","column":2, "color":"#6493f1"},
  {"id":"step4_PORTUGAL","name":"Portugal","column":3, "color":"#ede042"}
];


Highcharts.chart('container', {
  title: {
    text: 'Highcharts Sankey Diagram'
  },
  accessibility: {
    point: {
      valueDescriptionFormat: '{index}. {point.from} to {point.to}, {point.weight}.'
    }
  },
  series: [{
    data,
    nodes,
    type: 'sankey',
    name: 'Sankey demo series'
  }]
});

我得到这样的输出: 我期待:

  1. 第 1 列中的法国、葡萄牙、西班牙和英格兰(带有 step2_.. 的 ID)
  2. 第 2 列中的西班牙(带有 step3_.. 的 ID)
  3. 第 3 列中的葡萄牙(带有 step4_.. 的 ID)

nodes 选项中,列号和名称也存在。

如果我注释掉 Step2.. 中的一个节点,我会得到一个部分正确的图表。

const nodes = [
{"id":"step2_PORTUGAL","name":"Portugal","column":1,"color":"#ede042"},
// {"id":"step2_FRANCE","name":"France","column":1, "color":"#cb65dc"},
{"id":"step2_SPAIN","name":"Spain","column":1, "color":"#6493f1"},
{"id":"step2_ENG","name":"England", "column":1, "color":"#6ed4eb"},
{"id":"step3_SPAIN","name":"Spain","column":2, "color":"#6493f1"}, 
 {"id":"step4_PORTUGAL","name":"Portugal","column":3, "color":"#ede042"}
];

我无法理解为什么图表会这样。我猜我传递的方式有问题 data/nodes。如果有人能指出正确的方向,我将不胜感激。

在您的节点选项中从 0 开始设置列可以解决问题。

演示:https://jsfiddle.net/BlackLabel/fkshbmdv/

const nodes = [{
    "id": "step2_PORTUGAL",
    "name": "Portugal",
    //"column": 0,
    "color": "#ede042"
  }, ...
];

在这种情况下实际上不需要使用列 属性:https://jsfiddle.net/BlackLabel/n53Ljcgd/

API: https://api.highcharts.com/highcharts/series.sankey.nodes.column