[英]jqplot link in legend
I have a basic pie chart made with jqplot: 我有一个用jqplot制作的基本饼图:
$(document).ready(function(){
var data = [
['Heavy Industry', 12],['Retail', 9], ['Light Industry', 14],
['Out of home', 16],['Commuting', 7], ['Orientation', 9]
];
var plot1 = jQuery.jqplot ('chart1', [data],
{
seriesDefaults: {
renderer: jQuery.jqplot.PieRenderer,
rendererOptions: {
showDataLabels: true
}
},
legend: { show:true, location: 'e' }
}
);
});
Now I want to add links in the legend. 现在,我想在图例中添加链接。 Is that possible and if so how?
那有可能吗?
You can put HTML in labels: 您可以将HTML放入标签中:
$.jqplot(..., {
series : {
...
label : "<a href='URL'>click me</a>"
}
});
(or put the equivalent in the legend
section of the jqPlot configuration object). (或将等效项放在jqPlot配置对象的
legend
部分中)。
However, you might need to adjust the z-index of the legend before they are clickable: 但是,您可能需要先调整图例的z-index,然后才能单击它们:
.jqplot-table-legend { z-index: 1000 }
Also, I noticed some settings (like enabling zoom) block the clickability of the labels. 另外,我注意到某些设置(例如启用缩放)阻止了标签的可点击性。
//I used the below method to bring hyperlink on legends, it worked for me. I did the same thing for bar chart also.
This is the string which I used to form the array. 这是我用来形成数组的字符串。
strArr = "[<' a onclick = GoToSearch("100") href=# > NY <'/a> ' , 8561 ]" strArr =“ [<'a onclick = GoToSearch(” 100“)href =#> NY <'/ a>',8561]”
arrOwner= eval("[" + strArr + "]")
$.jqplot.config.enablePlugins = false;
plotCAP_EquipCount1 = $.jqplot('piechartOwner', [arrOwner], {
grid: {
drawBorder: true,
drawGridlines: false,
background: '#ffffff',
shadow: false
},
axesDefaults: {
},
title: 'Ownership Data',
seriesDefaults: {
renderer: $.jqplot.PieRenderer,
rendererOptions: {
showDataLabels: true,
sliceMargin: 1,
startAngle: -90,
dataLabels: 'value',
highlightMouseOver: true,
highlightMouseDown: true
}
},
legend: {
show: true,
placement: 'outsideGrid',
rendererOptions: {
numberRows: 10
},
location: 'ne'
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.