You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by GitBox <gi...@apache.org> on 2019/05/16 08:38:49 UTC

[GitHub] [incubator-echarts] sylsaint opened a new issue #10485: Graph Layout with node id=0 causes Cannot set property dataIndex of undefined

sylsaint opened a new issue #10485: Graph Layout with node id=0 causes Cannot set property dataIndex of undefined
URL: https://github.com/apache/incubator-echarts/issues/10485
 
 
   ### Version
   4.2.1
   
   ### Reproduction link
   [https://jsfiddle.net/Lr6vw89u/](https://jsfiddle.net/Lr6vw89u/)
   
   ### Steps to reproduce
   1.  set nodes = [{
           "id"                 : 1,
           "name"               : "root node",
       }, {
           "id"                 : 0,
           "name"               : "node a",
       }]
   2. Cannot set property dataIndex of undefined happens
   
   ### What is expected?
   Graph layouts as normal
   
   ### What is actually happening?
   Echarts throw errors:  Cannot set property dataIndex of undefined
   
   ---
   This is the bug of file: [https://github.com/apache/incubator-echarts/blob/4.2.1/src/data/Graph.js#L104](https://github.com/apache/incubator-echarts/blob/4.2.1/src/data/Graph.js#L104) 
   
   If node.id = 0, but the node's dataIndex is not 0, According to the current logic,  id will be set to dataIndex. Then, if there is already a node with id equal to the dataIndex has been added to the Graph, Node with id equal to 0 will not be added to the Graph. The actual count of nodes will be reduced in the Graph.
   
   **PS**: I don't think using dataIndex as id is a good idea, there are always chance of collisions, e.g.  if I change the second id from 0 to false,  error also happens. Please consider unique id as alternative.
   
   <!-- This issue is generated by echarts-issue-helper. DO NOT REMOVE -->
   <!-- This issue is in English. DO NOT REMOVE -->

----------------------------------------------------------------
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: dev-unsubscribe@echarts.apache.org
For additional commands, e-mail: dev-help@echarts.apache.org