Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph Layout with node id=0 causes Cannot set property dataIndex of undefined #10485

Closed
sylsaint opened this issue May 16, 2019 · 2 comments · Fixed by OpenTMI/opentmi-default-gui#32 or DeviaVir/zenbot#2011 · May be fixed by dyna-dot/iClient-JavaScript-s#1
Labels
bug en This issue is in English topic: graph

Comments

@sylsaint
Copy link

Version

4.2.1

Reproduction link

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

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.

@echarts-bot
Copy link

echarts-bot bot commented May 16, 2019

Hi! We've received your issue and please be patient to get responded. 🎉
The average response time is expected to be within one day for weekdays.

In the meanwhile, please make sure that you have posted enough image to demo your request. You may also check out the API and chart option to get the answer.

Have a nice day! 🍵

@echarts-bot echarts-bot bot added bug en This issue is in English pending We are not sure about whether this is a bug/new feature. waiting-for-help labels May 16, 2019
@Ovilia Ovilia added topic: graph and removed pending We are not sure about whether this is a bug/new feature. waiting-for-help labels May 17, 2019
@Ovilia
Copy link
Contributor

Ovilia commented May 27, 2019

Technically speaking, id of data should be string values rather than number values. Try changing id and those in target and source to be string will remove the error in your case.
But I think it's reasonable to improve the source code to prevent problems like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug en This issue is in English topic: graph
Projects
None yet
2 participants