random .NET and web development musings

jqPlot is an awesome javascript graphing library, supporting loads of cool features. Except clickable bar charts.

Here is a plugin which allows you to capture click events for bar charts.

Use it like this:

$.jqplot('Graph', data, {
	ClickableBars: { 
		onClick: function(i, j, data){
			alert("Clicked series: " + i + ", data point: " + j + ", data: " + data);
		}
	}
});

This won’t work on horizontal or stacked graphs without modification, but it would be a fairly trivial change.

The code is available on github.

4 COMMENTS
RC
January 24, 2011
ad

Hmmmm, couldn’t get this to work. The cursor turns into a hand when the bars are rolled over, and I’m getting no errors…

kik
April 28, 2011
ad

Thanks for sharing.
Anyway it is not working for me (chrome). No Js errors. I’m disapointed it was exaclty what i needed

chris tw
June 27, 2012
ad

i don’t know if anybody is still interested. but for others who read this:

it should look something like this:


ClickableBars: {
onClick: function(i, j, data) {
alert("Series: " + i + ", Data item: " + j + ", Data: " + data);
}
}

June 27, 2012
ad

Thanks, I’ve updated the mistake in the post

Post a comment