Raphael JS Pie:为路径切片添加ID

我在Raphael谷歌小组看过这个问题,但是在那里搜索了几个小时,还有谷歌,我似乎无法找到解决方案。

我只是希望能够使用jQuery定位我的饼图(svg路径)切片,但我无法弄清楚如何将自定义ID添加到路径标记 – 默认情况下没有ID属性:

 

什么是理想的将是这样的:

  

有谁知道如何实现这一目标?

这是我用来创建饼图的代码:

 window.onload = function () { var r = Raphael("holder"); var pie = rgpiechart(350, 350, 256, [56, 104, 158, 23, 15, 6]); pie.hover(function () { this.sector.stop(); this.sector.animate({scale: [1.1, 1.1, this.cx, this.cy]}, 500, "bounce"); }, function () { this.sector.animate({scale: [1, 1, this.cx, this.cy]}, 500, "bounce"); }); 

};

基本上,我需要能够做到这一点的原因是,我可以创建一些单独的锚点触发器来执行上面显示的缩放动画。

任何帮助非常感谢。

piechart对象提供了3种到达其扇区的方法。

1)每个function

 pie.each(function(sector, cover, i) { sector.attr({/*...*/}); //raphael $(sector.node).foo(); //jquery }); 

2)系列对象(用于样式和转换)

 var i = 0; // 0 = 56, 1 = 104, 2 = 158 … //raphael way to hide the first sector pie.series.items[i].attr({ opacity : 0 }); //jquery way to hide the first sector $(pie.series.items[i].node).hide(); 

其中i是数据数组的索引

演示: http : //jsbin.com/eriqa5/2/edit

3)覆盖对象(用于鼠标和触摸事件)

 //raphael way to hover the first sector pie.covers.items[0].hover(...); //jquery way to hover the first sector $(pie.covers.items[0].node).hover(...); 

演示: http : //jsbin.com/eriqa5/4/edit