当我的光标移动时,我抓住两个最近的点,如果它还没有在绘图点上。
我希望能够使这两个最近的点亮起(即将颜色变为橙色或其他东西),然后在光标离开图形范围后恢复正常。我该如何实施呢?
placeholder.bind("plothover", function (event, pos, item) {
if (item){
local_x = item.datapoint[0].toFixed(2);
local_y = item.datapoint[1].toFixed(2);
if (!updateLegendTimeout){
updateLegendTimeout = setTimeout(updateLegend(local_x,local_y), 1000);
updateLegendTimeout = null;
}
}
else{
var closest_points_container = interpolate(plot,pos.x,pos.y);
//Code to make points glow goes here, they are contained in closest_points[0]
and closest_points[1].
}
答案 0 :(得分:2)
Flot在绘图对象上提供高亮和非高亮方法,如文档的Plot Methods部分所述。不幸的是,它的限制是一次只能突出显示一个点。这是烤好的;你不能在不改变来源的情况下改变它。
我将使用的解决方法是添加第二个系列,仅显示点,没有线条,并将点样式设置为突出显示,即具有半透明效果。这个亮点系列将开始空白;然后,当您想要突出显示主系列中的某个点时,您可以将其复制到突出显示系列并重新绘制。