Search code examples
raphaelgraphael

g.raphael bar chart with clickable bars


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.


Solution

  • 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});
      },