@@ -60,7 +60,7 @@ window.Widgets.Panel.Promo = {}
60
60
61
61
62
62
ns . promotable_sim = d3
63
- . forceSimulation ( )
63
+ . forceSimulation ( panelUtilsNs . split . promo . nodes )
64
64
. force ( "link" , d3 . forceLink ( ) // This force provides links between nodes
65
65
. id ( d => d . id ) // This sets the node id accessor to the specified function. If not specified, will default to the index of a node.
66
66
// .distance(500 * ns.options.icon_size)
@@ -203,18 +203,49 @@ window.Widgets.Panel.Promo = {}
203
203
} ) ; //use simulation.on to listen for tick events as the simulation runs.
204
204
205
205
// This function is run at each iteration of the force algorithm, updating the nodes position (the nodes data array is directly manipulated).
206
- ns . promotable_sim . force ( "link" )
207
- . links ( panelUtilsNs . split . promo . edges )
208
- . id ( d => d . id )
209
- . distance ( function ( ) { return 5 * ns . options . icon_size ; } ) ;
206
+ // ns.promotable_sim;
210
207
211
208
// Setup either the Layout, or Default Force Graph
212
- if ( ns . options . promoSim ) {
213
- ns . promotable_sim
214
- . force ( "charge" , d3 . forceManyBody ( ) . strength ( - 500 ) ) // This adds repulsion (if it's negative) between nodes.
215
- // .force("charge", d3.forceManyBody().strength(-500)) // This adds repulsion (if it's negative) between nodes.
209
+ if ( ns . options . promoSim ) {
210
+
211
+
212
+
213
+ ns . promotable_sim
214
+ . force ( "link" )
215
+ . links ( panelUtilsNs . split . promo . edges )
216
+ . id ( d => d . id )
217
+ . distance ( function ( ) { return 4 * ns . options . icon_size ; } )
218
+ . strength ( 0.05 ) ;
219
+
220
+ ns . promotable_sim
221
+ . force ( 'x' , d3 . forceX ( ) . x ( function ( d ) {
222
+ return d . positionX ;
223
+ } ) . strength ( function ( d ) {
224
+ // ignore forceX below the first two layers
225
+ if ( d . positionX === 0 ) {
226
+ return 0 ;
227
+ } else {
228
+ return 1 ;
229
+ }
230
+ } ) )
231
+ . force ( 'y' , d3 . forceY ( ) . y ( function ( d ) {
232
+ return d . positionY ;
233
+ } ) . strength ( 1 ) )
234
+ // .force('collision', d3.forceCollide().radius(function(d) {
235
+ // console.log("d is ->", d)
236
+ // return d.radius;
237
+ // }))
238
+ . force ( "collide" , d3 . forceCollide ( ns . options . icon_size ) )
239
+ // .force("charge", d3.forceManyBody().strength(-200)) // This adds repulsion (if it's negative) between nodes.
240
+ . force ( "charge" , d3 . forceManyBody ( ) . strength ( - 500 ) ) // This adds repulsion (if it's negative) between nodes.
216
241
// .force("center", d3.forceCenter(ns.options.width / 2, ns.options.height / 2)); // This force attracts nodes to the center of the svg area
217
242
} else {
243
+ ns . promotable_sim
244
+ . force ( "link" )
245
+ . links ( panelUtilsNs . split . promo . edges )
246
+ . id ( d => d . id )
247
+ . distance ( function ( ) { return 1.5 * ns . options . icon_size ; } ) ;
248
+
218
249
ns . promotable_sim
219
250
. force ( "charge" , d3 . forceManyBody ( ) . strength ( - 500 ) ) // This adds repulsion (if it's negative) between nodes.
220
251
. force ( "center" , d3 . forceCenter ( ns . options . width / 2 , ns . options . height / 2 ) ) ; // This force attracts nodes to the center of the svg area
0 commit comments