Alireza Fattahi
Alireza Fattahi

Reputation: 45475

Jquery Flot get ticks data for tooltip

I am using the jquery flot to show charts with tooltip. I am using ticks to get custom xaxis data. SO

 var data = [ [0, 3], [4, 8], [8, 5],  [9, 13] ];
 var ticksData = [ [0, "A"], [4, "B"], [8, "C"],  [9, "D"] ];
 ......
 xaxis: {            
         ticks: ticksData,
         tickLength: 0
     },

But when I want to show the tooltip, I got the none ticks data.

 $("#placeholder").bind("plothover", function(event, pos, item) {
      var x = item.datapoint[0],   y = item.datapoint[1];
      //x and y are 4,8 instead of B,8

Complete sample http://jsfiddle.net/z0u6rqhe/

Is there any way to get to fix tool tip to show ticks data, or I should loop through ticksData and re find the value

Upvotes: 1

Views: 448

Answers (1)

Pawan Lakhara
Pawan Lakhara

Reputation: 1150

please check this link, i hope this will helpful for you.

jsfiddle.net/z0u6rqhe/5/

code:

  var x = item.series.xaxis.ticks[item.dataIndex];

Upvotes: 1

Related Questions