Extracting HTML Link from Javascript Associative Array to apply to D3 Generated Table -
problem: html link i'm extracting associative array not applied link but, rather, string, html link not traversable browser.
full visual example , code: located at: http://bl.ocks.org/guerino1/6366020
data: have javascript array of associative arrays.
var densityset = [ { name: "<a href=\"http:if4it.com\">if4it</a>", total: 1000 }, { name: "node2", total: 1500 }, . . . { name: "node3", total: 700 }, { name: "node27", total: 1500 } ];
you'll notice first element of first associative array has data element html link. want extract link , apply cell of html table i'm generating using d3.
symptom: when table renders, full html path rendered string , not traversable html link.
the code extracts link data , applies cell follows...
var densitybodydatarecords = d3.selectall("#density_body_record").selectall("tr.td") .data(function(d) { return densitykeys.map(function(k) { return d[k]; }); }) .enter() .append("td") .attr("id", "density_body_data") //.text(function(d) { return d; }) .text(function(d, i) { if(i < 2) { return d; } <------------------text applied here }) .style("font-size", "10pt") .append("svg") .attr("width", function(d, i) { if(i == 0) { return 200; } else if(i == 1) { return 100; } else { return 500; } }) //.attr("height", 15) .attr("height", function(d, i) { if(i < 2) { return 0; } else { return 15; } }) .append("rect") .attr("height", 15) .style("fill", "blue") .attr("width", function(d, i) { if(i == 2) { return (d/maxrelationshipvalue)*100*5; } else { return 0; } });
any ideas on how fix appreciated.
thanks!
if want content parsed html, have call .html()
, not .text()
.
Comments
Post a Comment