如何将jquery单击事件添加到gRaphael图形?
我用拉斐尔制作了一张图表:如何将jquery单击事件添加到gRaphael图形?,jquery,graphael,Jquery,Graphael,我用拉斐尔制作了一张图表: $(function(){ var r = Raphael("pieChart"), pie = r.piechart(320, 240, 100, [55, 20, 13, 32, 5, 1, 2, 10]); r.text(320, 100, "Interactive Pie Chart").attr({ font: "20px sans-serif" }); $(pie.secto
$(function(){
var r = Raphael("pieChart"),
pie = r.piechart(320, 240, 100, [55, 20, 13, 32, 5, 1, 2, 10]);
r.text(320, 100, "Interactive Pie Chart").attr({ font: "20px sans-serif" });
$(pie.sector).click(function(){
alert('hi');//not work!
})
})
后来我将click事件添加到pie.sector,但我的事件无效。。。有人知道使用jQuery处理gRaphael的正确方法吗?只需选择饼图即可
$(pie).click(function(){
alert('hi');
})
给你
在饼图切片上迭代并向其添加单击处理程序
for(var index_i=0;index_i < pie.covers.items.length;index_i++){
pie.covers.items[index_i].click(clickSomeSlice);
}
var clickSomeSlice = function () {
alert("clicked on\t"+this.label[1].attrs.text);
};
for(var index_i=0;index_i