You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "zshtxwd (via GitHub)" <gi...@apache.org> on 2023/12/14 02:20:13 UTC
[I] [Feature] Specify Node Relationships in Graph using "id" Attribute [echarts]
zshtxwd opened a new issue, #19401:
URL: https://github.com/apache/echarts/issues/19401
### What problem does this feature solve?
In the graph component, it is necessary to add an "id" attribute to each element in the data, and then use this "id" to establish connections in the "links" through the "target" and "source" attributes.
When working with the graph, a unique identifier is needed to handle cases where nodes have the same name. While the ECharts documentation mentions that the "links" support using "name" and the index of data, using "name" may lead to situations with identical names, and using the index is not convenient when dealing with dynamic data.
I propose using an "id" to specify nodes and establish connections through the "links." In fact, ECharts already supports using "id," but this is not explicitly documented. It's important to note that the "id" cannot be a number; it must be a string. If it's a number, ECharts recognizes it as a data index.
You can then use these "id" values in the "links," where the "target" and "source" values should be the same as the "id" set in the data.
I will provide an example below. If this is not a bug, I suggest documenting this feature. If it is a bug, I hope this functionality can be made available in the next release.
### What does the proposed API look like?
### example
```JavaScript
data: [
{ name: '李白', category: '亲人', id: '1' },
{ name: '杜甫', category: '亲人', id: '2' },
{ name: '李白', category: '租户', id: '3' },
{ name: '王之涣', category: '租户', id: '4' },
{ name: '王之涣', category: '亲人', id: '5' },
{ name: '杜甫', category: '亲人', id: '6' }
],
links: [
{ source: '4', target: '5', value: '夫妻' },
{ source: '2', target: '3', value: '租赁' },
{ source: '3', target: '4', value: '亲人' },
{ source: '1', target: '5', value: '亲人' },
{ source: '1', target: '2', value: '亲人' },
{ source: '4', target: '6', value: '亲人' },
]
```

