简体   繁体   中英

Determine plot of flot point

I have a flot graph with a few different plots in it. There is interactivity that triggers an event when a point is hovered over, a la http://www.flotcharts.org/flot/examples/interacting/ . Is there any on-hand way of determining which plot the event's point came from, short of coloring all plots uniquely and getting at the point's color?

If you look at the script on that page you have this binding for the plothover event:

$("#placeholder").bind("plothover", function (event, pos, item) 

The item is the actual point you are hovering over (or null if you are not over a point). That object contains all the data you need including both series which gives you the series it belongs to (which I assume is what you meant by plot ) and seriesIndex .

The actual description of the item object is kind of hidden in the documentation :

item: {
    datapoint: the point, e.g. [0, 2]
    dataIndex: the index of the point in the data array
    series: the series object
    seriesIndex: the index of the series
    pageX, pageY: the global screen coordinates of the point
}

Also note: "The item object in this example is either null or a nearby object on the form"

How near "nearby" is depends on the mouseActiveRadius

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM