I'll take as an example this plot: http://www.flotcharts.org/flot/examples/interacting/
As you can see, if you click a point it will remain highlighted. Not an issue with static graphs, but I have a graph that is updated every second.
How could I make this highlighted part disappear after a certain period, e.g. 5 seconds?
This is the flot code for the above chart (clickable elements):
$("#placeholder").bind("plotclick", function (event, pos, item) {
if (item) {
$("#clickdata").text(" - click point " + item.dataIndex + " in " + item.series.label);
plot.highlight(item.series, item.datapoint);
}
});
To remove the highlight after 5 seconds, you can use a timer for the unhighlight()
function:
$("#placeholder").bind("plotclick", function (event, pos, item) {
if (item) {
$("#clickdata").text(" - click point " + item.dataIndex + " in " + item.series.label);
plot.highlight(item.series, item.datapoint);
setTimeout(function() {
plot.unhighlight(item.series, item.datapoint);
}, 5000);
}
});