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

@sammaniamsam sammaniamsam commented Nov 27, 2018

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

This comment has been minimized.

Copy link
Owner

@danielcaldas danielcaldas commented Nov 27, 2018

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

@danielcaldas danielcaldas added the bug label Nov 27, 2018
@sammaniamsam

This comment has been minimized.

Copy link
Author

@sammaniamsam sammaniamsam commented Nov 28, 2018

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

This comment has been minimized.

Copy link
Owner

@danielcaldas danielcaldas commented Mar 3, 2019

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

This comment has been minimized.

Copy link
Owner

@danielcaldas danielcaldas commented Mar 28, 2019

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
2 participants
You can’t perform that action at this time.