我尝试使用jqplot创建条形图,该条形图可以单击,然后将用户连同标签值作为url参数一起重定向到另一个页面,但是没有运气可以建立链接。这是我所做的。
$(document).ready(function() {
$.jqplot.config.enablePlugins = true;
var ticks = [ 'SCAN', 'SGON', 'TERM', 'TRAN'];
var arrBranchId = ['08270K08001', '08298K08003', '12026K12003','14123K14003'];
var plot1 = $.jqplot('chart1',[[0,0,0,1],[2,4,2,5],[0,0,0,1],[0,5,0,1]], {
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
rendererOptions: { fillToZero: true },
pointLabels: { show: true }
},
series: [{label:'08270K08001'},{label:'08298K08003'},{label:'12026K12003'},{label:'14123K14003'}],
legend: {
show: true,
placement: 'ne'
},
highlighter: {
show: false,
},
cursor: {
show: true
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: ticks
},
yaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
pad: 1.05,
tickOptions: { formatString: '%d' }
}
}
});
});
还尝试了此方法如何从轴刻度jqplot,highcharts,flot捕获单击事件,将函数更改为
$('.jqplot-xaxis-tick').each(function(){
var label = $(this),
value = label.text();
if(categoryLinks[value]) {
label.click(function(){
alert('could link to another page: ' + categoryLinks[value]);
});
}
});
但是当用户点击时什么也没有发生。我在这里想念什么吗?提前致谢
我想出了一种方法,使该栏可单击并通过使用window.location链接到另一个页面,如下所示
$('#chart1').bind('jqplotDataClick',function(ev, seriesIndex, pointIndex, data){
window.location = 'branchDetails.aspx?appId='+ticks[**pointIndex**]+"&branchId="+arrBranchId[**seriesIndex**];
});
注意:数组ticks []和arrBranchId []已经在$(document).ready(function(){.....}中定义了,所以我刚刚通过pointIndex和seriesIndex传递了数组。非常感谢大家
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句