开发者

g.raphael bar chart with clickable bars

开发者 https://www.devze.com 2023-02-10 20:11 出处:网络
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.j

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

精彩评论

暂无评论...
验证码 换一张
取 消