summaryrefslogtreecommitdiff
path: root/app/screens/graph/graph-screen.tsx
diff options
context:
space:
mode:
authorThomas F. K. Jorna <[email protected]>2021-07-17 13:53:31 +0200
committerThomas F. K. Jorna <[email protected]>2021-07-17 13:53:31 +0200
commit9b46f1da6cc37204bc54913f95ef31cf879d4881 (patch)
tree4ed6cd58fa25f2d9c22ef20d9301728a5d06e531 /app/screens/graph/graph-screen.tsx
parentdc81675878b92c12ab868804adc8afc35ab04e20 (diff)
trying to pass the node ids to graph
Diffstat (limited to 'app/screens/graph/graph-screen.tsx')
-rw-r--r--app/screens/graph/graph-screen.tsx15
1 files changed, 9 insertions, 6 deletions
diff --git a/app/screens/graph/graph-screen.tsx b/app/screens/graph/graph-screen.tsx
index 9f1f08c..1c91721 100644
--- a/app/screens/graph/graph-screen.tsx
+++ b/app/screens/graph/graph-screen.tsx
@@ -32,6 +32,7 @@ export const GraphScreen = observer(function GraphScreen() {
const [physics, setPhysics] = useState({})
const [graphData, setGraphData] = useState();
+ const [nodeIds, setNodeIds] = useState([]);
// { "nodes": [{ "id": 1 }, { "id": 2 }], "links": [{ "target": 1, "source": 2 }] });
const physicsInit = {
charge: -30,
@@ -105,18 +106,20 @@ export const GraphScreen = observer(function GraphScreen() {
};
const getNodesById = (data) => {
- const nodeIds: string[] = [];
- data.nodes.forEach(node => nodeIds.push(node.id));
- return nodeIds;
+ let temp = [];
+ data.nodes.forEach(node => temp.push(node.id));
+ setNodeIds(temp);
+ return temp;
};
useEffect(() => {
getData().then((data) => setPhysics(data));
axios.get("http://localhost:35901/graph")
.then((dataa) => {
- const nodeIds = getNodesById(dataa.data);
+ let nods = getNodesById(dataa.data);
+ setNodeIds(nods);
console.log(nodeIds);
- const cleanData = sanitizeGraph(dataa.data, nodeIds);
+ let cleanData = sanitizeGraph(dataa.data, nods);
console.log(cleanData)
setGraphData(cleanData);
})
@@ -131,7 +134,7 @@ export const GraphScreen = observer(function GraphScreen() {
return (
<Screen style={ROOT} preset="scroll">
<Tweaks physics={physics} setPhysics={setPhysics} />
- <Graph physics={physics} gData={graphData} />
+ <Graph physics={physics} gData={graphData} nodeIds={nodeIds}/>
</Screen>
)
}