All Nodes Are Overlap together
See original GitHub issueI 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 :
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
Oh actually this is expected behavior if you do not provide initial x and y coordinates 😄
From the official docs:
How to provide initial coordinates?
The live demo example does the same thing, source code in Sandbox.jsx:
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.