Jquery Flot “plothover” event not working

丶灬走出姿态 提交于 2019-12-06 17:30:32

问题


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!


回答1:


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!

:)




回答2:


I'm not sure what $chartArea is in your code, but lets try something like this:

var chartArea = $("#placeholder"); // your chart div

$.plot(chartArea, eventData, eventOptions);

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


来源:https://stackoverflow.com/questions/10181837/jquery-flot-plothover-event-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!