Jquery Flot "plothover" event not working

gabaum10 picture gabaum10 · Apr 16, 2012 · Viewed 9.3k times · Source

I have an issue I can't seem to track down. I am using Flot to graph some data, super easy. I want to add the hover effect you see here: Flot Example

Unfortunately, under no circumstance can I get the 'plothover' event to fire. This is a brief snippet from the code:

$.plot($chartArea, eventData, eventOptions);

$chartArea.bind("plothover", function (event, pos, item) {
    console.log('hovering!');
});

Is there something you need to set in the options object to enable this behavior? Thanks!

Answer

gabaum10 picture gabaum10 · Apr 16, 2012

Like an idiot, I forgot to include the grid option. Check out the object:

eventOptions = {
   points: {
        show: true
    },
    lines: {
        show: true
    },
    grid: { hoverable: true, clickable: true },
    xaxis: {
        min:earliestMessage.timestamp,
        max:currentTime,
        mode:"time",
        ticks:10
    }
};

notice the grid parameter. That's what was missing. Duh!

:)