You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "EF1874 (via GitHub)" <gi...@apache.org> on 2025/03/27 12:43:38 UTC
[I] [Bug] graph的高亮能否使用click触发 [echarts]
EF1874 opened a new issue, #20870:
URL: https://github.com/apache/echarts/issues/20870
### Version
5.6.0
### Link to Minimal Reproduction
无
### Steps to Reproduce
无
### Current Behavior
使用如下配置只能在hover触发高亮
```
focusNodeAdjacency: true,
emphasis: {
focus: 'adjacency',
},
```
### Expected Behavior
希望能通过鼠标点击节点高亮
### Environment
```markdown
- OS:
- Browser:
- Framework:
```
### Any additional comments?
_No response_
--
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] [Bug] graph的高亮能否使用click触发 [echarts]
Posted by "EF1874 (via GitHub)" <gi...@apache.org>.
EF1874 commented on issue #20870:
URL: https://github.com/apache/echarts/issues/20870#issuecomment-2760085488
> did you try [highlight](https://echarts.apache.org/en/api.html#action.highlight) action?
I tried, but emphasis config will triggerOn hover always;
I need to use custom highlight set like this
```
chart.on('click', params => {
if (params.dataType === 'node') {
const targetId = params.data.id;
const related = new Set([targetId]);
const relatedLinks = new Set();
// 标记关联元素
links.forEach(link => {
if (link.source === targetId || link.target === targetId) {
related.add(link.source);
related.add(link.target);
relatedLinks.add(`${link.source}-${link.target}`);
}
});
// 更新节点透明度
const newNodes = nodes.map(n => ({
...n,
itemStyle: {
opacity: related.has(n.id) ? 1 : 0.1
}
}));
// 更新连线透明度
const newLinks = links.map(link => ({
...link,
lineStyle: {
opacity: relatedLinks.has(`${link.source}-${link.target}`) ||
relatedLinks.has(`${link.target}-${link.source}`) ? 1 : 0.1
}
}));
// 应用更新并保留布局
chart.setOption({
series: [{
data: newNodes,
links: newLinks,
// 保持力导向图的当前布局
force: {
initLayout: null // 保留现有位置
}
}]
}, { notMerge: false });
}
});
```
--
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] [Bug] graph的高亮能否使用click触发 [echarts]
Posted by "EF1874 (via GitHub)" <gi...@apache.org>.
EF1874 closed issue #20870: [Bug] graph的高亮能否使用click触发
URL: https://github.com/apache/echarts/issues/20870
--
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] [Bug] graph的高亮能否使用click触发 [echarts]
Posted by "helgasoft (via GitHub)" <gi...@apache.org>.
helgasoft commented on issue #20870:
URL: https://github.com/apache/echarts/issues/20870#issuecomment-2758930486
did you try [highlight](https://echarts.apache.org/en/api.html#action.highlight) action?
--
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