jquery - How to detect adjacent items in flot using a bootstrap tooltip -


i'm switching flot graphs towards using bootstrap tooltips. i've encountered bug if 2 items close tooltip doesn't follow.

error in flot

as can see in image above, i'm hovering lower datapoint while bootstrap tooltip still stuck on datapoint above.

i'm using following code. guess problem situated @ if(item) stays true while hovering down. thinking of working global variable seems messy solution. ideas?

placeholder.bind('plothover', function (event, pos, item) {          if (item) {             var x = item.datapoint[0],                 y = item.datapoint[1],                 label = item.series.label;              box.css({                 top: item.pagey - 2,                 left: item.pagex + 1             });              if ($('.tooltip').length === 0) {                 box.tooltip({                     placement: 'top',                     title: label + ': ' + y                 }).tooltip('show');             }         } else {             box.tooltip('destroy');         }     }); 

jsfiddle

the global variable store item tooltip shown default solution in flot this, here:

previtem = null; placeholder.bind('plothover', function (event, pos, item) {      if (item) {         if (previtem != item.dataindex + item.seriesindex / 100) {             previtem = item.dataindex + item.seriesindex / 100;              // show / update tooltip         }     } else {         previtem = null;         box.tooltip('destroy');     } }); 

i tried working in fiddle , worked of time. there issues bootstrap tooltip not updates text properly. destroying , recreating tooltip solves brings flicker.


Comments