Reputation: 2870
I'd like to make each 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.
Upvotes: 4
Views: 2573
Reputation: 10902
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";
});
},
Upvotes: -1
Reputation: 2870
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});
},
Upvotes: 4