@@ -28,7 +28,7 @@ const FloatingControlCard = ({
2828 handlePhysicsChange : ( name : string , value : any ) => void ,
2929 restartStabilization : ( ) => void ,
3030} ) => {
31- const handleSliderChange = ( name : string ) => ( event , value : any ) => {
31+ const handleSliderChange = ( name : string ) => ( event : any , value : any ) => {
3232 handlePhysicsChange ( name , value ) ;
3333 restartStabilization ( ) ;
3434 } ;
@@ -40,31 +40,31 @@ const FloatingControlCard = ({
4040 < Box >
4141 < SliderControl
4242 label = "Gravitational Constant"
43- value = { physicsOptions . gravitationalConstant }
43+ value = { physicsOptions . gravitationalConstant ?? - 2000 }
4444 min = { - 30000 }
4545 max = { 0 }
4646 step = { 1000 }
4747 onChange = { handleSliderChange ( 'gravitationalConstant' ) }
4848 />
4949 < SliderControl
5050 label = "Spring Length"
51- value = { physicsOptions . springLength }
51+ value = { physicsOptions . springLength ?? 100 }
5252 min = { 50 }
5353 max = { 300 }
5454 step = { 10 }
5555 onChange = { handleSliderChange ( 'springLength' ) }
5656 />
5757 < SliderControl
5858 label = "Spring Constant"
59- value = { physicsOptions . springConstant }
59+ value = { physicsOptions . springConstant ?? 0.04 }
6060 min = { 0.01 }
6161 max = { 0.5 }
6262 step = { 0.01 }
6363 onChange = { handleSliderChange ( 'springConstant' ) }
6464 />
6565 < SliderControl
6666 label = "Damping"
67- value = { physicsOptions . damping }
67+ value = { physicsOptions . damping ?? 0.09 }
6868 min = { 0.01 }
6969 max = { 1 }
7070 step = { 0.01 }
@@ -77,31 +77,31 @@ const FloatingControlCard = ({
7777 < Box >
7878 < SliderControl
7979 label = "Gravitational Constant"
80- value = { physicsOptions . gravitationalConstant }
80+ value = { physicsOptions . gravitationalConstant ?? - 50 }
8181 min = { - 200 }
8282 max = { 0 }
8383 step = { 10 }
8484 onChange = { handleSliderChange ( 'gravitationalConstant' ) }
8585 />
8686 < SliderControl
8787 label = "Spring Length"
88- value = { physicsOptions . springLength }
88+ value = { physicsOptions . springLength ?? 100 }
8989 min = { 50 }
9090 max = { 300 }
9191 step = { 10 }
9292 onChange = { handleSliderChange ( 'springLength' ) }
9393 />
9494 < SliderControl
9595 label = "Spring Constant"
96- value = { physicsOptions . springConstant }
96+ value = { physicsOptions . springConstant ?? 0.08 }
9797 min = { 0.01 }
9898 max = { 0.5 }
9999 step = { 0.01 }
100100 onChange = { handleSliderChange ( 'springConstant' ) }
101101 />
102102 < SliderControl
103103 label = "Damping"
104- value = { physicsOptions . damping }
104+ value = { physicsOptions . damping ?? 0.4 }
105105 min = { 0.01 }
106106 max = { 1 }
107107 step = { 0.01 }
@@ -114,23 +114,23 @@ const FloatingControlCard = ({
114114 < Box >
115115 < SliderControl
116116 label = "Level Separation"
117- value = { physicsOptions . levelSeparation }
117+ value = { physicsOptions . levelSeparation ?? 150 }
118118 min = { 50 }
119119 max = { 500 }
120120 step = { 10 }
121121 onChange = { handleSliderChange ( 'levelSeparation' ) }
122122 />
123123 < SliderControl
124124 label = "Node Spacing"
125- value = { physicsOptions . nodeSpacing }
125+ value = { physicsOptions . nodeSpacing ?? 100 }
126126 min = { 50 }
127127 max = { 200 }
128128 step = { 10 }
129129 onChange = { handleSliderChange ( 'nodeSpacing' ) }
130130 />
131131 < SliderControl
132132 label = "Tree Spacing"
133- value = { physicsOptions . treeSpacing }
133+ value = { physicsOptions . treeSpacing ?? 200 }
134134 min = { 50 }
135135 max = { 500 }
136136 step = { 10 }
@@ -163,7 +163,7 @@ const FloatingControlCard = ({
163163 < FormControl fullWidth margin = "normal" >
164164 < InputLabel > Direction</ InputLabel >
165165 < Select
166- value = { physicsOptions . direction }
166+ value = { physicsOptions . direction ?? 'UD' }
167167 onChange = { ( e ) => {
168168 handlePhysicsChange ( 'direction' , e . target . value ) ;
169169 restartStabilization ( ) ;
@@ -178,7 +178,7 @@ const FloatingControlCard = ({
178178 < FormControl fullWidth margin = "normal" >
179179 < InputLabel > Sort Method</ InputLabel >
180180 < Select
181- value = { physicsOptions . sortMethod }
181+ value = { physicsOptions . sortMethod ?? 'hubsize' }
182182 onChange = { ( e ) => {
183183 handlePhysicsChange ( 'sortMethod' , e . target . value ) ;
184184 restartStabilization ( ) ;
@@ -191,7 +191,7 @@ const FloatingControlCard = ({
191191 < FormControl fullWidth margin = "normal" >
192192 < InputLabel > Shake Towards</ InputLabel >
193193 < Select
194- value = { physicsOptions . shakeTowards }
194+ value = { physicsOptions . shakeTowards ?? 'roots' }
195195 onChange = { ( e ) => {
196196 handlePhysicsChange ( 'shakeTowards' , e . target . value ) ;
197197 restartStabilization ( ) ;
@@ -208,39 +208,39 @@ const FloatingControlCard = ({
208208 < Box >
209209 < SliderControl
210210 label = "Node Distance"
211- value = { physicsOptions . nodeDistance }
211+ value = { physicsOptions . nodeDistance ?? 100 }
212212 min = { 50 }
213213 max = { 500 }
214214 step = { 10 }
215215 onChange = { handleSliderChange ( 'nodeDistance' ) }
216216 />
217217 < SliderControl
218218 label = "Central Gravity"
219- value = { physicsOptions . centralGravity }
219+ value = { physicsOptions . centralGravity ?? 0.2 }
220220 min = { 0 }
221221 max = { 1 }
222222 step = { 0.01 }
223223 onChange = { handleSliderChange ( 'centralGravity' ) }
224224 />
225225 < SliderControl
226226 label = "Spring Length"
227- value = { physicsOptions . springLength }
227+ value = { physicsOptions . springLength ?? 200 }
228228 min = { 50 }
229229 max = { 300 }
230230 step = { 10 }
231231 onChange = { handleSliderChange ( 'springLength' ) }
232232 />
233233 < SliderControl
234234 label = "Spring Constant"
235- value = { physicsOptions . springConstant }
235+ value = { physicsOptions . springConstant ?? 0.05 }
236236 min = { 0.01 }
237237 max = { 0.5 }
238238 step = { 0.01 }
239239 onChange = { handleSliderChange ( 'springConstant' ) }
240240 />
241241 < SliderControl
242242 label = "Damping"
243- value = { physicsOptions . damping }
243+ value = { physicsOptions . damping ?? 0.09 }
244244 min = { 0.01 }
245245 max = { 1 }
246246 step = { 0.01 }
@@ -260,7 +260,6 @@ const FloatingControlCard = ({
260260 bottom : '16px' ,
261261 right : '46px' ,
262262 width : '300px' ,
263- // background: '#121826',
264263 color : '#fff' ,
265264 zIndex : 1000 ,
266265 } }
@@ -285,20 +284,16 @@ const FloatingControlCard = ({
285284 style = { { color : '#fff' } }
286285 >
287286 < MenuItem value = "barnesHut" > Barnes Hut</ MenuItem >
288- < MenuItem value = "forceAtlas2Based" >
289- Force Atlas 2 Based
290- </ MenuItem >
291- < MenuItem value = "hierarchicalRepulsion" >
292- Hierarchical Repulsion
293- </ MenuItem >
287+ < MenuItem value = "forceAtlas2Based" > Force Atlas 2 Based</ MenuItem >
288+ < MenuItem value = "hierarchicalRepulsion" > Hierarchical Repulsion</ MenuItem >
294289 < MenuItem value = "repulsion" > Repulsion</ MenuItem >
295290 < MenuItem value = "hierarchical" > Hierarchical</ MenuItem >
296291 </ Select >
297292 </ FormControl >
298293 { renderSliders ( ) }
299294 < SliderControl
300295 label = "Stabilization Iterations"
301- value = { physicsOptions . iterations }
296+ value = { physicsOptions . iterations ?? 1000 }
302297 min = { 0 }
303298 max = { 5000 }
304299 step = { 100 }
0 commit comments