You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2019/11/14 08:22:29 UTC

[GitHub] [incubator-echarts] peterviergutz commented on issue #11637: Sankey chart ignores edges with source or target null

peterviergutz commented on issue #11637: Sankey chart ignores edges with source or target null
URL: https://github.com/apache/incubator-echarts/issues/11637#issuecomment-553778211
 
 
   Dug a bit on this one, the reason is that edges with no target or source are ignored here: 
   
   https://github.com/apache/incubator-echarts/blob/1bdb91aec185937ade601ccb58da13d382fc340d/src/data/Graph.js#L160
   
   and node size is calculated from incoming and outgoing edges here:
   
   https://github.com/apache/incubator-echarts/blob/fcfa95012ca561becab607b065a62b5f87220801/src/chart/sankey/sankeyLayout.js#L86
   
   A quick fix might involve summing the values of nodes with no connection in the latter function like this 
   
   ```js
   function computeNodeValues(nodes, seriesModel) {
   
     var nodeSizes = {}
     seriesModel.option.links.filter(link => {
         return !link.source || !link.target
     }).reduce(function (nodeSizes, node) {
         if(!nodeSizes[node.source]) nodeSizes[node.source] = 0
         nodeSizes[node.source] += node.value
         return nodeSizes
     }, nodeSizes)
   
     zrUtil.each(nodes, function (node) {
       var extra = nodeSizes[node.id] || 0
       var value1 = sum(node.outEdges, getEdgeValue);
       var value2 = sum(node.inEdges, getEdgeValue);
       var value = Math.max(value1, value2);
       node.setLayout({
         value: value + extra
       }, true);
     });
   }
   ```
   
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org