Compare commits

...

2 Commits

Author SHA1 Message Date
JuliusHerrmann
5464c7c1b8 remove unused jsx 2022-01-19 17:44:28 +01:00
JuliusHerrmann
d5a692f0c6 remove console.log 2022-01-19 17:43:10 +01:00
2 changed files with 0 additions and 65 deletions

View File

@ -28,7 +28,6 @@ class Graph extends React.Component {
componentDidUpdate(prevProps, _) { componentDidUpdate(prevProps, _) {
//only recalculate the layout if graph has changed //only recalculate the layout if graph has changed
if (prevProps.graphData !== this.props.graphData) { if (prevProps.graphData !== this.props.graphData) {
console.log("updated component => error");
this.layoutGraph(); this.layoutGraph();
this.setState({step: 0}, () => { this.setState({step: 0}, () => {
//first crop the animation //first crop the animation

View File

@ -1,64 +0,0 @@
import React, { useEffect, useRef } from "react";
import { Network } from "vis-network";
class Graph extends React.Component{
constructor(props){
super(props);
this.state = {
nodes:[
{ id: 1, label: "Node 1" },
{ id: 2, label: "Node 2" },
{ id: 3, label: "Node 3" },
{ id: 4, label: "Node 4" },
{ id: 5, label: "Node 5" },
],
edges:[
{ from: 1, to: 3 },
{ from: 1, to: 2 },
{ from: 2, to: 4 },
{ from: 2, to: 5 },
{ from: 3, to: 3 },
]
}
}
componentDidMount(){
this.id = setInterval(()=>this.tick(), 1000);
}
componentWillUnmount(){
clearInterval(this.id);
}
tick(){
if(this.state.nodes[0].label === "Node 1"){
var copy = this.state;
copy.nodes[0].label = "TEUZET";
this.setState(copy)
}else{
var copy = this.state;
copy.nodes[0].label = "Node 1";
this.setState(copy)
}
}
render(){
console.log(this.state);
return (<VisNetwork inp={this.state}/>)
}
}
function VisNetwork(inp) {
const visJsRef = useRef(false);
var nodes = inp.inp.nodes;
var edges = inp.inp.edges;
useEffect(() => {
visJsRef.current.graph = new Network(visJsRef.current, { nodes, edges }, {});
// Use `network` here to configure events, etc
}, [visJsRef, nodes, edges]);
//redraw the graph
if(visJsRef.current.graph != null){
console.log("red")
visJsRef.current.graph.redraw();
}
return <div ref={visJsRef} />;
};
export default Graph;