@@ -53,22 +53,23 @@ DecayChainChart = function(elem, options) {
5353
5454 if ( ( typeof this . options . clickNucTxt ) !== 'string' )
5555 this . options . clickNucTxt = "Click nuclide for more information." ;
56- if ( ( typeof this . options . clickNucMoreInfoTxt1 ) !== 'string' )
57- this . options . clickNucMoreInfoTxt1 = "Double-click nuclide for particles it gives off." ;
5856 if ( ( typeof this . options . clickNucMoreInfoTxt2 ) !== 'string' )
5957 this . options . clickNucMoreInfoTxt2 = "Click a different source nuclide above to" ;
6058 if ( ( typeof this . options . clickNucMoreInfoTxt3 ) !== 'string' )
6159 this . options . clickNucMoreInfoTxt3 = "change displayed decay chain." ;
6260
6361 if ( ( typeof this . options . clickNucMblTxt ) !== 'string' )
6462 this . options . clickNucMblTxt = "Tap nuclide for more information." ;
65- if ( ( typeof this . options . clickNucMblMoreInfoTxt1 ) !== 'string' )
66- this . options . clickNucMblMoreInfoTxt1 = "Touch nuclide for 1 second for particles it gives off." ;
6763 if ( ( typeof this . options . clickNucMblMoreInfoTxt2 ) !== 'string' )
6864 this . options . clickNucMblMoreInfoTxt2 = "Click a different source nuclide above to" ;
69- if ( ( typeof this . options . clickNucMblMoreInfoTxt3 ) !== 'string' )
65+ if ( ( typeof this . options . clickNucMblMoreInfoTxt3 ) !== 'string' )
7066 this . options . clickNucMblMoreInfoTxt3 = "change displayed decay chain." ;
71-
67+
68+ if ( ( typeof this . options . showDecayProductsTxt ) !== 'string' )
69+ this . options . showDecayProductsTxt = "Show {nuclide} decay products" ;
70+ if ( ( typeof this . options . showDecaysThroughTxt ) !== 'string' )
71+ this . options . showDecaysThroughTxt = "Show decays through {nuclide}" ;
72+
7273 this . svg = d3 . select ( this . area ) . append ( "svg" ) ;
7374
7475 this . chartbackground = this . svg . append ( "rect" )
@@ -262,16 +263,14 @@ DecayChainChart.prototype.setDecayData = function( data, decayFrom ){
262263 {
263264 this . instructions . html (
264265 '<tspan x="0">' + this . options . clickNucMblTxt + '</tspan>'
265- + ( decayFrom ? '<tspan x="0" dy="1em">' + this . options . clickNucMblMoreInfoTxt1 + '</tspan>'
266- + '<tspan x="0" dy="1em">' + this . options . clickNucMblMoreInfoTxt2 + '</tspan>'
266+ + ( decayFrom ? '<tspan x="0" dy="1em">' + this . options . clickNucMblMoreInfoTxt2 + '</tspan>'
267267 + '<tspan x="0" dy="1em">' + this . options . clickNucMblMoreInfoTxt3 + '</tspan>' : '' )
268268 ) ;
269269 } else
270270 {
271271 this . instructions . html (
272272 '<tspan x="0" dy="1em">' + this . options . clickNucTxt + '</tspan>'
273- + ( decayFrom ? '<tspan x="0" dy="1em">' + this . options . clickNucMoreInfoTxt1 + '</tspan>'
274- + '<tspan x="0" dy="1em">' + this . options . clickNucMoreInfoTxt2 + '</tspan>'
273+ + ( decayFrom ? '<tspan x="0" dy="1em">' + this . options . clickNucMoreInfoTxt2 + '</tspan>'
275274 + '<tspan x="0" dy="1em">' + this . options . clickNucMoreInfoTxt3 + '</tspan>' : '' )
276275 ) ;
277276 } //if( no data ) / else mobile / else
@@ -501,7 +500,6 @@ DecayChainChart.prototype.redraw = function() {
501500 self . decays . selectAll ( '.DecayChartNuc' ) . classed ( 'MousedOver' , false ) ;
502501 } )
503502 . on ( "click" , function ( d ) { self . nuclideClicked ( d ) ; } )
504- . on ( "dblclick" , function ( d ) { self . nuclideDoubleClicked ( d ) ; } )
505503 ;
506504
507505 rects . exit ( ) . remove ( ) ;
@@ -667,7 +665,6 @@ DecayChainChart.prototype.redraw = function() {
667665 self . decays . selectAll ( '.DecayChartNuc' ) . classed ( 'MousedOver' , false ) ;
668666 } )
669667 . on ( "click" , function ( d ) { self . nuclideClicked ( d ) ; } )
670- . on ( "dblclick" , function ( d ) { self . nuclideDoubleClicked ( d ) ; } )
671668 . html ( function ( d ) { return labelTxtFcn ( d , txtXPos ) ; } )
672669 . attr ( "font-family" , "sans-serif" )
673670 . attr ( "font-size" , function ( ) { return font_size + "px" ; } )
@@ -759,12 +756,19 @@ DecayChainChart.prototype.redraw = function() {
759756 //I cant decide if its better to underline the "Show Decays Through ..." text,
760757 // or draw a box around it; currently underlineing, but I left the box
761758 // implementation commented out in the various lines below.
762-
759+
763760 if ( ! this . selectedNuclide && this . showParentsTxt ) {
764761 self . showParentsTxt . remove ( ) ;
765762 self . showParentsRect . remove ( ) ;
766763 self . showParentsTxt = null ;
767764 self . showParentsRect = null ;
765+
766+ if ( self . showDecayProductsTxt ) {
767+ self . showDecayProductsTxt . remove ( ) ;
768+ self . showDecayProductsRect . remove ( ) ;
769+ self . showDecayProductsTxt = null ;
770+ self . showDecayProductsRect = null ;
771+ }
768772 } else if ( this . selectedNuclide && this . options . isDecayChain ) {
769773 if ( ! self . showParentsTxt ) {
770774 self . showParentsRect = this . chart . append ( "rect" )
@@ -776,33 +780,76 @@ DecayChainChart.prototype.redraw = function() {
776780 . attr ( "stroke" , "none" )
777781 . attr ( "class" , "ShowDecaysThroughRect" )
778782 . on ( "click" , function ( ) { self . emitShowDecaysThrough ( ) ; } ) ;
779-
783+
780784 self . showParentsTxt = this . chart . append ( "text" )
781785 . attr ( "class" , "ShowDecaysThroughTxt" )
782786 . attr ( "x" , 0 )
783787 . attr ( "y" , "0" )
784788 . attr ( "fill" , self . options . linkColor )
785789 . on ( "click" , function ( ) { self . emitShowDecaysThrough ( ) ; } ) ;
790+
791+ self . showDecayProductsRect = this . chart . append ( "rect" )
792+ . attr ( "x" , 0 )
793+ . attr ( "y" , 0 )
794+ . attr ( "fill" , "#ffffff" ) //add fill so mouse over will be active for entire rect area
795+ . attr ( "fill-opacity" , "0" )
796+ . attr ( "stroke" , "none" )
797+ . attr ( "class" , "ShowDecayProductsRect" )
798+ . on ( "click" , function ( ) { self . showNuclideDecayProducts ( self . selectedNuclide ) ; } ) ;
799+
800+ self . showDecayProductsTxt = this . chart . append ( "text" )
801+ . attr ( "class" , "ShowDecayProductsTxt" )
802+ . attr ( "x" , 0 )
803+ . attr ( "y" , "0" )
804+ . attr ( "fill" , self . options . linkColor )
805+ . on ( "click" , function ( ) { self . showNuclideDecayProducts ( self . selectedNuclide ) ; } ) ;
786806 }
787-
807+
808+ // Position the "Show decay products" text first, below the instructions
809+ const decayProductsText = self . options . showDecayProductsTxt . replace ( '{nuclide}' , self . selectedNuclide . nuclide ) ;
810+ self . showDecayProductsTxt
811+ . html ( decayProductsText )
812+ . attr ( "font-size" , 0.9 * inst_font_size )
813+ . attr ( "text-decoration" , "underline" )
814+ ;
815+
816+ const decayprodtxtbb = self . showDecayProductsTxt . node ( ) . getBoundingClientRect ( ) ;
817+ const decayprod_txt_h = decayprodtxtbb . height ;
818+ const decayprod_txt_w = decayprodtxtbb . width ;
819+ const box_x = chartwidth - txtbb . width - 4 ;
820+
821+ // Position below the instructions text
822+ const decayprod_box_y = txtbb . height + 4 + 0.15 * decayprod_txt_h ;
823+
824+ self . showDecayProductsTxt . attr ( "transform" , "translate(" + box_x + "," + ( decayprod_box_y + 0.9 * decayprod_txt_h ) + ")" )
825+
826+ self . showDecayProductsRect
827+ . attr ( "height" , 1.2 * decayprod_txt_h )
828+ . attr ( "width" , decayprod_txt_w + 0.75 * decayprod_txt_h )
829+ . attr ( "rx" , 0.08 * 1.2 * decayprod_txt_h )
830+ . attr ( "transform" , "translate(" + ( box_x - 0.375 * decayprod_txt_h ) + "," + decayprod_box_y + ")" )
831+ ;
832+
833+ // Position the "Show Decays Through" text below the decay products text
834+ const decaysThroughText = self . options . showDecaysThroughTxt . replace ( '{nuclide}' , self . selectedNuclide . nuclide ) ;
788835 self . showParentsTxt
789- . html ( 'Show Decays Through ' + self . selectedNuclide . nuclide )
836+ . html ( decaysThroughText )
790837 //.attr("font-size", 0.8*inst_font_size )
791838 . attr ( "font-size" , 0.9 * inst_font_size )
792839 . attr ( "text-decoration" , "underline" )
793840 ;
794-
841+
795842 const showtxtpbb = self . showParentsTxt . node ( ) . getBoundingClientRect ( ) ;
796843 const txt_h = showtxtpbb . height ;
797844 const txt_w = showtxtpbb . width ;
798- const box_x = chartwidth - txtbb . width - 4 ;
799- //const box_y = txtbb.height + 4 + 0.25*txt_h;
800- const box_y = txtbb . height + 4 + 0.15 * txt_h ;
801-
845+
846+ // Position below the decay products text, with some spacing
847+ const box_y = decayprod_box_y + decayprod_txt_h + 0.3 * txt_h ;
848+
802849 //self.showParentsTxt.attr("transform", "translate(" + (box_x + 0.375*txt_h) + "," + (box_y + 0.90*txt_h) + ")");
803850 self . showParentsTxt . attr ( "transform" , "translate(" + box_x + "," + ( box_y + 0.9 * txt_h ) + ")" )
804-
805-
851+
852+
806853 self . showParentsRect
807854 . attr ( "height" , 1.2 * txt_h )
808855 . attr ( "width" , txt_w + 0.75 * txt_h )
@@ -849,12 +896,12 @@ DecayChainChart.prototype.nuclideClicked = function( d ) {
849896
850897
851898
852- DecayChainChart . prototype . nuclideDoubleClicked = function ( d ) {
899+ DecayChainChart . prototype . showNuclideDecayProducts = function ( d ) {
853900 let nucstr = ( d && d . nuclide ) ? d . nuclide : '' ;
854901 ( ( d && d . additionalIsos ) ? d . additionalIsos : [ ] ) . forEach ( function ( nuc ) {
855902 nucstr += "," + nuc . nuclide ;
856903 } ) ;
857-
904+
858905 this . WtEmit ( this . area . id , { name : 'ShowDecayParticleInfo' } , nucstr ) ;
859906}
860907
0 commit comments