How can I make the axis labels (of a category X axis) clickable.
If it is less problematic, it is OK that the click will lead to a new link (and not some javascript code)
Is there a way I can do this?
Thanks, Boaz.
How can I make the axis labels (of a category X axis) clickable.
If it is less problematic, it is OK that the click will lead to a new link (and not some javascript code)
Is there a way I can do this?
Thanks, Boaz.
Here is a simple script:
$(".jqplot-xaxis-label")
.css({
cursor: "pointer",
zIndex: "1"
})
.click(function(){ location.href = "http://google.com"; });
The most important thing happening above is that the zIndex
is being set to 1 so that it sits above the canvas object. Now you can actually click it. The cursor
style just makes it have that friendly rollover mouse icon. Now, you can do whatever you want inside the click event.
My answer is almost similar to Abishai Gray the difference being that it works with latest version of jqPlot (Version tested: 1.0.4)
The CSS class for Axis ticks now end with -tick instead of -label
$('.jqplot-xaxis-tick')
.css({ cursor: "pointer", zIndex: "1" })
.click(function () { alert('Axis Tick Clicked'); });
Depends on what you expect as behavior after clicking category
Generator of Ticks is in file called: jqplot.axisTickRenderer.js
You can
1) modify the code to give every tick #id
and attach behavior with your own jquery code
2) list ticks in $(".jqplot-xaxis")
and add behavior -| |-