--
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.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [I] [Feature] Specify Node Relationships in Graph using "id" Attribute [echarts]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #19401:
URL: https://github.com/apache/echarts/issues/19401#issuecomment-6089347201
This issue has been automatically marked as stale because it did not have recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [I] [Feature] Specify Node Relationships in Graph using "id" Attribute [echarts]
Posted by "Nicooow (via GitHub)" <gi...@apache.org>.
Nicooow commented on issue #19401:
URL: https://github.com/apache/echarts/issues/19401#issuecomment-2401784089
I'm reopening this issue as I encountered the same problem with a Sankey diagram.
**However, for Sankey diagrams, the id is prioritized over the name, making this technique ineffective!**
The solution is to use a formatter: as shown [here](https://echarts.apache.org/examples/en/editor.html?c=line-simple&code=CYQwLiAEC8kNoChKQN6QHYgLYFMBckA5IHLmgvm6EA0kAxuDgOYD2ATgJ4GGBNcoF1ylkAlsA4BGQpAC-FJKgzZ8RQDrmgalc-tMAxbsiPPoI4AmMZOlpMuDmVV0mbDoH3PQOxGuoUQDMRqclNyOgaOdA0nKAxbZW6jZahI7OHAAsHiay5kQBwVRqGrbavFR6RACscV4J8oTKIenhOtkuhABsRggAugDcCAA2_OgA1gDOMPDx3YwArszUxbFUEMz0OGAc-VQAbiCtQ8UADAUygyNjBnxTM3NufMurxcKbEp7bw6PF7pMg07MxpytrBlfGhTv3Igdnkd5u9zjFvjc0H89kRRE8XsdCIYlh9xhCBncYYQJpBDq8iHUUWC8t9Gi1Wl1erB2pSAHRYEAABwAFMyAB4UfgAShgAD5UNJulTIKAILSAGYdYAASXQwBwbOZjD5kEYtMEMGgsDZtOhOC50jAYD6opAEqlsvliuV0H5ao1Wu1tLxYANyGYsxG6FQeoIQvhwNxYCJn0gOrOa3ECHEBoQjEZYH4jG9sBQ0gARiBqJ16MxhnKAMKMVosAgAIjAzBA6G6jOeOHQYDLNzAjGLicZBDTyGQlf49BmzHL_HUWGb0l7zH7g4A8uhy1hht0cIvFjhx8gfpBl1OcN0uxPcaxGcVutXOjhWHxD6aCKaqIeaT0CBSejdkK0QOmcK0Dz2e-KLAMkaOBDkQKDpuIhCHlGm7Rk0QA)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [I] [Feature] Specify Node Relationships in Graph using "id" Attribute [echarts]
Posted by "helgasoft (via GitHub)" <gi...@apache.org>.
helgasoft commented on issue #19401:
URL: https://github.com/apache/echarts/issues/19401#issuecomment-1857243187
wow, you are right, links work directly with node IDs!
So that's another documentation omission (Easter egg) 🐣
Someday, someone, will fix them all... ⌛
--
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.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [I] [Feature] Specify Node Relationships in Graph using "id" Attribute [echarts]
Posted by "helgasoft (via GitHub)" <gi...@apache.org>.
helgasoft commented on issue #19401:
URL: https://github.com/apache/echarts/issues/19401#issuecomment-1856430077
agree, proposal makes sense for database use.
But there is a simple solution through data preparation - [Demo Code](https://echarts.apache.org/examples/en/editor.html?c=line-simple&code=CYQwLiAEC8kNoChKQN6QHYgLYFMBckA5IHLmgvm6EA0kAxuDgOYD2ATgJ4GGBNcoF1ylkAlsA4BGQpAC-FJKgzZ8RQDrmgalc-tMAxbsiPPoI4AmMZOlpMuDmVV0mbDoH3PQOxGuoUQDMRqclNyOgaOdA0nKAxbZW6jZahI7OHAAsHiay5kQBwVRqGrbavFR6RACscV4J8oTKIenhOtkuhABsRggAugDcCAA2_OgA1gDOMPDx3YwArszUxbFUEMz0OGAc-VQAbiCtQ8WA1JqA3ZoFMoMjYwZ8UzNzbnzLq8V2gIKxO2h7o8XukyDTszHnK2scOhKeu8NHiIjq8TvNPpcfrw_gNAQciKIXm9ToRDEsvsVfsZCg94YQJpBju8iHV0ZDMvVmm0ur1YO0aQA6LAgAAOAAo2QAPCj8ACUMAAfKhpN1aZBQBAGQAzDrAACS6GAOE5bMYgsgjAZghg0FgnIZuJwvOkYDAfQlIGlsoVSpVaugQs12t1eoZRLAxuQzFmI3QqENBFFSLBhLAZO-kH1FzW4gQ4mNCEYLLA_EYftgKBFOGY_Bw3QImeQyDArBZxXozFZAAs-NJkK0QKxhiipSwxnxW0CUN6WUNWt1U-g8ABOUfYov0nAAZRLrXkaAA7oIwFW8NEYUXIN1WFgAEaMVpT_gAL3kuVyVAbu5wrTwKG6VcYC4IYGYMf-yAA9J-cMAZgAZEBr1ve9H2fQk3xwcdkAtAgLSoOtIHpHoCFaGkPxoawWFzfN-k3LwzHwLgsn4dQsBnVg5zvagDxYPBCG9YBCHEaCixQQj6MiHkyIoqiUBo1o6MIXdLmY2NNwaf5Y3EJogA).

--
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.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [I] [Feature] Specify Node Relationships in Graph using "id" Attribute [echarts]
Posted by "zshtxwd (via GitHub)" <gi...@apache.org>.
zshtxwd commented on issue #19401:
URL: https://github.com/apache/echarts/issues/19401#issuecomment-1857194652
Thank you for your reply. Yes, I am aware, but in fact, your ECharts already supports directly using IDs to specify source and target. Can you please add this feature to the documentation?
I can directly use code like this to implement it
```JavaScript
data = [
{ name: '李白', category: '亲人', id: '1' },
{ name: '杜甫', category: '亲人', id: '2' },
{ name: '李白', category: '租户', id: '3' },
{ name: '王之涣', category: '租户', id: '4' },
{ name: '王之涣', category: '亲人', id: '5' },
{ name: '杜甫', category: '亲人', id: '6' }
];
links = [
{ source: '4', target: '5', value: '夫妻' },
{ source: '2', target: '3', value: '租赁' },
{ source: '3', target: '4', value: '亲人' },
{ source: '1', target: '5', value: '亲人' },
{ source: '1', target: '2', value: '亲人' },
{ source: '4', target: '6', value: '亲人' }
]
option = {
series: {
type: 'graph',
layout: 'force', force:{repulsion:999},
lineStyle: { width:4 },
symbolSize: 55, label:{show: true},
//edgeLabel:{show: true},
data: data,
links: links,
categories: [
{name:'亲人',itemStyle:{color:'red'}},
{name:'租户',itemStyle:{color:'blue'}}
],
}
};
```
You can directly use it without the need to convert dataIndex.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [I] [Feature] Specify Node Relationships in Graph using "id" Attribute [echarts]
Posted by "zshtxwd (via GitHub)" <gi...@apache.org>.
zshtxwd commented on issue #19401:
URL: https://github.com/apache/echarts/issues/19401#issuecomment-1855352492
I accidentally closed this issue.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [I] [Feature] Specify Node Relationships in Graph using "id" Attribute [echarts]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed issue #19401: [Feature] Specify Node Relationships in Graph using "id" Attribute
URL: https://github.com/apache/echarts/issues/19401
--
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.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [I] [Feature] Specify Node Relationships in Graph using "id" Attribute [echarts]
Posted by "zshtxwd (via GitHub)" <gi...@apache.org>.
zshtxwd commented on issue #19401:
URL: https://github.com/apache/echarts/issues/19401#issuecomment-1857303238
I'm looking forward to it
--
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.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [I] [Feature] Specify Node Relationships in Graph using "id" Attribute [echarts]
Posted by "zshtxwd (via GitHub)" <gi...@apache.org>.
zshtxwd commented on issue #19401:
URL: https://github.com/apache/echarts/issues/19401#issuecomment-1855349980
I understand that dataIndex can be used, but it is not as convenient when dealing with dynamic data. It is more suitable for dynamic data. We need an attribute like 'id' or a similar one to better specify the source and target relationships in cases where names are the same. This would also facilitate storing data in a database on the backend or handling data sent from the backend more conveniently.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [I] [Feature] Specify Node Relationships in Graph using "id" Attribute [echarts]
Posted by "zshtxwd (via GitHub)" <gi...@apache.org>.
zshtxwd closed issue #19401: [Feature] Specify Node Relationships in Graph using "id" Attribute
URL: https://github.com/apache/echarts/issues/19401
--
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.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [I] [Feature] Specify Node Relationships in Graph using "id" Attribute [echarts]
Posted by "helgasoft (via GitHub)" <gi...@apache.org>.
helgasoft commented on issue #19401:
URL: https://github.com/apache/echarts/issues/19401#issuecomment-1855326240
source and target could be set as numerical node _dataIndex_ and node names could be duplicated.
See [official example](https://echarts.apache.org/examples/en/editor.html?c=graph-grid) and try several happy Fridays.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [I] [Feature] Specify Node Relationships in Graph using "id" Attribute [echarts]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #19401:
URL: https://github.com/apache/echarts/issues/19401#issuecomment-6241147232
This issue has been automatically closed because it did not have recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!
--
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.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org