I had been using awesome flot.js charting library on my results app. The charts were easy to generate and I included categories plugin to replace x-axis labels to words rather than integer values.
But I faced some issues while enabling tooltips and having them display the labels rather than x coordinates. I checked up the source code.
[caption id="attachment_35" align="aligncenter" width="646"] getAxes()??[/caption]
plot.getAxes() method described in the documentation was giving me an undefined method error.I searched the docs, searched on Google, stackexchange etc.. but to no avail.
Then I found solution thanks to firebug.
I did a console.log() of the whole item object and began inspecting. I could see few objects that looked promising. Upon further inspection I found a way to map a value back to its label.
[caption id="attachment_34" align="aligncenter" width="924"] Dumping entire item object in firebug[/caption]
I found 3 ways
Note:-- previousPoint is the point reference on x-axis.
Problem Solved.
But I faced some issues while enabling tooltips and having them display the labels rather than x coordinates. I checked up the source code.
[caption id="attachment_35" align="aligncenter" width="646"] getAxes()??[/caption]
plot.getAxes() method described in the documentation was giving me an undefined method error.I searched the docs, searched on Google, stackexchange etc.. but to no avail.
Then I found solution thanks to firebug.
I did a console.log() of the whole item object and began inspecting. I could see few objects that looked promising. Upon further inspection I found a way to map a value back to its label.
[caption id="attachment_34" align="aligncenter" width="924"] Dumping entire item object in firebug[/caption]
I found 3 ways
- item.series.data[previousPoint][0]
- item.series.xaxis.categories
- item.series.xaxis.ticks[previousPoint].label
Note:-- previousPoint is the point reference on x-axis.
Problem Solved.
Comments
Post a Comment