2011-12-15 2 views
4

내가 svg 요소에 ID를 어떻게 할당 할 수 있습니까? (바 raphaeljs하는)

bar[0].id = "id-"+i; 
//or 
bar.node.id = "id-"+i; 

bar

는 라파엘 요소 인 시도 g.raphael의 막대 그래프에서 막대를 raphaeljs하는 ID를 할당 할 수있는 방법

var r = Raphael("holder", 600, 500); 
var data=[1,3,4,5]; 
var chart = r.g.barchart(30, 30, 350, 250, [data], {stacked: true, type: "soft"}); 
for (var i = 0; i < chart.bars[0].length; i++) { 
     var bar = chart.bars[0][i]; 
     if (bar.value >= 7) { 
       bar.attr("fill", "#bf2f2f"); 
       bar.attr("stroke", "#bf2f2f"); 
       bar.attr("id","id-"+i); //this doesn't work 
       bar.id="id-"+i;   //this also doesn't work 
       //applied as per raphaeljs documentatoion 
       //[http://raphaeljs.com/reference.html#Element.id][1] 
        } 
     } 

답변