@@ -218,9 +218,9 @@ function classes(root) {
218218 return { children : classes } ;
219219}
220220
221- function ProteinForceDirectedGraph ( ) {
221+ function ProteinForceDirectedGraph ( { onChoose , onRelease } ) {
222222 debugger
223- d3 . select ( "#svgprotein" ) . remove ( )
223+ d3 . select ( "#svgprotein" ) . remove ( ) ;
224224 var width = 650 ,
225225 height = 650 ;
226226 var radius = 2 ;
@@ -281,30 +281,30 @@ function ProteinForceDirectedGraph() {
281281 if ( e . data . protein . indexOf ( d . label ) >= 0 ) return 1 ;
282282 else return 0.05 ;
283283 } ) ;
284- var bars1 = d3 . select ( "#svg1" ) . selectAll ( "rect" ) ;
285- bars1 . style ( "fill-opacity" , function ( bar ) {
286- if ( bar . symbol . toUpperCase ( ) == d . label ) return 1 ;
287- else return 0.05 ;
288-
289- } ) ;
290- var bars2 = d3 . select ( "#svg2" ) . selectAll ( "rect" ) ;
291- bars2 . style ( "fill-opacity" , function ( bar ) {
292- if ( bar . symbol . toUpperCase ( ) == d . label ) return 1 ;
293- else return 0.05 ;
294-
295- } ) ;
296- var bars3 = d3 . select ( "#svg3" ) . selectAll ( "rect" ) ;
297- bars3 . style ( "fill-opacity" , function ( bar ) {
298- if ( bar . symbol . toUpperCase ( ) == d . label ) return 1 ;
299- else return 0.05 ;
300-
301- } ) ;
302- var bars4 = d3 . select ( "#svg4" ) . selectAll ( "rect" ) ;
303- bars4 . style ( "fill-opacity" , function ( bar ) {
304- if ( bar . symbol . toUpperCase ( ) == d . label ) return 1 ;
305- else return 0.05 ;
306-
307- } ) ;
284+ // var bars1 = d3.select("#svg1").selectAll("rect");
285+ // bars1.style("fill-opacity",function (bar) {
286+ // if(bar.symbol.toUpperCase()==d.label) return 1;
287+ // else return 0.05;
288+ //
289+ // });
290+ // var bars2 = d3.select("#svg2").selectAll("rect");
291+ // bars2.style("fill-opacity",function (bar) {
292+ // if(bar.symbol.toUpperCase()==d.label) return 1;
293+ // else return 0.05;
294+ //
295+ // });
296+ // var bars3 = d3.select("#svg3").selectAll("rect");
297+ // bars3.style("fill-opacity",function (bar) {
298+ // if(bar.symbol.toUpperCase()==d.label) return 1;
299+ // else return 0.05;
300+ //
301+ // });
302+ // var bars4 = d3.select("#svg4").selectAll("rect");
303+ // bars4.style("fill-opacity",function (bar) {
304+ // if(bar.symbol.toUpperCase()==d.label) return 1;
305+ // else return 0.05;
306+ //
307+ // });
308308 } )
309309 node . append ( "text" )
310310 . attr ( "class" , "texts" )
@@ -356,45 +356,55 @@ function ProteinForceDirectedGraph() {
356356 d3 . select ( "#svgbubble" ) . selectAll ( "g" ) . classed ( "selected" , false ) ;
357357 }
358358 d3 . select ( this ) . classed ( "selected" , ! isSelected ) ;
359-
359+ // to do release
360360 d3 . select ( "#svgbubble" ) . selectAll ( "g" ) . style ( "opacity" , 0.1 )
361- d3 . select ( "#svgbubble" ) . selectAll ( ".selected" ) . style ( "opacity" , 1 )
362-
363-
364- node . style ( "opacity" , function ( d ) {
365- if ( b . data . protein . indexOf ( d . label ) >= 0 ) return 1 ;
366- else return 0.05 ;
367- } ) ;
368- link . style ( "opacity" , function ( d ) {
369- if ( b . data . protein . indexOf ( d . source . label ) >= 0 && b . data . protein . indexOf ( d . target . label ) >= 0 ) return 1 ;
370- else return 0.05 ;
371- } )
372-
373- var bars1 = d3 . select ( "#svg1" ) . selectAll ( "rect" ) ;
374- bars1 . style ( "fill-opacity" , function ( bar ) {
375- if ( b . data . protein . indexOf ( bar . symbol . toUpperCase ( ) ) >= 0 ) return 1 ;
376- else return 0.05 ;
377-
378- } ) ;
379-
380- var bars2 = d3 . select ( "#svg2" ) . selectAll ( "rect" ) ;
381- bars2 . style ( "fill-opacity" , function ( bar ) {
382- if ( b . data . protein . indexOf ( bar . symbol . toUpperCase ( ) ) >= 0 ) return 1 ;
383- else return 0.05 ;
384-
385- } ) ;
386- var bars3 = d3 . select ( "#svg3" ) . selectAll ( "rect" ) ;
387- bars3 . style ( "fill-opacity" , function ( bar ) {
388- if ( b . data . protein . indexOf ( bar . symbol . toUpperCase ( ) ) >= 0 ) return 1 ;
389- else return 0.05 ;
390-
391- } ) ;
392- var bars4 = d3 . select ( "#svg4" ) . selectAll ( "rect" ) ;
393- bars4 . style ( "fill-opacity" , function ( bar ) {
394- if ( b . data . protein . indexOf ( bar . symbol . toUpperCase ( ) ) >= 0 ) return 1 ;
395- else return 0.05 ;
396-
397- } ) ;
361+ let selectedItems = d3 . select ( "#svgbubble" ) . selectAll ( ".selected" ) . style ( "opacity" , 1 ) ;
362+ let nodesList = [ ] ;
363+ if ( ! selectedItems . empty ( ) )
364+ {
365+ node . style ( "opacity" , function ( d ) {
366+ if ( b . data . protein . indexOf ( d . label ) >= 0 ) {
367+ nodesList . push ( d . referenceName )
368+ return 1 ;
369+ }
370+ else return 0.05 ;
371+ } ) ;
372+ link . style ( "opacity" , function ( d ) {
373+ if ( b . data . protein . indexOf ( d . source . label ) >= 0 && b . data . protein . indexOf ( d . target . label ) >= 0 ) return 1 ;
374+ else return 0.05 ;
375+ } ) ;
376+ } else {
377+ d3 . select ( "#svgbubble" ) . selectAll ( "g" ) . style ( "opacity" , 1 ) ;
378+ node . style ( "opacity" , 1 ) ;
379+ link . style ( "opacity" , 1 ) ;
380+ }
381+ if ( onChoose )
382+ onChoose ( nodesList )
383+ // var bars1 = d3.select("#svg1").selectAll("rect");
384+ // bars1.style("fill-opacity",function (bar) {
385+ // if(b.data.protein.indexOf(bar.symbol.toUpperCase())>=0) return 1;
386+ // else return 0.05;
387+ //
388+ // });
389+ //
390+ // var bars2 = d3.select("#svg2").selectAll("rect");
391+ // bars2.style("fill-opacity",function (bar) {
392+ // if(b.data.protein.indexOf(bar.symbol.toUpperCase())>=0) return 1;
393+ // else return 0.05;
394+ //
395+ // });
396+ // var bars3 = d3.select("#svg3").selectAll("rect");
397+ // bars3.style("fill-opacity",function (bar) {
398+ // if(b.data.protein.indexOf(bar.symbol.toUpperCase())>=0) return 1;
399+ // else return 0.05;
400+ //
401+ // });
402+ // var bars4 = d3.select("#svg4").selectAll("rect");
403+ // bars4.style("fill-opacity",function (bar) {
404+ // if(b.data.protein.indexOf(bar.symbol.toUpperCase())>=0) return 1;
405+ // else return 0.05;
406+ //
407+ // });
398408
399409 } ) ;
400410
0 commit comments