flot charts - externally selecting bars

孤者浪人 提交于 2020-01-04 03:18:19

问题


I'm using flot http://code.google.com/p/flot/ and would like to highlight a particular bar in the series when the user hovers over a link, does anyone know how to do that?

Cheers,

Tim


回答1:


The thing you're looking for is highlight, which is documented in the API.txt:

highlight(series, datapoint)

Highlight a specific datapoint in the data series. You can either
specify the actual objects, e.g. if you got them from a
"plotclick" event, or you can specify the indices, e.g.
highlight(1, 3) to highlight the fourth point in the second series
(remember, zero-based indexing).

So your code would look something like this:

//before this, $.plot has been called and assigned to "plot"
$('#mylink').mouseover(function(){
   plot.highlight(1,3);
}).mouseout(function(){
   plot.unhighlight(1,3);
});


来源:https://stackoverflow.com/questions/6105279/flot-charts-externally-selecting-bars

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