G.raphael graphic chart with interactive bars

I would like to make each segment of the columnar histogram (horizontally in my case) clickable to a specific hyperlink (basically β€œexpand”). I don't think this function is in g.bar.js, but did anyone do this or can point me in the right direction? It would also be useful on scatter charts.

+4
source share
2 answers

Well, posting the question seems to have prompted me to figure this out ...

Using the provided demo diagram, I added a line to the fin function:

fin = function () { this.flag = rgpopup(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}); }, 
+4
source

this.attr suggested above does not work for me, but it happened:

 fin = function () { this.flag = rgpopup(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"; }); }, 
-1
source

Source: https://habr.com/ru/post/1339844/


All Articles