Reputation: 333
By default when we hover the mouse on any region of the jqplot charts it changes color - that's fine. But I want that on hover it should show its value. For example I have 2 regions on charts as:
Now on mouse hover it should show the label as well as the value. For example it should show as
Customer Projects:20
How can I do this? Thanks in advance.
Upvotes: 1
Views: 5748
Reputation: 108512
Here's a hack that uses the fact that the labels are just text divs:
previousPoint = null;
$('#chartdiv').bind('jqplotDataMouseOver', function (ev, seriesIndex, pointIndex, data) {
var labels = $('#chartdiv .jqplot-data-label');
if (previousPoint != null)
{
labels[previousPoint['idx']].innerHTML = previousPoint['data'][1]+'';
}
labels[pointIndex].innerHTML = data[0] + ": " + data[1];
previousPoint = {'idx':pointIndex, 'data':data};
});
Working fiddle here. Remember to cache the jqplot files.
Upvotes: 1