-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[Bug]: antv-dagre layout doesn't work on collapsed combos #6810
Comments
The issue you're experiencing with the
If you need further assistance or have specific questions about implementing any of these suggestions, feel free to ask! 🪧 TipsFor further assistance, please describe your question in the comments and @petercat-assistant to start a conversation with me. |
@petercat-assistant, how would you approach custom layout adjustment in this case? Could you, please, give a basic example? Also is it possible to set x and y positions for combos from data? |
To approach custom layout adjustment for handling collapsed combos, you can manually set the positions of nodes and combos after the layout calculation. Here's a basic example of how you might achieve this: Custom Layout Adjustment Example
Here's a basic example: import { Graph } from '@antv/g6';
const data = {
nodes: [
{ id: '0', combo: 'A' },
{ id: '1', combo: 'A' },
// ... other nodes
],
combos: [
{ id: 'A', style: { type: 'rect', collapsed: true } },
// ... other combos
],
edges: [
{ source: '0', target: '1' },
// ... other edges
],
};
const graph = new Graph({
container: 'container',
autoFit: true,
data,
layout: {
type: 'antv-dagre',
ranksep: 50,
nodesep: 5,
sortByCombo: true,
},
behaviors: ['drag-element', 'drag-canvas', 'zoom-canvas', 'collapse-expand'],
});
graph.on('afterlayout', () => {
// Manually adjust positions
graph.updateCombo('A', { x: 100, y: 100 });
// You can also update nodes if needed
graph.updateItem('0', { x: 150, y: 150 });
});
graph.render(); Setting x and y Positions for Combos from DataYes, you can set x and y positions for combos directly from the data. You need to include const data = {
nodes: [
{ id: '0', combo: 'A' },
{ id: '1', combo: 'A' },
// ... other nodes
],
combos: [
{ id: 'A', x: 100, y: 100, style: { type: 'rect', collapsed: true } },
// ... other combos
],
edges: [
{ source: '0', target: '1' },
// ... other edges
],
}; By setting the If you have further questions or need more detailed examples, feel free to ask! 🪧 TipsFor further assistance, please describe your question in the comments and @petercat-assistant to start a conversation with me. |
This approach doesn't work because |
Currently, when the combo is set to { collapse: true }, there is an issue where the antv-dagre layout fails to function properly. This is a bug. You can temporarily resolve this problem by setting the combo configuration to { collapse: false }. We plan to comprehensively redesign the combo layout-related content in the future. |
Thanks for your answer! Temporary workaround that worked for me is to initially set
If you hide the canvas before it's rendered - it looks like the layout worked. |
@zhongyunWan Hello; When you apply comboCombined layout in antv g6 v4.x (I apply it with graph.updateLayout) if the combos are collapsed as you said, the comboCombined layout does not change the location and order of the combos. This problem is solved simply as follows; If I call the graph.render method, the layout is created immediately, but since I have called the graph.render method before, when I call it again, some problems occur in the graph. For example, if I add a node/edge to the graph later, they do not appear, etc. Is there an easy way to overcome this problem? What kind of problems does the graph.render method cause when called twice in v4 and is there a solution? |
Describe the bug / 问题描述
When using antv-dagr layout on initially collapsed combos - combos show on top of each other.
When opening combo - nodes show on top of each other.
Is there a layout that works on collapsed combos or some workaround for this issue?

Appreciate your help
Steps to Reproduce the Bug or Issue / 重现步骤
You can paste this code here: https://g6.antv.antgroup.com/en/examples/layout/dagre#antv-dagre-combo
to see it.
Version / 版本
🆕 5.x
OS / 操作系统
Browser / 浏览器
The text was updated successfully, but these errors were encountered: