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

Nodes added or deleted from a graph with nodes in fixed positions will cause issues #151

Closed
sammaniamsam opened this issue Nov 27, 2018 · 4 comments

Comments

@sammaniamsam
Copy link

If you set <fx, fy> (fixed static) for some of the nodes on your graph and add or delete nodes thereafter your graph will "break" and become un-editable.
temp

@danielcaldas
Copy link
Owner

Now that I noticed it seems to happen even without setting specific fx or fy 🤔

@sammaniamsam
Copy link
Author

Thanks, Daniel

@stale stale bot added the wontfix label Feb 7, 2019
Repository owner deleted a comment from stale bot Feb 10, 2019
@stale stale bot removed the wontfix label Feb 10, 2019
@danielcaldas
Copy link
Owner

Just revisited this issue, seems that somehow the problem is not on the setting of fx and fy but rather on the nodes which are removed from the graph, therefore I'm closing this as it is a client-side integration issue. This can be easily triggered in the react-d3-graph sandbox where nodes and links are removed randomly and depending on the removed node and links the sandbox can break due to the randomness of the sample implementation. Before removing the nodes you should always remove the links that are source or target of the removed node.

Check the implementation that causes the issue:

    /**
     * Remove a node.
     */
    onClickRemoveNode = () => {
        if (this.state.data.nodes && this.state.data.nodes.length) {
            const id = this.state.data.nodes[0].id;

            this.state.data.nodes.splice(0, 1);
            const links = this.state.data.links.filter(l => l.source !== id && l.target !== id);
            const data = { nodes: this.state.data.nodes, links };

            this.setState({ data });
        } else {
            window.alert('No more nodes to remove!');
        }
    };

@danielcaldas
Copy link
Owner

From the screenshot, it seems that this issue also pointed out this one #183 which is going to be fixed here #186

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants