@@ -6,101 +6,94 @@ import DefaultEdgeLabelRenderer from '@/components/graphs/labels/renderers/Defau
66import { DirectedGraph } from '@/models/graphs' ;
77import PannableScalableView from '@/views/PannableScalableView' ;
88
9- import GraphEventsProvider from './context/graphEvents' ;
10-
11- const CATEGORIES_GRAPH = {
9+ const GRAPH1 = {
1210 vertices : [
13- { key : 'Root' , data : [ ] } ,
14- { key : 'Sport' , data : [ ] } ,
15- { key : 'Health' , data : [ ] } ,
16- { key : 'Diet' , data : [ ] } ,
17- { key : 'Sleep' , data : [ ] } ,
18- { key : 'Work' , data : [ ] }
11+ { key : 'A' , data : 'A' } ,
12+ { key : 'B' , data : 'B' } ,
13+ { key : 'C' , data : 'C' } ,
14+ { key : 'D' , data : 'D' } ,
15+ { key : 'E' , data : 'E' }
1916 ] ,
2017 edges : [
21- { from : 'Root' , to : 'Sport' , key : 'E1' , data : [ ] } ,
22- { from : 'Root' , to : 'Health' , key : 'E2' , data : [ ] } ,
23- { from : 'Root' , to : 'Diet' , key : 'E3' , data : [ ] } ,
24- { from : 'Root' , to : 'Sleep' , key : 'E4' , data : [ ] } ,
25- { from : 'Root' , to : 'Work' , key : 'E5' , data : [ ] }
18+ { key : 'AB' , from : 'A' , to : 'B' , data : 'AB' } ,
19+ { key : 'AC' , from : 'A' , to : 'C' , data : 'AC' } ,
20+ { key : 'AD' , from : 'A' , to : 'D' , data : 'AD' } ,
21+ { key : 'AE' , from : 'A' , to : 'E' , data : 'AE' }
2622 ]
2723} ;
2824
29- const SPORT_GRAPH = {
25+ const GRAPH2 = {
3026 vertices : [
31- { key : 'Sport' , data : [ ] } ,
32- { key : 'Football' , data : [ ] } ,
33- { key : 'Basketball' , data : [ ] } ,
34- { key : 'Gym' , data : [ ] } ,
35- { key : 'Running' , data : [ ] } ,
36- { key : 'Cycling' , data : [ ] } ,
37- { key : 'Root' , data : [ ] }
27+ { key : 'F' , data : 'F' } ,
28+ { key : 'G' , data : 'G' } ,
29+ { key : 'H' , data : 'H' } ,
30+ { key : 'I' , data : 'I' } ,
31+ { key : 'J' , data : 'J' } ,
32+ { key : 'K' , data : 'K' } ,
33+ { key : 'L' , data : 'L' } ,
34+ { key : 'M' , data : 'M' } ,
35+ { key : 'N' , data : 'N' } ,
36+ { key : 'O' , data : 'O' }
3837 ] ,
3938 edges : [
40- { from : 'Sport' , to : 'Football' , key : 'E1' , data : [ ] } ,
41- { from : 'Sport' , to : 'Basketball' , key : 'E2' , data : [ ] } ,
42- { from : 'Sport' , to : 'Gym' , key : 'E3' , data : [ ] } ,
43- { from : 'Sport' , to : 'Running' , key : 'E4' , data : [ ] } ,
44- { from : 'Sport' , to : 'Cycling' , key : 'E5' , data : [ ] } ,
45- { from : 'Root' , to : 'Sport' , key : 'E6' , data : [ ] }
39+ { key : 'FG' , from : 'F' , to : 'G' , data : 'FG' } ,
40+ { key : 'FH' , from : 'F' , to : 'H' , data : 'FH' } ,
41+ { key : 'FI' , from : 'F' , to : 'I' , data : 'FI' } ,
42+ { key : 'GJ' , from : 'G' , to : 'J' , data : 'GJ' } ,
43+ { key : 'GK' , from : 'G' , to : 'K' , data : 'GK' } ,
44+ { key : 'GL' , from : 'G' , to : 'L' , data : 'GL' } ,
45+ { key : 'GM' , from : 'G' , to : 'M' , data : 'GM' } ,
46+ { key : 'GN' , from : 'G' , to : 'N' , data : 'GN' } ,
47+ { key : 'GO' , from : 'G' , to : 'O' , data : 'GO' }
4648 ]
4749} ;
4850
49- const GYM_GRAPH = {
51+ const GRAPH3 = {
5052 vertices : [
51- { key : 'Gym' , data : [ ] } ,
52- { key : 'Bench Press' , data : [ ] } ,
53- { key : 'Squats' , data : [ ] } ,
54- { key : 'Deadlift' , data : [ ] } ,
55- { key : 'Push Ups' , data : [ ] } ,
56- { key : 'Sport' , data : [ ] }
53+ { key : 'P' , data : 'P' } ,
54+ { key : 'Q' , data : 'Q' }
5755 ] ,
5856 edges : [
59- { from : 'Gym' , to : 'Bench Press' , key : 'E1' , data : [ ] } ,
60- { from : 'Gym' , to : 'Squats' , key : 'E2' , data : [ ] } ,
61- { from : 'Gym' , to : 'Deadlift' , key : 'E3' , data : [ ] } ,
62- { from : 'Gym' , to : 'Push Ups' , key : 'E5' , data : [ ] } ,
63- { from : 'Sport' , to : 'Gym' , key : 'E6' , data : [ ] }
57+ { key : 'PQ1' , from : 'P' , to : 'Q' , data : 'PQ1' } ,
58+ { key : 'PQ2' , from : 'P' , to : 'Q' , data : 'PQ2' }
6459 ]
6560} ;
6661
62+ const DISCONNECTED_GRAPH = {
63+ vertices : [ ...GRAPH1 . vertices , ...GRAPH2 . vertices , ...GRAPH3 . vertices ] ,
64+ edges : [ ...GRAPH1 . edges , ...GRAPH2 . edges , ...GRAPH3 . edges ]
65+ } ;
66+
6767export default function App ( ) {
6868 const graph = DirectedGraph . fromData (
69- CATEGORIES_GRAPH . vertices ,
70- CATEGORIES_GRAPH . edges
69+ DISCONNECTED_GRAPH . vertices ,
70+ DISCONNECTED_GRAPH . edges
7171 ) ;
7272
7373 return (
7474 < SafeAreaView className = 'grow' >
7575 < GestureHandlerRootView className = 'grow' >
7676 < View className = 'grow bg-black' >
77- < GraphEventsProvider
78- onVertexPress = { ( { key } ) => {
79- if ( key === 'Sport' ) {
80- graph . replaceBatch ( SPORT_GRAPH ) ;
81- } else if ( key === 'Gym' ) {
82- graph . replaceBatch ( GYM_GRAPH ) ;
83- } else if ( key === 'Root' ) {
84- graph . replaceBatch ( CATEGORIES_GRAPH ) ;
85- }
86- } } >
87- < PannableScalableView objectFit = 'contain' controls >
88- < DirectedGraphComponent
89- graph = { graph }
90- settings = { {
91- // TODO - fix orbits strategy padding
92- placement : {
93- strategy : 'orbits' ,
94- layerSizing : 'equal' ,
95- minVertexSpacing : 125
77+ < PannableScalableView objectFit = 'contain' controls >
78+ < DirectedGraphComponent
79+ graph = { graph }
80+ settings = { {
81+ // TODO - fix orbits strategy padding
82+ placement : {
83+ strategy : 'circles' ,
84+ minVertexSpacing : 100
85+ } ,
86+ components : {
87+ edge : {
88+ type : 'curved'
9689 }
97- } }
98- renderers = { {
99- label : DefaultEdgeLabelRenderer
100- } }
101- />
102- </ PannableScalableView >
103- </ GraphEventsProvider >
90+ }
91+ } }
92+ renderers = { {
93+ label : DefaultEdgeLabelRenderer
94+ } }
95+ / >
96+ </ PannableScalableView >
10497 </ View >
10598 </ GestureHandlerRootView >
10699 </ SafeAreaView >
0 commit comments