aboutsummaryrefslogtreecommitdiff
path: root/react-frontend/src/components/Visualization.js
diff options
context:
space:
mode:
authorJulia McCauley <skurvyj@gmail.com>2021-04-18 23:23:34 -0400
committerJulia McCauley <skurvyj@gmail.com>2021-04-18 23:23:34 -0400
commit0466db8b9051cb6300f274f0bba480d1020c63cf (patch)
treef57fe574c9ab91ce1b746b773f5aa1e6374958a4 /react-frontend/src/components/Visualization.js
parent8019e169643d2d988e994470cdd814dca83ecb28 (diff)
cleaned up graph visualization, added colors, score based node scaling
Diffstat (limited to 'react-frontend/src/components/Visualization.js')
-rw-r--r--react-frontend/src/components/Visualization.js39
1 files changed, 36 insertions, 3 deletions
diff --git a/react-frontend/src/components/Visualization.js b/react-frontend/src/components/Visualization.js
index 1975e86..0a0c82a 100644
--- a/react-frontend/src/components/Visualization.js
+++ b/react-frontend/src/components/Visualization.js
@@ -6,6 +6,7 @@ import Graph from 'vis-react';
// CSS imports
import '../css/Canvas.css';
+
/**
* This function renders and mantains thhe canvas.
* @param {Object} props The props for the canvas.
@@ -29,10 +30,37 @@ function Visualization(props) {
let nodes = [];
props.data.forEach(hub => {
if (hub.followers) {
+ let colorVal = '#f6f7d4';
+ const score = hub.suspicionScore;
+
+ if(score > 0.8){
+ colorVal = '#d92027'
+ }
+ if(score < 0.8 && score > 0.6){
+ colorVal = '#f37121'
+ }
+ if(score < 0.6 && score > 0.4){
+ colorVal = '#fdca40'
+ }
nodes.push({
id: hub.id,
+ autoResize: true,
label: hub.name,
- size: hub.suspicionScore
+ labelHighlightBold: true,
+ shape: "dot",
+ value: hub.suspicionScore*1000,
+ color: {
+ background: colorVal,
+ border: '#2b2e4a',
+ highlight:{
+ background: '#29bb89',
+ border: '#fdca40'
+ }
+ },
+ font: {
+ color: '#9fd8df',
+ size: 20,
+ }
});
}
});
@@ -43,8 +71,13 @@ function Visualization(props) {
props.data.forEach(hub => {
hub.followers.forEach(follower => {
edges.push({
- from: hub.id,
- to: follower.id
+ from: follower.id,
+ to: hub.id,
+ dashes: false,
+ color:{
+ opacity: 0.7,
+ highlight:'#fdca40',
+ }
});
});
});