summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/components/graph/graph.tsx110
-rw-r--r--app/data/randorev.json2392
-rw-r--r--app/screens/graph/graph-screen.tsx84
-rw-r--r--org-roam-ui.el2
-rw-r--r--package.json2
-rw-r--r--yarn.lock23
6 files changed, 140 insertions, 2473 deletions
diff --git a/app/components/graph/graph.tsx b/app/components/graph/graph.tsx
index 930233b..1202413 100644
--- a/app/components/graph/graph.tsx
+++ b/app/components/graph/graph.tsx
@@ -9,7 +9,6 @@ import { flatten } from "ramda"
//import data from "../../data/miserables.json"
//import genRandomTree from "../../data/randomdata";
//import rando from "../../data/rando.json"
-import rando from "../../data/randorev.json"
import { ForceGraph2D, ForceGraph3D, ForceGraphVR, ForceGraphAR } from "react-force-graph"
import * as d3 from "d3-force"
@@ -62,44 +61,44 @@ export const Graph = observer(function Graph(props: GraphProps): JSX.Element {
})
// For the expandable version of the graph
- const rootId = 0
-
- const nodesById = useMemo(() => {
- const nodesById = Object.fromEntries(rando.nodes.map((node) => [node.id, node]))
+ /* const rootId = 0
+* const nodesById = useMemo(() => {
+* const nodesById = Object.fromEntries(gData.nodes.map((node) => [node.id, node]))
+ */
// link parent/children
- rando.nodes.forEach((node) => {
- node.collapsed = node.id !== rootId
- node.childLinks = []
- node.parentLink = []
- })
- rando.links.forEach((link) => nodesById[link.source].childLinks.push(link))
-
- return nodesById
- }, [rando])
-
- const getPrunedTree = useCallback(() => {
- const visibleNodes = []
- const visibleLinks = []
- ; (function traverseTree(node = nodesById[rootId]) {
- visibleNodes.push(node)
- if (node.collapsed) return
- visibleLinks.push(...node.childLinks)
- node.childLinks
- .map((link) => (typeof link.target === "object" ? link.target : nodesById[link.target])) // get child node
- .forEach(traverseTree)
- })()
-
- return { nodes: visibleNodes, links: visibleLinks }
- }, [nodesById])
-
- const [prunedTree, setPrunedTree] = useState(getPrunedTree())
-
- const handleNodeClick = useCallback((node) => {
- node.collapsed = !node.collapsed // toggle collapse state
- setPrunedTree(getPrunedTree())
- }, []);
-
+ /* gData.nodes.forEach((node) => {
+ * node.collapsed = node.id !== rootId
+ * node.childLinks = []
+ * node.parentLink = []
+ * })
+ * gData.links.forEach((link) => nodesById[link.source].childLinks.push(link))
+
+ * return nodesById
+ }, [gData])
+ */
+ /* const getPrunedTree = useCallback(() => {
+* const visibleNodes = [];
+* const visibleLinks = [];
+* (function traverseTree(node = nodesById[rootId]) {
+* visibleNodes.push(node);
+* if (node.collapsed) return
+* visibleLinks.push(...node.childLinks)
+* node.childLinks
+* .map((link) => (typeof link.target === "object" ? link.target : nodesById[link.target])) // get child node
+* .forEach(traverseTree)
+* })()
+
+* return { nodes: visibleNodes, links: visibleLinks }
+* }, [nodesById])
+
+* const [prunedTree, setPrunedTree] = useState(getPrunedTree())
+
+* const handleNodeClick = useCallback((node) => {
+* node.collapsed = !node.collapsed // toggle collapse state
+* setPrunedTree(getPrunedTree())
+* }, []);
+ */
// Highlight Graph
/**
@@ -180,37 +179,40 @@ export const Graph = observer(function Graph(props: GraphProps): JSX.Element {
{!physics.threedim ? (
<ForceGraph2D
ref={fgRef}
- graphData={physics.collapse ? prunedTree : rando}
+ graphData={gData}
+ //graphData={physics.collapse ? prunedTree : gData}
// nodeAutoColorBy={d => d.id%GROUPS}
- linkAutoColorBy={(d) => rando.nodes[d.source].id % GROUPS}
- linkColor={"#ffffff"}
+ //linkAutoColorBy={(d) => gData.nodes[d.source].id % GROUPS}
+ linkColor="#ffffff"
linkDirectionalParticles={physics.particles}
- nodeColor={(node) =>
- !node.childLinks.length ? "green" : node.collapsed ? "red" : "yellow"
- }
- onNodeClick={!physics.collapse ? null : handleNodeClick}
- nodeLabel={(node) => "label"}
- // nodeVal ={(node)=> node.childLinks.length * 0.5 + 1}
+ //nodeColor={(node) =>
+ // !node.childLinks.length ? "green" : node.collapsed ? "red" : "yellow"
+ //}
+ //onNodeClick={!physics.collapse ? null : handleNodeClick}
+ nodeLabel={(node) => node.title}
+ //nodeVal ={(node)=> node.childLinks.length * 0.5 + 1}
//d3VelocityDecay={visco}
linkWidth={physics.linkWidth}
linkOpacity={physics.linkOpacity}
nodeRelSize={physics.nodeRel}
linkDirectionalParticleWidth={physics.particleWidth}
+ backgroundColor={"#ffffff"}
/>
) : (
<ForceGraph3D
ref={fgRef}
- graphData={physics.collapse ? prunedTree : rando}
+ graphData={gData}
+ //graphData={physics.collapse ? prunedTree : gData}
// nodeAutoColorBy={d => d.id%GROUPS}
- linkAutoColorBy={(d) => rando.nodes[d.source].id % GROUPS}
- linkColor={"#ffffff"}
+ //linkAutoColorBy={(d) => gData.nodes[d.source].id % GROUPS}
+ linkColor="#ffffff"
linkWidth={2}
linkDirectionalParticles={physics.particles}
- nodeColor={(node) =>
- !node.childLinks.length ? "green" : node.collapsed ? "red" : "yellow"
- }
- onNodeClick={!physics.collapse ? null : handleNodeClick}
- nodeVal={(node) => node.childLinks.length + 1}
+ //nodeColor={(node) =>
+ // !node.childLinks.length ? "green" : node.collapsed ? "red" : "yellow"
+ //}
+ //onNodeClick={!physics.collapse ? null : handleNodeClick}
+ //nodeVal={(node) => node.childLinks.length + 1}
//d3VelocityDecay={visco}
linkWidth={physics.linkWidth}
linkOpacity={physics.linkOpacity}
diff --git a/app/data/randorev.json b/app/data/randorev.json
index 2bfb6cb..e686411 100644
--- a/app/data/randorev.json
+++ b/app/data/randorev.json
@@ -1805,2398 +1805,6 @@
{
"target": 1,
"source": 0
- },
- {
- "target": 2,
- "source": 1
- },
- {
- "target": 3,
- "source": 1
- },
- {
- "target": 4,
- "source": 1
- },
- {
- "target": 5,
- "source": 1
- },
- {
- "target": 6,
- "source": 2
- },
- {
- "target": 7,
- "source": 6
- },
- {
- "target": 8,
- "source": 5
- },
- {
- "target": 9,
- "source": 3
- },
- {
- "target": 10,
- "source": 6
- },
- {
- "target": 11,
- "source": 9
- },
- {
- "target": 12,
- "source": 5
- },
- {
- "target": 13,
- "source": 11
- },
- {
- "target": 14,
- "source": 6
- },
- {
- "target": 15,
- "source": 14
- },
- {
- "target": 16,
- "source": 10
- },
- {
- "target": 17,
- "source": 10
- },
- {
- "target": 18,
- "source": 1
- },
- {
- "target": 19,
- "source": 5
- },
- {
- "target": 20,
- "source": 3
- },
- {
- "target": 21,
- "source": 6
- },
- {
- "target": 22,
- "source": 14
- },
- {
- "target": 23,
- "source": 13
- },
- {
- "target": 24,
- "source": 13
- },
- {
- "target": 25,
- "source": 2
- },
- {
- "target": 26,
- "source": 9
- },
- {
- "target": 27,
- "source": 14
- },
- {
- "target": 28,
- "source": 24
- },
- {
- "target": 29,
- "source": 19
- },
- {
- "target": 30,
- "source": 14
- },
- {
- "target": 31,
- "source": 23
- },
- {
- "target": 32,
- "source": 3
- },
- {
- "target": 33,
- "source": 7
- },
- {
- "target": 34,
- "source": 7
- },
- {
- "target": 35,
- "source": 14
- },
- {
- "target": 36,
- "source": 6
- },
- {
- "target": 37,
- "source": 28
- },
- {
- "target": 38,
- "source": 22
- },
- {
- "target": 39,
- "source": 28
- },
- {
- "target": 40,
- "source": 37
- },
- {
- "target": 41,
- "source": 25
- },
- {
- "target": 42,
- "source": 38
- },
- {
- "target": 43,
- "source": 15
- },
- {
- "target": 44,
- "source": 40
- },
- {
- "target": 45,
- "source": 13
- },
- {
- "target": 46,
- "source": 28
- },
- {
- "target": 47,
- "source": 43
- },
- {
- "target": 48,
- "source": 40
- },
- {
- "target": 49,
- "source": 1
- },
- {
- "target": 50,
- "source": 26
- },
- {
- "target": 51,
- "source": 35
- },
- {
- "target": 52,
- "source": 22
- },
- {
- "target": 53,
- "source": 39
- },
- {
- "target": 54,
- "source": 11
- },
- {
- "target": 55,
- "source": 20
- },
- {
- "target": 56,
- "source": 24
- },
- {
- "target": 57,
- "source": 35
- },
- {
- "target": 58,
- "source": 46
- },
- {
- "target": 59,
- "source": 8
- },
- {
- "target": 60,
- "source": 52
- },
- {
- "target": 61,
- "source": 8
- },
- {
- "target": 62,
- "source": 5
- },
- {
- "target": 63,
- "source": 10
- },
- {
- "target": 64,
- "source": 39
- },
- {
- "target": 65,
- "source": 0
- },
- {
- "target": 66,
- "source": 6
- },
- {
- "target": 67,
- "source": 41
- },
- {
- "target": 68,
- "source": 61
- },
- {
- "target": 69,
- "source": 59
- },
- {
- "target": 70,
- "source": 65
- },
- {
- "target": 71,
- "source": 29
- },
- {
- "target": 72,
- "source": 12
- },
- {
- "target": 73,
- "source": 46
- },
- {
- "target": 74,
- "source": 19
- },
- {
- "target": 75,
- "source": 39
- },
- {
- "target": 76,
- "source": 41
- },
- {
- "target": 77,
- "source": 35
- },
- {
- "target": 78,
- "source": 36
- },
- {
- "target": 79,
- "source": 23
- },
- {
- "target": 80,
- "source": 8
- },
- {
- "target": 81,
- "source": 36
- },
- {
- "target": 82,
- "source": 58
- },
- {
- "target": 83,
- "source": 23
- },
- {
- "target": 84,
- "source": 25
- },
- {
- "target": 85,
- "source": 75
- },
- {
- "target": 86,
- "source": 28
- },
- {
- "target": 87,
- "source": 34
- },
- {
- "target": 88,
- "source": 34
- },
- {
- "target": 89,
- "source": 20
- },
- {
- "target": 90,
- "source": 68
- },
- {
- "target": 91,
- "source": 48
- },
- {
- "target": 92,
- "source": 73
- },
- {
- "target": 93,
- "source": 41
- },
- {
- "target": 94,
- "source": 85
- },
- {
- "target": 95,
- "source": 84
- },
- {
- "target": 96,
- "source": 64
- },
- {
- "target": 97,
- "source": 59
- },
- {
- "target": 98,
- "source": 46
- },
- {
- "target": 99,
- "source": 14
- },
- {
- "target": 100,
- "source": 25
- },
- {
- "target": 101,
- "source": 66
- },
- {
- "target": 102,
- "source": 6
- },
- {
- "target": 103,
- "source": 53
- },
- {
- "target": 104,
- "source": 22
- },
- {
- "target": 105,
- "source": 47
- },
- {
- "target": 106,
- "source": 54
- },
- {
- "target": 107,
- "source": 47
- },
- {
- "target": 108,
- "source": 55
- },
- {
- "target": 109,
- "source": 76
- },
- {
- "target": 110,
- "source": 34
- },
- {
- "target": 111,
- "source": 93
- },
- {
- "target": 112,
- "source": 0
- },
- {
- "target": 113,
- "source": 58
- },
- {
- "target": 114,
- "source": 1
- },
- {
- "target": 115,
- "source": 109
- },
- {
- "target": 116,
- "source": 89
- },
- {
- "target": 117,
- "source": 49
- },
- {
- "target": 118,
- "source": 75
- },
- {
- "target": 119,
- "source": 78
- },
- {
- "target": 120,
- "source": 11
- },
- {
- "target": 121,
- "source": 37
- },
- {
- "target": 122,
- "source": 20
- },
- {
- "target": 123,
- "source": 52
- },
- {
- "target": 124,
- "source": 45
- },
- {
- "target": 125,
- "source": 93
- },
- {
- "target": 126,
- "source": 105
- },
- {
- "target": 127,
- "source": 99
- },
- {
- "target": 128,
- "source": 48
- },
- {
- "target": 129,
- "source": 34
- },
- {
- "target": 130,
- "source": 58
- },
- {
- "target": 131,
- "source": 97
- },
- {
- "target": 132,
- "source": 89
- },
- {
- "target": 133,
- "source": 19
- },
- {
- "target": 134,
- "source": 106
- },
- {
- "target": 135,
- "source": 62
- },
- {
- "target": 136,
- "source": 99
- },
- {
- "target": 137,
- "source": 97
- },
- {
- "target": 138,
- "source": 62
- },
- {
- "target": 139,
- "source": 109
- },
- {
- "target": 140,
- "source": 101
- },
- {
- "target": 141,
- "source": 88
- },
- {
- "target": 142,
- "source": 107
- },
- {
- "target": 143,
- "source": 81
- },
- {
- "target": 144,
- "source": 92
- },
- {
- "target": 145,
- "source": 102
- },
- {
- "target": 146,
- "source": 60
- },
- {
- "target": 147,
- "source": 56
- },
- {
- "target": 148,
- "source": 41
- },
- {
- "target": 149,
- "source": 84
- },
- {
- "target": 150,
- "source": 79
- },
- {
- "target": 151,
- "source": 56
- },
- {
- "target": 152,
- "source": 110
- },
- {
- "target": 153,
- "source": 130
- },
- {
- "target": 154,
- "source": 65
- },
- {
- "target": 155,
- "source": 66
- },
- {
- "target": 156,
- "source": 124
- },
- {
- "target": 157,
- "source": 10
- },
- {
- "target": 158,
- "source": 17
- },
- {
- "target": 159,
- "source": 0
- },
- {
- "target": 160,
- "source": 19
- },
- {
- "target": 161,
- "source": 115
- },
- {
- "target": 162,
- "source": 95
- },
- {
- "target": 163,
- "source": 144
- },
- {
- "target": 164,
- "source": 22
- },
- {
- "target": 165,
- "source": 91
- },
- {
- "target": 166,
- "source": 14
- },
- {
- "target": 167,
- "source": 34
- },
- {
- "target": 168,
- "source": 40
- },
- {
- "target": 169,
- "source": 40
- },
- {
- "target": 170,
- "source": 100
- },
- {
- "target": 171,
- "source": 23
- },
- {
- "target": 172,
- "source": 88
- },
- {
- "target": 173,
- "source": 78
- },
- {
- "target": 174,
- "source": 8
- },
- {
- "target": 175,
- "source": 129
- },
- {
- "target": 176,
- "source": 160
- },
- {
- "target": 177,
- "source": 94
- },
- {
- "target": 178,
- "source": 42
- },
- {
- "target": 179,
- "source": 33
- },
- {
- "target": 180,
- "source": 53
- },
- {
- "target": 181,
- "source": 73
- },
- {
- "target": 182,
- "source": 112
- },
- {
- "target": 183,
- "source": 175
- },
- {
- "target": 184,
- "source": 71
- },
- {
- "target": 185,
- "source": 65
- },
- {
- "target": 186,
- "source": 15
- },
- {
- "target": 187,
- "source": 69
- },
- {
- "target": 188,
- "source": 1
- },
- {
- "target": 189,
- "source": 142
- },
- {
- "target": 190,
- "source": 111
- },
- {
- "target": 191,
- "source": 6
- },
- {
- "target": 192,
- "source": 31
- },
- {
- "target": 193,
- "source": 54
- },
- {
- "target": 194,
- "source": 128
- },
- {
- "target": 195,
- "source": 24
- },
- {
- "target": 196,
- "source": 163
- },
- {
- "target": 197,
- "source": 160
- },
- {
- "target": 198,
- "source": 168
- },
- {
- "target": 199,
- "source": 92
- },
- {
- "target": 200,
- "source": 80
- },
- {
- "target": 201,
- "source": 18
- },
- {
- "target": 202,
- "source": 191
- },
- {
- "target": 203,
- "source": 65
- },
- {
- "target": 204,
- "source": 128
- },
- {
- "target": 205,
- "source": 195
- },
- {
- "target": 206,
- "source": 126
- },
- {
- "target": 207,
- "source": 202
- },
- {
- "target": 208,
- "source": 162
- },
- {
- "target": 209,
- "source": 54
- },
- {
- "target": 210,
- "source": 125
- },
- {
- "target": 211,
- "source": 170
- },
- {
- "target": 212,
- "source": 150
- },
- {
- "target": 213,
- "source": 202
- },
- {
- "target": 214,
- "source": 202
- },
- {
- "target": 215,
- "source": 83
- },
- {
- "target": 216,
- "source": 6
- },
- {
- "target": 217,
- "source": 60
- },
- {
- "target": 218,
- "source": 209
- },
- {
- "target": 219,
- "source": 3
- },
- {
- "target": 220,
- "source": 83
- },
- {
- "target": 221,
- "source": 18
- },
- {
- "target": 222,
- "source": 61
- },
- {
- "target": 223,
- "source": 185
- },
- {
- "target": 224,
- "source": 62
- },
- {
- "target": 225,
- "source": 55
- },
- {
- "target": 226,
- "source": 51
- },
- {
- "target": 227,
- "source": 21
- },
- {
- "target": 228,
- "source": 48
- },
- {
- "target": 229,
- "source": 175
- },
- {
- "target": 230,
- "source": 3
- },
- {
- "target": 231,
- "source": 25
- },
- {
- "target": 232,
- "source": 143
- },
- {
- "target": 233,
- "source": 229
- },
- {
- "target": 234,
- "source": 172
- },
- {
- "target": 235,
- "source": 32
- },
- {
- "target": 236,
- "source": 56
- },
- {
- "target": 237,
- "source": 168
- },
- {
- "target": 238,
- "source": 143
- },
- {
- "target": 239,
- "source": 1
- },
- {
- "target": 240,
- "source": 125
- },
- {
- "target": 241,
- "source": 60
- },
- {
- "target": 242,
- "source": 150
- },
- {
- "target": 243,
- "source": 238
- },
- {
- "target": 244,
- "source": 76
- },
- {
- "target": 245,
- "source": 129
- },
- {
- "target": 246,
- "source": 58
- },
- {
- "target": 247,
- "source": 232
- },
- {
- "target": 248,
- "source": 80
- },
- {
- "target": 249,
- "source": 39
- },
- {
- "target": 250,
- "source": 143
- },
- {
- "target": 251,
- "source": 47
- },
- {
- "target": 252,
- "source": 13
- },
- {
- "target": 253,
- "source": 191
- },
- {
- "target": 254,
- "source": 60
- },
- {
- "target": 255,
- "source": 52
- },
- {
- "target": 256,
- "source": 224
- },
- {
- "target": 257,
- "source": 109
- },
- {
- "target": 258,
- "source": 1
- },
- {
- "target": 259,
- "source": 66
- },
- {
- "target": 260,
- "source": 2
- },
- {
- "target": 261,
- "source": 143
- },
- {
- "target": 262,
- "source": 40
- },
- {
- "target": 263,
- "source": 202
- },
- {
- "target": 264,
- "source": 104
- },
- {
- "target": 265,
- "source": 116
- },
- {
- "target": 266,
- "source": 154
- },
- {
- "target": 267,
- "source": 120
- },
- {
- "target": 268,
- "source": 226
- },
- {
- "target": 269,
- "source": 245
- },
- {
- "target": 270,
- "source": 128
- },
- {
- "target": 271,
- "source": 125
- },
- {
- "target": 272,
- "source": 216
- },
- {
- "target": 273,
- "source": 263
- },
- {
- "target": 274,
- "source": 98
- },
- {
- "target": 275,
- "source": 118
- },
- {
- "target": 276,
- "source": 55
- },
- {
- "target": 277,
- "source": 132
- },
- {
- "target": 278,
- "source": 173
- },
- {
- "target": 279,
- "source": 50
- },
- {
- "target": 280,
- "source": 63
- },
- {
- "target": 281,
- "source": 197
- },
- {
- "target": 282,
- "source": 153
- },
- {
- "target": 283,
- "source": 243
- },
- {
- "target": 284,
- "source": 195
- },
- {
- "target": 285,
- "source": 98
- },
- {
- "target": 286,
- "source": 45
- },
- {
- "target": 287,
- "source": 274
- },
- {
- "target": 288,
- "source": 152
- },
- {
- "target": 289,
- "source": 228
- },
- {
- "target": 290,
- "source": 49
- },
- {
- "target": 291,
- "source": 130
- },
- {
- "target": 292,
- "source": 197
- },
- {
- "target": 293,
- "source": 162
- },
- {
- "target": 294,
- "source": 115
- },
- {
- "target": 295,
- "source": 66
- },
- {
- "target": 296,
- "source": 181
- },
- {
- "target": 297,
- "source": 50
- },
- {
- "target": 298,
- "source": 14
- },
- {
- "target": 299,
- "source": 101
- },
- {
- "target": 300,
- "source": 126
- },
- {
- "target": 301,
- "source": 236
- },
- {
- "target": 302,
- "source": 195
- },
- {
- "target": 303,
- "source": 224
- },
- {
- "target": 304,
- "source": 129
- },
- {
- "target": 305,
- "source": 171
- },
- {
- "target": 306,
- "source": 233
- },
- {
- "target": 307,
- "source": 103
- },
- {
- "target": 308,
- "source": 36
- },
- {
- "target": 309,
- "source": 162
- },
- {
- "target": 310,
- "source": 100
- },
- {
- "target": 311,
- "source": 130
- },
- {
- "target": 312,
- "source": 123
- },
- {
- "target": 313,
- "source": 158
- },
- {
- "target": 314,
- "source": 258
- },
- {
- "target": 315,
- "source": 148
- },
- {
- "target": 316,
- "source": 70
- },
- {
- "target": 317,
- "source": 159
- },
- {
- "target": 318,
- "source": 257
- },
- {
- "target": 319,
- "source": 306
- },
- {
- "target": 320,
- "source": 307
- },
- {
- "target": 321,
- "source": 55
- },
- {
- "target": 322,
- "source": 64
- },
- {
- "target": 323,
- "source": 319
- },
- {
- "target": 324,
- "source": 121
- },
- {
- "target": 325,
- "source": 7
- },
- {
- "target": 326,
- "source": 207
- },
- {
- "target": 327,
- "source": 280
- },
- {
- "target": 328,
- "source": 121
- },
- {
- "target": 329,
- "source": 13
- },
- {
- "target": 330,
- "source": 59
- },
- {
- "target": 331,
- "source": 292
- },
- {
- "target": 332,
- "source": 267
- },
- {
- "target": 333,
- "source": 79
- },
- {
- "target": 334,
- "source": 113
- },
- {
- "target": 335,
- "source": 250
- },
- {
- "target": 336,
- "source": 4
- },
- {
- "target": 337,
- "source": 253
- },
- {
- "target": 338,
- "source": 34
- },
- {
- "target": 339,
- "source": 20
- },
- {
- "target": 340,
- "source": 160
- },
- {
- "target": 341,
- "source": 138
- },
- {
- "target": 342,
- "source": 45
- },
- {
- "target": 343,
- "source": 209
- },
- {
- "target": 344,
- "source": 173
- },
- {
- "target": 345,
- "source": 99
- },
- {
- "target": 346,
- "source": 111
- },
- {
- "target": 347,
- "source": 273
- },
- {
- "target": 348,
- "source": 267
- },
- {
- "target": 349,
- "source": 127
- },
- {
- "target": 350,
- "source": 310
- },
- {
- "target": 351,
- "source": 144
- },
- {
- "target": 352,
- "source": 274
- },
- {
- "target": 353,
- "source": 339
- },
- {
- "target": 354,
- "source": 308
- },
- {
- "target": 355,
- "source": 317
- },
- {
- "target": 356,
- "source": 130
- },
- {
- "target": 357,
- "source": 328
- },
- {
- "target": 358,
- "source": 342
- },
- {
- "target": 359,
- "source": 20
- },
- {
- "target": 360,
- "source": 155
- },
- {
- "target": 361,
- "source": 348
- },
- {
- "target": 362,
- "source": 119
- },
- {
- "target": 363,
- "source": 240
- },
- {
- "target": 364,
- "source": 176
- },
- {
- "target": 365,
- "source": 344
- },
- {
- "target": 366,
- "source": 306
- },
- {
- "target": 367,
- "source": 88
- },
- {
- "target": 368,
- "source": 56
- },
- {
- "target": 369,
- "source": 194
- },
- {
- "target": 370,
- "source": 136
- },
- {
- "target": 371,
- "source": 100
- },
- {
- "target": 372,
- "source": 233
- },
- {
- "target": 373,
- "source": 301
- },
- {
- "target": 374,
- "source": 373
- },
- {
- "target": 375,
- "source": 329
- },
- {
- "target": 376,
- "source": 302
- },
- {
- "target": 377,
- "source": 87
- },
- {
- "target": 378,
- "source": 16
- },
- {
- "target": 379,
- "source": 72
- },
- {
- "target": 380,
- "source": 144
- },
- {
- "target": 381,
- "source": 112
- },
- {
- "target": 382,
- "source": 88
- },
- {
- "target": 383,
- "source": 374
- },
- {
- "target": 384,
- "source": 213
- },
- {
- "target": 385,
- "source": 168
- },
- {
- "target": 386,
- "source": 14
- },
- {
- "target": 387,
- "source": 301
- },
- {
- "target": 388,
- "source": 76
- },
- {
- "target": 389,
- "source": 140
- },
- {
- "target": 390,
- "source": 187
- },
- {
- "target": 391,
- "source": 243
- },
- {
- "target": 392,
- "source": 249
- },
- {
- "target": 393,
- "source": 154
- },
- {
- "target": 394,
- "source": 131
- },
- {
- "target": 395,
- "source": 322
- },
- {
- "target": 396,
- "source": 1
- },
- {
- "target": 397,
- "source": 176
- },
- {
- "target": 398,
- "source": 187
- },
- {
- "target": 399,
- "source": 80
- },
- {
- "target": 400,
- "source": 211
- },
- {
- "target": 401,
- "source": 17
- },
- {
- "target": 402,
- "source": 294
- },
- {
- "target": 403,
- "source": 57
- },
- {
- "target": 404,
- "source": 135
- },
- {
- "target": 405,
- "source": 228
- },
- {
- "target": 406,
- "source": 227
- },
- {
- "target": 407,
- "source": 245
- },
- {
- "target": 408,
- "source": 237
- },
- {
- "target": 409,
- "source": 262
- },
- {
- "target": 410,
- "source": 66
- },
- {
- "target": 411,
- "source": 128
- },
- {
- "target": 412,
- "source": 30
- },
- {
- "target": 413,
- "source": 37
- },
- {
- "target": 414,
- "source": 172
- },
- {
- "target": 415,
- "source": 188
- },
- {
- "target": 416,
- "source": 191
- },
- {
- "target": 417,
- "source": 251
- },
- {
- "target": 418,
- "source": 382
- },
- {
- "target": 419,
- "source": 138
- },
- {
- "target": 420,
- "source": 354
- },
- {
- "target": 421,
- "source": 203
- },
- {
- "target": 422,
- "source": 220
- },
- {
- "target": 423,
- "source": 404
- },
- {
- "target": 424,
- "source": 178
- },
- {
- "target": 425,
- "source": 72
- },
- {
- "target": 426,
- "source": 329
- },
- {
- "target": 427,
- "source": 119
- },
- {
- "target": 428,
- "source": 206
- },
- {
- "target": 429,
- "source": 287
- },
- {
- "target": 430,
- "source": 315
- },
- {
- "target": 431,
- "source": 62
- },
- {
- "target": 432,
- "source": 366
- },
- {
- "target": 433,
- "source": 290
- },
- {
- "target": 434,
- "source": 196
- },
- {
- "target": 435,
- "source": 132
- },
- {
- "target": 436,
- "source": 172
- },
- {
- "target": 437,
- "source": 286
- },
- {
- "target": 438,
- "source": 172
- },
- {
- "target": 439,
- "source": 207
- },
- {
- "target": 440,
- "source": 316
- },
- {
- "target": 441,
- "source": 127
- },
- {
- "target": 442,
- "source": 350
- },
- {
- "target": 443,
- "source": 114
- },
- {
- "target": 444,
- "source": 440
- },
- {
- "target": 445,
- "source": 174
- },
- {
- "target": 446,
- "source": 324
- },
- {
- "target": 447,
- "source": 154
- },
- {
- "target": 448,
- "source": 349
- },
- {
- "target": 449,
- "source": 170
- },
- {
- "target": 450,
- "source": 229
- },
- {
- "target": 451,
- "source": 171
- },
- {
- "target": 452,
- "source": 271
- },
- {
- "target": 453,
- "source": 24
- },
- {
- "target": 454,
- "source": 91
- },
- {
- "target": 455,
- "source": 61
- },
- {
- "target": 456,
- "source": 37
- },
- {
- "target": 457,
- "source": 235
- },
- {
- "target": 458,
- "source": 412
- },
- {
- "target": 459,
- "source": 299
- },
- {
- "target": 460,
- "source": 177
- },
- {
- "target": 461,
- "source": 447
- },
- {
- "target": 462,
- "source": 43
- },
- {
- "target": 463,
- "source": 415
- },
- {
- "target": 464,
- "source": 363
- },
- {
- "target": 465,
- "source": 9
- },
- {
- "target": 466,
- "source": 312
- },
- {
- "target": 467,
- "source": 138
- },
- {
- "target": 468,
- "source": 209
- },
- {
- "target": 469,
- "source": 425
- },
- {
- "target": 470,
- "source": 376
- },
- {
- "target": 471,
- "source": 379
- },
- {
- "target": 472,
- "source": 252
- },
- {
- "target": 473,
- "source": 129
- },
- {
- "target": 474,
- "source": 30
- },
- {
- "target": 475,
- "source": 325
- },
- {
- "target": 476,
- "source": 411
- },
- {
- "target": 477,
- "source": 264
- },
- {
- "target": 478,
- "source": 346
- },
- {
- "target": 479,
- "source": 468
- },
- {
- "target": 480,
- "source": 67
- },
- {
- "target": 481,
- "source": 438
- },
- {
- "target": 482,
- "source": 374
- },
- {
- "target": 483,
- "source": 173
- },
- {
- "target": 484,
- "source": 198
- },
- {
- "target": 485,
- "source": 22
- },
- {
- "target": 486,
- "source": 159
- },
- {
- "target": 487,
- "source": 172
- },
- {
- "target": 488,
- "source": 13
- },
- {
- "target": 489,
- "source": 127
- },
- {
- "target": 490,
- "source": 337
- },
- {
- "target": 491,
- "source": 59
- },
- {
- "target": 492,
- "source": 229
- },
- {
- "target": 493,
- "source": 177
- },
- {
- "target": 494,
- "source": 117
- },
- {
- "target": 495,
- "source": 290
- },
- {
- "target": 496,
- "source": 81
- },
- {
- "target": 497,
- "source": 247
- },
- {
- "target": 498,
- "source": 149
- },
- {
- "target": 499,
- "source": 227
- },
- {
- "target": 500,
- "source": 393
- },
- {
- "target": 501,
- "source": 221
- },
- {
- "target": 502,
- "source": 345
- },
- {
- "target": 503,
- "source": 413
- },
- {
- "target": 504,
- "source": 247
- },
- {
- "target": 505,
- "source": 281
- },
- {
- "target": 506,
- "source": 294
- },
- {
- "target": 507,
- "source": 463
- },
- {
- "target": 508,
- "source": 119
- },
- {
- "target": 509,
- "source": 72
- },
- {
- "target": 510,
- "source": 207
- },
- {
- "target": 511,
- "source": 380
- },
- {
- "target": 512,
- "source": 409
- },
- {
- "target": 513,
- "source": 331
- },
- {
- "target": 514,
- "source": 444
- },
- {
- "target": 515,
- "source": 334
- },
- {
- "target": 516,
- "source": 228
- },
- {
- "target": 517,
- "source": 51
- },
- {
- "target": 518,
- "source": 12
- },
- {
- "target": 519,
- "source": 290
- },
- {
- "target": 520,
- "source": 433
- },
- {
- "target": 521,
- "source": 312
- },
- {
- "target": 522,
- "source": 483
- },
- {
- "target": 523,
- "source": 469
- },
- {
- "target": 524,
- "source": 7
- },
- {
- "target": 525,
- "source": 357
- },
- {
- "target": 526,
- "source": 146
- },
- {
- "target": 527,
- "source": 251
- },
- {
- "target": 528,
- "source": 43
- },
- {
- "target": 529,
- "source": 379
- },
- {
- "target": 530,
- "source": 439
- },
- {
- "target": 531,
- "source": 214
- },
- {
- "target": 532,
- "source": 366
- },
- {
- "target": 533,
- "source": 56
- },
- {
- "target": 534,
- "source": 25
- },
- {
- "target": 535,
- "source": 534
- },
- {
- "target": 536,
- "source": 162
- },
- {
- "target": 537,
- "source": 45
- },
- {
- "target": 538,
- "source": 180
- },
- {
- "target": 539,
- "source": 56
- },
- {
- "target": 540,
- "source": 417
- },
- {
- "target": 541,
- "source": 372
- },
- {
- "target": 542,
- "source": 534
- },
- {
- "target": 543,
- "source": 264
- },
- {
- "target": 544,
- "source": 197
- },
- {
- "target": 545,
- "source": 496
- },
- {
- "target": 546,
- "source": 221
- },
- {
- "target": 547,
- "source": 238
- },
- {
- "target": 548,
- "source": 97
- },
- {
- "target": 549,
- "source": 229
- },
- {
- "target": 550,
- "source": 240
- },
- {
- "target": 551,
- "source": 213
- },
- {
- "target": 552,
- "source": 523
- },
- {
- "target": 553,
- "source": 293
- },
- {
- "target": 554,
- "source": 287
- },
- {
- "target": 555,
- "source": 360
- },
- {
- "target": 556,
- "source": 467
- },
- {
- "target": 557,
- "source": 419
- },
- {
- "target": 558,
- "source": 136
- },
- {
- "target": 559,
- "source": 427
- },
- {
- "target": 560,
- "source": 20
- },
- {
- "target": 561,
- "source": 218
- },
- {
- "target": 562,
- "source": 540
- },
- {
- "target": 563,
- "source": 30
- },
- {
- "target": 564,
- "source": 135
- },
- {
- "target": 565,
- "source": 51
- },
- {
- "target": 566,
- "source": 450
- },
- {
- "target": 567,
- "source": 191
- },
- {
- "target": 568,
- "source": 414
- },
- {
- "target": 569,
- "source": 338
- },
- {
- "target": 570,
- "source": 188
- },
- {
- "target": 571,
- "source": 1
- },
- {
- "target": 572,
- "source": 498
- },
- {
- "target": 573,
- "source": 198
- },
- {
- "target": 574,
- "source": 35
- },
- {
- "target": 575,
- "source": 207
- },
- {
- "target": 576,
- "source": 205
- },
- {
- "target": 577,
- "source": 240
- },
- {
- "target": 578,
- "source": 330
- },
- {
- "target": 579,
- "source": 174
- },
- {
- "target": 580,
- "source": 156
- },
- {
- "target": 581,
- "source": 441
- },
- {
- "target": 582,
- "source": 482
- },
- {
- "target": 583,
- "source": 283
- },
- {
- "target": 584,
- "source": 448
- },
- {
- "target": 585,
- "source": 382
- },
- {
- "target": 586,
- "source": 484
- },
- {
- "target": 587,
- "source": 493
- },
- {
- "target": 588,
- "source": 491
- },
- {
- "target": 589,
- "source": 404
- },
- {
- "target": 590,
- "source": 9
- },
- {
- "target": 591,
- "source": 304
- },
- {
- "target": 592,
- "source": 261
- },
- {
- "target": 593,
- "source": 398
- },
- {
- "target": 594,
- "source": 375
- },
- {
- "target": 595,
- "source": 158
- },
- {
- "target": 596,
- "source": 149
- },
- {
- "target": 597,
- "source": 517
- },
- {
- "target": 598,
- "source": 25
- },
- {
- "target": 599,
- "source": 545
}
]
}
diff --git a/app/screens/graph/graph-screen.tsx b/app/screens/graph/graph-screen.tsx
index 2ae956c..9f1f08c 100644
--- a/app/screens/graph/graph-screen.tsx
+++ b/app/screens/graph/graph-screen.tsx
@@ -15,6 +15,8 @@ import AsyncStorage from "@react-native-async-storage/async-storage"
import axios from "axios";
+import rando from "../../data/rando.json"
+
const ROOT: ViewStyle = {
backgroundColor: color.palette.black,
flex: 1,
@@ -27,7 +29,10 @@ export const GraphScreen = observer(function GraphScreen() {
// Pull in navigation via hook
// const navigation = useNavigation()
+
const [physics, setPhysics] = useState({})
+ const [graphData, setGraphData] = useState();
+ // { "nodes": [{ "id": 1 }, { "id": 2 }], "links": [{ "target": 1, "source": 2 }] });
const physicsInit = {
charge: -30,
collision: false,
@@ -45,10 +50,10 @@ export const GraphScreen = observer(function GraphScreen() {
const getData = async () => {
try {
const value: string = await AsyncStorage.getItem("@physics");
- if (value !== null ) {
- const valueJson = JSON.parse(value);
- if ( Object.keys(valueJson).length === Object.keys(physicsInit).length) {
- return valueJson;
+ if (value !== null) {
+ const valueJson = JSON.parse(value);
+ if (Object.keys(valueJson).length === Object.keys(physicsInit).length) {
+ return valueJson;
} else { return physicsInit };
} else {
return physicsInit
@@ -57,19 +62,6 @@ export const GraphScreen = observer(function GraphScreen() {
console.log(e)
}
}
-
- //"ComponentOnMount"
- // Get previous settings and the data from the org-roam-server
- useEffect(() => {
- getData().then((data) => setPhysics(data));
- // axios.get('/roamData')
- // .then(()=>console.log("Whoo got data"))
- //.catch((e)=>{
- // console.log(e);
- // console.log("Couldn't get data.");
- //});
- }, [])
-
const storeData = async (value) => {
try {
const jsonValue = JSON.stringify(value)
@@ -93,14 +85,54 @@ export const GraphScreen = observer(function GraphScreen() {
console.log(test)
}, 1000)
return () => clearTimeout(timer)
- }, [physics])
+ }, [physics]);
- const gData = genRandomTree()
+ //"ComponentOnMount"
+ // Get previous settings and the data from the org-roam-server
+ const sanitizeGraph = (data, nodeIds: string[]) => {
+ const cleanLinks = [];
+ data.links.forEach((link, i) => {
+ for (i=0; i<=nodeIds.length; i++){
+ if (link.target === nodeIds[i]) {
+ cleanLinks.push(link);
+ break;
+ };
+ };
+ });
+ console.log(cleanLinks);
+ data.links = cleanLinks;
+ return data;
+ };
- return (
- <Screen style={ROOT} preset="scroll">
- <Tweaks physics={physics} setPhysics={setPhysics} />
- <Graph physics={physics} gData={gData} />
- </Screen>
- )
-})
+ const getNodesById = (data) => {
+ const nodeIds: string[] = [];
+ data.nodes.forEach(node => nodeIds.push(node.id));
+ return nodeIds;
+ };
+
+ useEffect(() => {
+ getData().then((data) => setPhysics(data));
+ axios.get("http://localhost:35901/graph")
+ .then((dataa) => {
+ const nodeIds = getNodesById(dataa.data);
+ console.log(nodeIds);
+ const cleanData = sanitizeGraph(dataa.data, nodeIds);
+ console.log(cleanData)
+ setGraphData(cleanData);
+ })
+ .catch((e) => {
+ console.log(e);
+ console.log("Couldn't get data.");
+ //setGraphData(rando);
+ });
+ }, [])
+ if (!graphData) { return null }
+ else {
+ return (
+ <Screen style={ROOT} preset="scroll">
+ <Tweaks physics={physics} setPhysics={setPhysics} />
+ <Graph physics={physics} gData={graphData} />
+ </Screen>
+ )
+ }
+ })
diff --git a/org-roam-ui.el b/org-roam-ui.el
index 2a9547d..3f2c737 100644
--- a/org-roam-ui.el
+++ b/org-roam-ui.el
@@ -35,6 +35,6 @@
(defun links-row-to-cons (row)
(list
(cons 'source (elt row 1))
- (cons 'dest (elt row 2))))
+ (cons 'target (elt row 2))))
(provide 'org-roam-ui)
diff --git a/package.json b/package.json
index aba9265..3935adf 100644
--- a/package.json
+++ b/package.json
@@ -59,6 +59,7 @@
"react-native-keychain": "6.2.0",
"react-native-safe-area-context": "3.1.9",
"react-native-screens": "2.18.1",
+ "react-native-static-server": "^0.5.0",
"react-native-unimodules": "0.12.0",
"react-native-vector-icons": "^8.1.0",
"reactotron-mst": "3.1.3",
@@ -107,6 +108,7 @@
"react-devtools-core": "4.10.1",
"react-dom": "^17.0.2",
"react-native-clean-project": "^3.6.3",
+ "react-native-fs": "^2.18.0",
"react-native-web": "^0.16.3",
"react-powerplug": "1.0.0",
"solidarity": "2.3.1",
diff --git a/yarn.lock b/yarn.lock
index b84e274..e8913af 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5338,6 +5338,11 @@ balanced-match@^1.0.0:
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
+base-64@^0.1.0:
+ version "0.1.0"
+ resolved "https://registry.yarnpkg.com/base-64/-/base-64-0.1.0.tgz#780a99c84e7d600260361511c4877613bf24f6bb"
+ integrity sha1-eAqZyE59YAJgNhURxId2E78k9rs=
+
version "1.2.0"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.0.tgz#a39992d723584811982be5e290bb6a53d86700f1"
@@ -16050,6 +16055,14 @@ react-native-flipper@^0.34.0:
resolved "https://registry.yarnpkg.com/react-native-flipper/-/react-native-flipper-0.34.0.tgz#7df1f38ba5d97a9321125fe0fccbe47d99e6fa1d"
integrity sha512-48wgm29HJTOlZ0DibBsvXueEOY0EPIVL0wWKbwRfgrk86+luSEuLW3aZC50oJa95zSFb9qYShTV/6dWqh4Jamg==
+react-native-fs@^2.18.0:
+ version "2.18.0"
+ resolved "https://registry.yarnpkg.com/react-native-fs/-/react-native-fs-2.18.0.tgz#987b99cc90518ef26663a8d60e62104694b41c21"
+ integrity sha512-9iQhkUNnN2JNED0in06JwZy88YEVyIGKWz4KLlQYxa5Y2U0U2AZh9FUHtA04oWj+xt2LlHh0LFPCzhmNsAsUDg==
+ dependencies:
+ base-64 "^0.1.0"
+ utf8 "^3.0.0"
+
version "1.10.3"
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-1.10.3.tgz#942bbf2963bbf49fa79593600ee9d7b5dab3cfc0"
@@ -16081,6 +16094,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/react-native-screens/-/react-native-screens-2.18.1.tgz#47b9991c6f762d00d0ed3233e5283d523e859885"
integrity sha512-r5WZLpmx2hHjC1RgMdPq5YpSU9tEhBpUaZ5M1SUtNIONyiLqQVxabhRCINdebIk4depJiIl7yw2Q85zJyeX6fw==
+react-native-static-server@^0.5.0:
+ version "0.5.0"
+ resolved "https://registry.yarnpkg.com/react-native-static-server/-/react-native-static-server-0.5.0.tgz#4b396082bfe7dfdbba6fe7d7de894de5ba4ebadb"
+ integrity sha512-RGteckPoBZq48p9Y8V67bjZGPxLHKkEOAffLSUJiGC7hkx+H+zuekqCR+04F30NuWB7y+nb8N7Qld2RGjX5DNg==
+
react-native-swipe-gestures@^1.0.4:
version "1.0.5"
resolved "https://registry.yarnpkg.com/react-native-swipe-gestures/-/react-native-swipe-gestures-1.0.5.tgz#a172cb0f3e7478ccd681fd36b8bfbcdd098bde7c"
@@ -19134,6 +19152,11 @@ utf8-byte-length@^1.0.1:
resolved "https://registry.yarnpkg.com/utf8-byte-length/-/utf8-byte-length-1.0.4.tgz#f45f150c4c66eee968186505ab93fcbb8ad6bf61"
integrity sha1-9F8VDExm7uloGGUFq5P8u4rWv2E=
+utf8@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/utf8/-/utf8-3.0.0.tgz#f052eed1364d696e769ef058b183df88c87f69d1"
+ integrity sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ==
+
utif@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/utif/-/utif-2.0.1.tgz#9e1582d9bbd20011a6588548ed3266298e711759"