g.raphael bar chart with clickable bars
I'd like to make eac开发者_Go百科h segment of a stacked bar graph (horizontal in my case) clickable to a specific hyperlink (basically "drill down"). I don't think this functionality is in g.bar.js, but has anyone done this or can point me in the right direction? Would also be useful on dot charts.
Okay, posting the question seems to have motivated me to figure it out...
Using the demo bar chart provided, I added a line to the fin function:
fin = function () {
this.flag = r.g.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
/* add this for linked bars */
this.attr({href: "http://myurl.com/"+this.bar.x+"/"+this.bar.y+"/"+this.bar.value});
},
the suggested this.attr above didn't work for me, but this did:
fin = function () {
this.flag = r.g.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
/* add click event to bar */
this.click(function(){
location.href = "http://myurl.com";
});
},
精彩评论