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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -