summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/components/graph/graph.tsx3
-rw-r--r--app/screens/graph/graph-screen.tsx15
2 files changed, 11 insertions, 7 deletions
diff --git a/app/components/graph/graph.tsx b/app/components/graph/graph.tsx
index 94a4fe1..e179cb9 100644
--- a/app/components/graph/graph.tsx
+++ b/app/components/graph/graph.tsx
@@ -30,13 +30,14 @@ export interface GraphProps {
style?: StyleProp<ViewStyle>
physics
gData
+ nodeIds: string[]
}
/**
* Describe your component here
*/
export const Graph = observer(function Graph(props: GraphProps): JSX.Element {
- const { style, physics, gData } = props
+ const { style, physics, gData, nodeIds } = props
const styles = flatten([CONTAINER, style])
const fgRef = useRef()
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>
)
}