@@ -8,34 +8,59 @@ A simple react component to draw branched graphs consisting of vertices and edge
883 . Use directly in render function. Here's an example explaining all possible props you can pass:
99
1010``` jsx
11- < Graph
12- vertices= {[ // all possible edges
13- " HTML" ,
14- " CSS" ,
15- " jQuery" ,
16- " JavaScript" ,
17- " PHP" ,
18- " Python" ,
19- " Perl" ,
20- " Ruby"
21- ]}
22- edges= {[ // edges between nodes. Please draw a graph on paper first and see for yourself how the edges flow to place a suitable array value here
23- [" HTML" ," CSS" ],
24- [" CSS" , " jQuery" ],
25- [" jQuery" ," JavaScript" ],
26- [" jQuery" , " PHP" ],
27- [" PHP" , " Python" ],
28- [" Python" , " Perl" ],
29- [" Python" , " Ruby" ]
30- ]}
31- orientation= " horizontal" // orientation of graph (whether horizontal or vertical)
32- width= {window .innerWidth } // width of graph
33- height= {window .innerHeight } // height of graph
34- vertexStroke= " #df6766" // color of border of vertices
35- edgeStroke= " #ebb2b2" // color of edge
36- edgeWidth= {2 } // thickness of edge
37- vertexRadius= {10 } // radius of vertex -> bigger the radius, larger the vertex size
38- / >
11+ import React from ' react'
12+ import ReactDOM from ' react-dom'
13+ import Graph from ' reactjs-graphs'
14+
15+ const onClick = (label , index , extras ) => {
16+ console .log (label, index, extras)
17+ }
18+
19+ const vertices = [
20+ { label: " Here it begins" , onClick, extras: " Some helper data" },
21+ { label: " HTML" , onClick },
22+ { label: " CSS" , onClick },
23+ { label: " Sass" , onClick },
24+ { label: " JavaScript" , onClick },
25+ { label: " Bootstrap" , onClick },
26+ { label: " jQuery" , onClick },
27+ { label: " ReactJS" , onClick, extras: " Could be anything, literally" },
28+ { label: " Jest" , onClick },
29+ { label: " Angular" , onClick },
30+ { label: " Vue" , onClick },
31+ { label: " Redux" , onClick },
32+ { label: " React Material" , onClick },
33+ { label: " Vuetify" , onClick },
34+ ]
35+
36+ const edges = [
37+ [" Here it begins" , " HTML" ],
38+ [" HTML" , " CSS" ],
39+ [" CSS" , " JavaScript" ],
40+ [" CSS" , " Sass" ],
41+ [" JavaScript" , " jQuery" ],
42+ [" jQuery" , " Bootstrap" ],
43+ [" jQuery" , " ReactJS" ],
44+ [" jQuery" , " Angular" ],
45+ [" jQuery" , " Vue" ],
46+ [" ReactJS" , " Redux" ],
47+ [" Redux" , " React Material" ],
48+ [" React Material" , " Jest" ],
49+ [" Vue" , " Vuetify" ],
50+ ]
51+
52+
53+ ReactDOM .render (< Graph
54+ vertices= {vertices}
55+ edges= {edges}
56+ orientation= " horizontal"
57+ width= {window .innerWidth }
58+ height= {window .innerHeight }
59+ vertexStroke= " #df6766"
60+ edgeStroke= " #ebb2b2"
61+ edgeWidth= {2 }
62+ vertexRadius= {10 }
63+ / > , document .getElementById (' root' ))
3964```
4065
41664 . The example above would render the following graph:
0 commit comments