question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

All Nodes Are Overlap together

See original GitHub issue

I use the demo in the document for demo ,but the result is all the nodes and links are overloped ,Is there any adivse for it? here is the code ,Please give me some advise, thanks `import React from ‘react’; import PropTypes from ‘prop-types’; import { request } from ‘…/…/…/globalLib’; import { Graph } from ‘react-d3-graph’;

import ‘./ServiceTypology.scss’;

const myConfig = { nodeHighlightBehavior: true, automaticRearrangeAfterDropNode: true, collapsible: false, directed: true, node: { color: ‘lightgreen’, size: 120, highlightStrokeColor: ‘blue’, }, link: { highlightColor: ‘lightblue’, }, };

const data = { nodes: [ { id: ‘Harry’ }, { id: ‘Sally’ }, { id: ‘Alice’ }, ], links: [ { source: ‘Harry’, target: ‘Sally’ }, { source: ‘Harry’, target: ‘Alice’ }, ], };

const onClickGraph = function () { window.alert(‘Clicked the graph background’); };

const onClickNode = function (nodeId) { window.alert(‘Clicked node ${nodeId}’); };

const onDoubleClickNode = function (nodeId) { window.alert(‘Double clicked node ${nodeId}’); };

const onRightClickNode = function (event, nodeId) { window.alert(‘Right clicked node ${nodeId}’); };

const onMouseOverNode = function (nodeId) { window.alert(Mouse over node ${nodeId}); };

const onMouseOutNode = function (nodeId) { window.alert(Mouse out node ${nodeId}); };

const onClickLink = function (source, target) { window.alert(Clicked link between ${source} and ${target}); };

const onRightClickLink = function (event, source, target) { window.alert(‘Right clicked link between ${source} and ${target}’); };

const onMouseOverLink = function (source, target) { window.alert(Mouse over in link between ${source} and ${target}); };

const onMouseOutLink = function (source, target) { window.alert(Mouse out link between ${source} and ${target}); };

const onNodePositionChange = function (nodeId, x, y) { window.alert(Node ${nodeId} moved to new position x= ${x} y= ${y}); };

class ServiceTypology extends React.Component { static displayName = ‘ServiceTypology’;

static propTypes = { namespaceId: PropTypes.string, };

constructor(props) { super(props); this.state = { loading: false, }; }

openLoading() { this.setState({ loading: true }); }

closeLoading() { this.setState({ loading: false }); }

render() { const { namespaceId } = this.props; return ( <div className="graph-service-typology"> <Graph id="graph-id" data={data} config={myConfig} onClickGraph={onClickGraph} onClickNode={onClickNode} onDoubleClickNode={onDoubleClickNode} onRightClickNode={onRightClickNode} onClickLink={onClickLink} onRightClickLink={onRightClickLink} onMouseOverNode={onMouseOverNode} onMouseOutNode={onMouseOutNode} onMouseOverLink={onMouseOverLink} onMouseOutLink={onMouseOutLink} /> </div> ); } }

export default ServiceTypology; `

The next is the result :

微信图片_20191120220552

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
danielcaldascommented, Nov 30, 2019

Oh actually this is expected behavior if you do not provide initial x and y coordinates 😄

From the official docs:

staticGraph (boolean = false) when setting this value to true the graph will be completely static, thus all forces and drag events upon nodes will produce not effect. Note that, if this value is true the nodes will be rendered with the initial provided x and y coordinates (links positions will be automatically set from the given nodes positions by rd3g), no coordinates will be calculated by rd3g or subjacent d3 modules.

How to provide initial coordinates?

The live demo example does the same thing, source code in Sandbox.jsx:

/**
     * This function decorates nodes and links with positions. The motivation
     * for this function its to set `config.staticGraph` to true on the first render
     * call, and to get nodes and links statically set to their initial positions.
     * @param  {Object} nodes nodes and links with minimalist structure.
     * @return {Object} the graph where now nodes containing (x,y) coords.
     */
    decorateGraphNodesWithInitialPositioning = nodes => {
        return nodes.map(n =>
            Object.assign({}, n, {
                x: n.x || Math.floor(Math.random() * 500),
                y: n.y || Math.floor(Math.random() * 500),
            })
        );
    };
0reactions
stale[bot]commented, Jan 31, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visualizing graphs with overlapping node groups - R-bloggers
First, the nodes in the graph were organized in groups but each node could belong to multiple groups or to no group at...
Read more >
How to avoid overlapping when there's hundreds of nodes in ...
I've got 2000+ nodes and 900+ edges, but when I was trying to make graphics in networkx, I found all the nodes crowded...
Read more >
How to see which nodes frequently occur together [overlap]?
In order to find the nodes, which frequently overlap, you can run a Matrix coding query by selecting nodes as rows and columns...
Read more >
overlap - Graphviz
Nodes are first enlarged using the sep attribute. If true , overlaps are retained. If the value is "scale" , overlaps are removed...
Read more >
Overlapping nodes - Revit - Dynamo Forum
Using Revit 2021 Dynamo: [image] When I am opening a dyn file it is showing all of the nodes on top of each...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found