angular - Plotly Tooltip position should be dynamic based on cursor position -


i created plotly graph in angular2 using example https://plot.ly/javascript/filled-area-plots/, want move tool tip right side when cursor goes extreme left , move tool tip left side when cursor goes extreme right side.please help. in advance.

i had same requirement , not found satisfied solution. build own tooltiphandler.js in javascript showing tooltip hovered data points. put in full example on jsfiddle you: https://jsfiddle.net/qcobnbcw/ have no knowledge angular im not sure if works u there without changes.

at begin there 3 global variables. showverticalhoverline used tooltiphandler. if true, draw 1 bobbel each hovered data point , show vertical line:

var showverticalhoverline = true; var chartdivid = "mydiv"; var chartdiv = document.getelementbyid(chartdivid); 

from line 5 line 179 defines tooltiphandler.js. tooltiphandler can used object , have 2 simple methods showtooltip() , hidetooltip(). tooltip appear 30px right , down of current cursor position. avoiding tooltip not viewable if user if right or bottom of body haves in line 93 , 101 check it. if leave 'screen' moved left (or top) of cursor.

from line 184 line 205 build example plot referenced in question.

from line 210 end create hover , unhover function , attach them chartdiv. plotly call it, if recognizes it. function shows , hides correspondingly tooltip.

i hope not code , helps. fell free ask further questions.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -