@@ -155,7 +155,7 @@ $(function() {
155155 . attr ( "transform" , "translate(" + ( this . width - this . margins . right + 25 ) + " " + this . margins . top + ")" ) ;
156156
157157 // Create tooltip
158- this . _elements . tooltip = main_plot . append ( "g " )
158+ this . _elements . tooltip = d3 . select ( "body" ) . append ( "svg " )
159159 . attr ( "id" , "composite-plot-tooltip" ) ;
160160
161161 main_plot . append ( "g" )
@@ -171,7 +171,7 @@ $(function() {
171171 $ ( "#main-plot" ) . main_plot ( "move_tooltip" , e )
172172 } ) ;
173173 main_plot . on ( "mouseleave" , function ( ) {
174- $ ( "#main-plot" ) . main_plot ( "hide_tooltip" )
174+ // $("#main-plot").main_plot("hide_tooltip")
175175 } ) ;
176176 } ,
177177
@@ -763,6 +763,7 @@ $(function() {
763763 } ,
764764
765765 move_tooltip : function ( ev ) {
766+ let self = this ;
766767 if ( this . enable_tooltip ) {
767768 // Get data for all composites that are plotted and have files loaded
768769 let data = $ ( "#settings-table" ) . settings_table ( "export" ) . filter ( d => d . files_loaded > 0 && ! d . hide ) ,
@@ -780,7 +781,11 @@ $(function() {
780781 // Move tooltip to mouse position
781782 this . _elements . tooltip
782783 . style ( "display" , null )
783- . attr ( "transform" , "translate(" + this . xscale ( mouse_x_scaled ) + " " + mouse_y + ")" ) ;
784+ . style ( "position" , "absolute" )
785+ . style ( "top" , ev . clientY )
786+ . style ( "left" , ev . clientX )
787+ . style ( "pointer-events" , "none" ) ;
788+ // .attr("transform", "translate(" + this.xscale(mouse_x_scaled) + " " + mouse_y + ")");
784789
785790 // Create tooltip border and text
786791 let tooltip_border = this . _elements . tooltip . selectAll ( "path" )
@@ -807,9 +812,12 @@ $(function() {
807812 : parseFloat ( d . sense [ mouse_x_scaled - d . xmin ] . toPrecision ( 2 ) ) + "; " + parseFloat ( d . anti [ mouse_x_scaled - d . xmin ] . toPrecision ( 2 ) ) ) ) ;
808813 // Get bounding box of text
809814 let { y, width : w , height : h } = tooltip_text . node ( ) . getBBox ( ) ;
810- tooltip_text . attr ( "transform" , "translate(" + ( - w / 2 ) + " " + ( 15 - y ) + ")" ) ;
815+ tooltip_text . attr ( "transform" , "translate(" + 2 + " " + ( 15 - y ) + ")" ) ;
811816 // Update tooltip border
812- tooltip_border . attr ( "d" , "M" + ( - w / 2 - 10 ) + ",5H-5l5,-5l5,5H" + ( w / 2 + 10 ) + "v" + ( h + 20 ) + "h-" + ( w + 20 ) + "z" )
817+ tooltip_border . attr ( "d" , "M" + ( w + 4 ) + " 5 H " + ( w + 20 ) / 2 + " l -5 -5 l-5 5 H 0 V " + ( h + 20 ) + " H " + ( w + 4 ) + " z" )
818+ this . _elements . tooltip
819+ . style ( "top" , ev . clientY )
820+ . style ( "left" , ev . clientX - ( ( w + 8 ) / 2 ) ) ;
813821 } else {
814822 this . _elements . tooltip . style ( "display" , "none" )
815823 }
0 commit comments