Reputation: 11
I have a bar chart. Please find the below code of the bar chart. Also find the attached image which is the result of the given script.
$(document).ready(function(){
var s1 = [2, 6, 7, 10];
var s2 = [7, 5, 3, 2];
var s3 = [14, 9, 3, 8];
var tickx = ["aaa", "bbb", "ccc"];
plot3 = $.jqplot('chart3', [s1, s2, s3], {
stackSeries: true,
captureRightClick: true,
seriesDefaults:{
renderer:$.jqplot.BarRenderer,
rendererOptions: {
highlightMouseDown: true
},
pointLabels: {show: true}
},
legend: {
show: true,
location: 'e',
placement: 'outside'
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: tickx
}
}
});
$('#chart3').bind('jqplotDataRightClick',
function (ev, seriesIndex, pointIndex, data) {
$('#info3').html('series: '+seriesIndex+', point: '+pointIndex+', data: '+data);
}
);
});
On right click on the bar it will display the value of right clicked bar.
You Right Clicked: series: 2, point: 1, data: 2,9.
Here, the value 2 in the data value (data: 2,9) is the xaxis series number. Instead of series name i would like to get the tick used in the chart.
In this above script tick given is : ["aaa", "bbb", "ccc"];
I want the output displayed as
if the user clicks the series 1 axis. result should be
You Right Clicked: series: 2, point: 1, data: 1,7, series label: aaa.
Please help me to achieve this. Thanks in advance.
Regards,
Antony
Upvotes: 1
Views: 2232
Reputation: 108567
Read my comment above. If you are after the xaxis category position on the right-click, use this:
$('#chart3').bind('jqplotDataRightClick',
function (ev, seriesIndex, pointIndex, data) {
$('#info3').html('series: '+seriesIndex+', point: '+pointIndex+', data: '+data + ' category label: ' + plot3.axes.xaxis.ticks[pointIndex]);
}
);
In your event handler.
Upvotes: 2