Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I am probably answering this too late. As I understand the question, you are trying to display some text about the point other than just the x,y coordinates at that point. I was able to solve it for myself and found the clue in the link you gave <a href="http://people.iola.dk/olau/flot/examples/interacting.html" rel="nofollow">http://people.iola.dk/olau/flot/examples/interacting.html</a>. If you look at the code, in the function bound to plotclick event, there is this variable item.dataIndex: </p> <pre><code>$("#clickdata").text("You clicked point " + item.dataIndex + " in " + item.series.label + "."); </code></pre> <p>This variable is a sort of id for the point in the plot. Hence if I make an array with three params, the x coordinate, y coordinate and info, and pass the first two coordinates to the plot function in the following way:</p> <pre><code>var data = []; for(i=0;i&lt;len;i++) data.push([obj[i][1], obj[i][0]]); //plotting the new array "data" var plot = $.plot($("#placeholder"), [data], options); </code></pre> <p>where the obj array is:</p> <pre><code>{{12, 20, "info about point 1"},{26, 30, "info about point 2"}} </code></pre> <p>then the following statement inside the function for plothover event will do the job for us</p> <pre><code>showTooltip(item.pageX, item.pageY,obj[item.dataIndex][2]); </code></pre> <p>It worked me for me. Hope it helps. :)</p> <p>Note:</p> <p>You may also find it handy to reference the text directly rather than having to keep a reference to obj array:</p> <pre><code>var myLabel = this.plot.getData()[item.seriesIndex].data[item.dataIndex][2] showTooltip(item.pageX, item.pageY, myLabel; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload