krzysu / flot.tooltip

tooltip plugin for wonderful Flot plotting library
https://github.com/krzysu/flot.tooltip
187 stars 153 forks source link

fixed pie tooltip positioning bug #119

Closed kenirwin closed 9 years ago

kenirwin commented 9 years ago

This pull request fixes the bug whereby the tooltip for pie charts appears at the very bottom of a page instead of hovering over the chart as the tooltip for other kinds of charts. (This bug was documented in my comments on issue #105. I'm not sure if this fixes the original bug reported in that same issue, as I have not been able to replicate that user's problem.)

Using a bunch of console.log() calls, I was able to determine that the pie chart does set the position of the tooltip, and then somehow it unsets it right after, so it only ever appears in the wrong place. The fix I've implemented here add an instruction: if the tooltip position is currently undefined, keep the last known defined position. Since it resets every pixel or so that the mouse moves, this shouldn't cause trouble. It may mean that when the tooltip is hidden, it may technically be floating invisibly over the chart, but that should also not be a problem. I've tested the fix on all of the tooltip example files; it does fix the pie chart and it does not break any of the others.

BEFORE FIX:

tooltip-piebottom2

AFTER FIX:

tooltip-piehover