Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flot charts - externally selecting bars

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

like image 937
Tim Avatar asked Jan 27 '26 06:01

Tim


1 Answers

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);
});
like image 62
Ryley Avatar answered Jan 28 '26 19:01

Ryley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!