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

[Feature] Using Graph type and Force layout provide a way to stop auto layout #19493

Open
gkorland opened this issue Jan 10, 2024 · 4 comments
Open
Labels
en This issue is in English new-feature pending We are not sure about whether this is a bug/new feature.

Comments

@gkorland
Copy link

What problem does this feature solve?

When using type graph with layout force it provides a draggable option, but this option is pretty useless since whenever a node is dragged it immediately jumps back to the original place.
Expected behavior, to let the user drag and "reorder" the layout.

What does the proposed API look like?

Extend the force configuration with "maxTime" that will stop auto layout after this time. Will also be very helpful to stop very long initial layout in large graphs.

@echarts-bot echarts-bot bot added en This issue is in English pending We are not sure about whether this is a bug/new feature. labels Jan 10, 2024
@echarts-bot echarts-bot bot changed the title [Feature] Using Graph type and Force layout provide a way to stop auto layout [Feature] Using Graph type and Force layout provide a way to stop auto layout Jan 10, 2024
@helgasoft
Copy link

related to #16682 #19230
Agree that draggable for layout force does not make sense. Probably a documentation bug, should be for layout 'none' only.

@gkorland
Copy link
Author

I think it should be in force mode too, but only after it stabilize

@cuberinooo
Copy link

Is there are way to use this with force ? This would be a big benefit for us.
Also we use force without animation. So we see the stabilized view immediately. When I allow "draggable" and try to drag a node the whole graph recalculates its position. I think the problem is that force does not stick with the init values. It just recalculates the positions everytime.

@tsaltena
Copy link

We were facing a similar issue, and have gone the route of using the 'finished' event to turn the positions into static coordinates. So the basic approach (we use this in a Vue-Echarts setting, so all the 'this' references refer to the Vue component data):

on_finished: function() {
        const model = this.chart.getModel()
        const series = model.getSeriesByIndex(0);
        const nodeData = series.getData();
        // set the active layout to 'none' to avoid force updating:
        this.active_layout = 'none'
        // loop over node data to set the coordinates to the fixed node Data
        this.graph_data.nodes.forEach((node, nodenum) => {
          [node.x, node.y] = nodeData.getItemLayout(nodenum)
        })
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
en This issue is in English new-feature pending We are not sure about whether this is a bug/new feature.
Projects
None yet
Development

No branches or pull requests

4 participants