Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get clicked label in jQuery Flot "plotclick" event

So I have a method in jQuery for catching click events on my Flot chart:

$("#placeholder").bind("plotclick", function (event, pos, item) {
    alert("clicked");
});

I know the clicked values from item['datapoint'] array. But where can I find the label of curve I clicked?

Thanks.

like image 954
Mark M. Avatar asked Apr 05 '13 14:04

Mark M.


1 Answers

Look at item.series.label:

$("#placeholder").bind("plotclick", function (event, pos, item) {
    if (item) { 
        alert(item.series.label);
    }
});

Fiddle here.

like image 182
Mark Avatar answered Sep 21 '22 11:09

Mark