Skip to content

Commit 644eac4

Browse files
committed
Let's see if we can get the top-down direction to stick
1 parent 160d068 commit 644eac4

3 files changed

Lines changed: 40 additions & 13 deletions

File tree

src/_App/BotAnalysis/Networks/Graph2.js

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
// adapted from source: https://github.com/vasturiano/react-force-graph/blob/master/example/tree/index.html
3+
// https://github.com/vasturiano/react-force-graph#data-input
34

45
import React, { PureComponent, useEffect, useRef} from 'react'
56
import { ForceGraph2D } from 'react-force-graph'
@@ -12,6 +13,26 @@ import Spinner from '../../Spinner'
1213
import cachedData from './data'
1314

1415
const ForceTree = ({ data }) => {
16+
17+
data["nodes"] = data["nodes"].map(function(node){
18+
return {
19+
"id": node["id"], // NODE ID
20+
"mean_opinion": node["opinion"],
21+
"status_count": node["Rate"],
22+
"color": node["color"], // NODE COLOR
23+
//"x": node["xcoord"],
24+
//"y": node["ycoord"],
25+
}
26+
})
27+
28+
data["links"] = data["links"].map(function(link){
29+
return {
30+
"source": link["source"], // SOURCE NODE ID
31+
"target": link["target"], // TARGET NODE ID
32+
//"weight": link["weight"],
33+
}
34+
})
35+
1536
const containerRef = useRef()
1637
useEffect(() => {
1738
// add collision force
@@ -21,18 +42,17 @@ const ForceTree = ({ data }) => {
2142
}, [])
2243
//console.log("GRAPH DATA", data)
2344

24-
return <ForceGraph2D ref={containerRef} width={900} height={550}
45+
return <ForceGraph2D ref={containerRef} width={900} height={500} backgroundColor="#101020"
2546
graphData={data}
47+
2648
nodeId="id"
27-
nodeVal={node => Math.sqrt(50)}
28-
nodeLabel="Name"
29-
nodeAutoColorBy="color"
49+
nodeVal="status_count"
50+
nodeLabel={(node) => `@${node["id"]}`}
51+
nodeRelSize={1}
3052

31-
dagMode="td"
32-
dagLevelDistance={300}
33-
backgroundColor="#101020"
53+
//dagMode="td"
54+
//dagLevelDistance={300}
3455
linkColor={() => 'rgba(255,255,255,0.2)'}
35-
nodeRelSize={1}
3656
linkDirectionalParticles={2}
3757
linkDirectionalParticleWidth={2}
3858
d3VelocityDecay={0.3}
@@ -60,10 +80,11 @@ export default class NetworkGraph extends PureComponent {
6080

6181
componentDidMount() {
6282
console.log("DASHBOARD DID MOUNT")
63-
this.fetchData() // temporary for dev
64-
setTimeout(function(){
65-
this.setState({parsedResponse: cachedData})
66-
}.bind(this), 800) // let you see the spinner
83+
//this.fetchData() // temporary for dev
84+
//setTimeout(function(){
85+
// this.setState({parsedResponse: cachedData})
86+
//}.bind(this), 800) // let you see the spinner
87+
this.setState({parsedResponse: cachedData})
6788
}
6889

6990
fetchData() {

src/_App/BotAnalysis/Networks/Section.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import Container from 'react-bootstrap/Container'
66
import Card from 'react-bootstrap/Card'
77
//import Table from 'react-bootstrap/Table'
88

9-
import NetworkGraph from "./Graph"
109
import TreeGraph from "./Graph1"
10+
import NetworkGraph from "./Graph2"
11+
import NewGraph from "./Graph3"
1112

1213
export default function BotNetworks() {
1314
return (
@@ -16,6 +17,11 @@ export default function BotNetworks() {
1617
<Card.Body>
1718
<Card.Title><h3>Bot Networks</h3></Card.Title>
1819

20+
<Card.Text>
21+
Bot Community Networks (tree view):
22+
</Card.Text>
23+
<NewGraph/>
24+
1925
<Card.Text>
2026
Bot Community Networks:
2127
</Card.Text>

0 commit comments

Comments
 (0)