d3.js - How to add url/link on d3 objects in Cal-heatmap -
as newbie both d3 , js, or front-end in general, have spent enough time understand how cal-heatmap works. have working version, want make tiny boxes on calendar hyperlinks functionality, , reading source code complete disaster me. suppose should add .attr("xlink:href", url)
object suggested here, can't figure out where. there has done similar? don't understand how attributes specify when initializing passed through source code either. appreciated!
this takes little bit of hackery.
after heatmap draws could:
d3.selectall('.graph-rect') .each(function(d){ var = d3.select( this.parentnode ) // parent of rect (it's g) .append("a") // append link .attr("xlink:href","http://www.google.com") .attr("target", "_blank"); // set link var rect = this; rect.remove(); // remove rect a.insert(function(){return rect}); // , re-add link });
working example.
Comments
Post a Comment