@@ -32,49 +32,39 @@ window.Widgets.Panel.Promo = {}
32
32
return
33
33
}
34
34
// first the variables centreStrength
35
- ns . pforceNode = d3 . forceManyBody ( ) ;
35
+ // ns.pforceNode = d3.forceManyBody();
36
36
37
- ns . pforceLink = d3
38
- . forceLink ( panelUtilsNs . split . promo . edges )
39
- . id ( panelUtilsNs . getLinkId )
40
- . distance ( 4 * ns . options . icon_size ) ;
37
+ // ns.pforceLink = d3
38
+ // .forceLink(panelUtilsNs.split.promo.edges)
39
+ // .id(panelUtilsNs.getLinkId)
40
+ // .distance(4 * ns.options.icon_size);
41
41
42
- ns . pforceCentre = d3 . forceCenter (
43
- ns . options . working_width / 2 ,
44
- ns . options . svg_height / 4 ,
45
- ) ;
42
+ // ns.pforceCentre = d3.forceCenter(
43
+ // ns.options.working_width / 2,
44
+ // ns.options.svg_height / 4,
45
+ // );
46
46
47
- if ( ns . options . nodeStrength !== undefined ) {
48
- ns . pforceNode . strength ( ns . options . nodeStrength ) ;
49
- }
47
+ // if (ns.options.nodeStrength !== undefined) {
48
+ // ns.pforceNode.strength(ns.options.nodeStrength);
49
+ // }
50
50
51
- if ( ns . options . linkStrength !== undefined ) {
52
- ns . pforceLink . strength ( ns . options . linkStrength ) ;
53
- }
51
+ // if (ns.options.linkStrength !== undefined) {
52
+ // ns.pforceLink.strength(ns.options.linkStrength);
53
+ // }
54
54
55
- if ( ns . options . centreStrength !== undefined ) {
56
- ns . pforceCentre . strength ( ns . options . centreStrength ) ;
57
- }
55
+ // if (ns.options.centreStrength !== undefined) {
56
+ // ns.pforceCentre.strength(ns.options.centreStrength);
57
+ // }
58
58
console . log ( "panelUtilsNs.split.promo.nodes->" , panelUtilsNs . split . promo . nodes ) ;
59
59
60
- ns . promotable_sim = d3
61
- . forceSimulation ( )
62
- // .on('end', function() {
63
- // console.log(["promotable_sim",this]);
64
- // this.force('link', options.pforceLink)
65
- // .force('charge', options.pforceNode)
66
- // .force('center', options.pforceCentre);
67
- // });
68
- // .force('link', ns.pforceLink)
69
- // .force('charge', ns.pforceNode)
70
- // .force('center', ns.pforceCentre);
71
- . force ( "link" , d3 . forceLink ( ) // This force provides links between nodes
72
- . 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.
73
- // .distance(500 * ns.options.icon_size)
74
- )
75
- . force ( "charge" , d3 . forceManyBody ( ) . strength ( - 500 ) ) // This adds repulsion (if it's negative) between nodes.
76
- . force ( "center" , d3 . forceCenter ( ns . options . width / 2 , ns . options . height / 2 ) ) ; // This force attracts nodes to the center of the svg area
77
60
61
+
62
+ ns . promotable_sim = d3
63
+ . forceSimulation ( )
64
+ . force ( "link" , d3 . forceLink ( ) // This force provides links between nodes
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
+ // .distance(500 * ns.options.icon_size)
67
+ ) ;
78
68
79
69
// 7. Now show split graphs
80
70
console . groupEnd ( ) ;
@@ -215,12 +205,26 @@ window.Widgets.Panel.Promo = {}
215
205
// This function is run at each iteration of the force algorithm, updating the nodes position (the nodes data array is directly manipulated).
216
206
ns . promotable_sim . force ( "link" )
217
207
. links ( panelUtilsNs . split . promo . edges )
218
- . distance ( function ( ) { return 5 * ns . options . icon_size ; } ) ;
219
-
208
+ . id ( d => d . id )
209
+ . distance ( function ( ) { return 5 * ns . options . icon_size ; } ) ;
210
+
211
+ // 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.
216
+ // .force("center", d3.forceCenter(ns.options.width / 2, ns.options.height / 2)); // This force attracts nodes to the center of the svg area
217
+ } else {
218
+ ns . promotable_sim
219
+ . force ( "charge" , d3 . forceManyBody ( ) . strength ( - 500 ) ) // This adds repulsion (if it's negative) between nodes.
220
+ . force ( "center" , d3 . forceCenter ( ns . options . width / 2 , ns . options . height / 2 ) ) ; // This force attracts nodes to the center of the svg area
221
+ }
222
+
223
+
220
224
//create zoom handler for each
221
- ns . zoom_handler = d3 . zoom ( ) . on ( 'zoom' , function ( event , d ) {
222
- ns . promo_svg . attr ( 'transform' , d3 . event . transform ) ;
223
- } ) ;
225
+ // ns.zoom_handler = d3.zoom().on('zoom', function(event, d) {
226
+ // ns.promo_svg_root .attr('transform', event.transform);
227
+ // });
224
228
225
229
226
230
@@ -229,23 +233,23 @@ window.Widgets.Panel.Promo = {}
229
233
} ;
230
234
231
235
//The simulation is temporarily “heated” during interaction by setting the target alpha to a non-zero value.
232
- ns . dragstarted = function ( d ) {
233
- if ( ! d3 . event . active ) {
236
+ ns . dragstarted = function ( event , d ) {
237
+ if ( ! event . active ) {
234
238
ns . promotable_sim . alphaTarget ( 0.3 ) . restart ( ) ; //sets the current target alpha to the specified number in the range [0,1].
235
239
}
236
240
d . fy = d . y ; //fx - the node’s fixed x-position. Original is null.
237
241
d . fx = d . x ; //fy - the node’s fixed y-position. Original is null.
238
242
}
239
243
240
244
//When the drag gesture starts, the targeted node is fixed to the pointer
241
- ns . dragged = function ( d ) {
242
- d . fx = d3 . event . x ;
243
- d . fy = d3 . event . y ;
245
+ ns . dragged = function ( event , d ) {
246
+ d . fx = event . x ;
247
+ d . fy = event . y ;
244
248
}
245
249
246
250
//the targeted node is released when the gesture ends
247
- ns . dragended = function ( d ) {
248
- if ( ! d3 . event . active ) {
251
+ ns . dragended = function ( event , d ) {
252
+ if ( ! event . active ) {
249
253
ns . promotable_sim . alphaTarget ( 0 ) ;
250
254
}
251
255
d . fx = null ;
@@ -282,17 +286,20 @@ window.Widgets.Panel.Promo = {}
282
286
. attr ( 'width' , $component . width ( ) )
283
287
. attr ( 'height' , $component . height ( ) )
284
288
. attr ( 'cursor' , 'pointer' )
285
- . attr ( 'pointer-events' , 'none' )
286
-
287
- ns . promotable_rect = ns . promo_svg
288
- . append ( 'rect' )
289
- . attr ( 'id' , 'promotable_rect' )
290
- . attr ( 'width' , $component . width ( ) )
291
- . attr ( 'height' , $component . height ( ) )
292
- . attr ( 'x' , 0 )
293
- . attr ( 'y' , 0 )
294
- . attr ( 'stroke' , panelUtilsNs . theme . svgBorder )
295
- . attr ( 'fill' , panelUtilsNs . theme . fill ) ;
289
+ . attr ( 'pointer-events' , 'all' )
290
+ . style ( "background" , panelUtilsNs . theme . promoFill ) ;
291
+
292
+ // .attr('pointer-events', 'none')
293
+
294
+ // ns.promotable_rect = ns.promo_svg
295
+ // .append('rect')
296
+ // .attr('id', 'promotable_rect')
297
+ // .attr('width', $component.width())
298
+ // .attr('height', $component.height())
299
+ // .attr('x', 0)
300
+ // .attr('y', 0)
301
+ // .attr('stroke', panelUtilsNs.theme.svgBorder)
302
+ // .attr('fill', panelUtilsNs.theme.fill);
296
303
297
304
ns . promotable_label = ns . promo_svg
298
305
. append ( 'g' )
@@ -305,7 +312,7 @@ window.Widgets.Panel.Promo = {}
305
312
ns . promo_svg_zoom = ns . promo_svg
306
313
. call (
307
314
d3 . zoom ( ) . on ( 'zoom' , function ( event , d ) {
308
- ns . promo_svg . attr ( 'transform' , event . transform ) ;
315
+ ns . promo_svg_root . attr ( 'transform' , event . transform ) ;
309
316
} ) ,
310
317
)
311
318
. attr ( 'id' , 'promo_svg_zoom' ) ;
0 commit comments