删除flot中单击部分的突出显示

问题描述 投票:0回答:1

我将以此情节为例:http://www.flotcharts.org/flot/examples/interacting/

如您所见,如果您点击一个点,它将保持突出显示。静态图不是问题,但我有一个每秒更新一次的图。

如何使这个突出显示的部分在一段时间后消失,例如5秒?

这是上图(可点击元素)的flot代码:

$("#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);
        }
    });
javascript jquery flot clickable
1个回答
1
投票

要在5秒后删除突出显示,您可以使用unhighlight()函数的计时器:

$("#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);
    }
});
© www.soinside.com 2019 - 2024. All rights reserved.