gpt4 book ai didi

javascript - jqplot 如何使链接到另一个页面的条形图可点击

转载 作者:行者123 更新时间:2023-11-29 16:14:18 24 4
gpt4 key购买 nike

我试过使用 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' }
}
}
});
});
  • 我应该如何链接到栏,例如 localhost/webCharts/branch.aspx?branchId=08270K08001

也试过这个How to catch the click event from the axis ticks 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() { ..... } 中。所以我只是用 pointIndexseriesIndex。非常感谢大家

关于javascript - jqplot 如何使链接到另一个页面的条形图可点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19487717/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com