I have this chart that I need to make some a label bold based on a variable. However I am not sure how in D3 to achieve this. I think may need to use the .each function. The line .style("font-weight", "bold") makes all the text labels bold but I only want certain values to be made bold. Any ideas on the correct syntax for this?
g.append("svg:text")
.each(function(d) { d.angle = (d.startAngle + d.endAngle) / 2; })
.attr("dy", ".35em")
.style("font-family", "helvetica, arial, sans-serif")
.style("font-size", "10px")
//.style("font-weight", "bold")
.attr("text-anchor", function(d) { return d.angle > Math.PI ? "end" : null; })
.attr("transform", function(d) {
return "rotate(" + (d.angle * 180 / Math.PI - 90) + ")"
+ "translate(" + (r0 + 36) + ")"
+ (d.angle > Math.PI ? "rotate(180)" : "");
})
.text(function(d) { return rdr(d).gname; });
This approach seems to work...
.style("font-weight", function(d) {if(selectedvaluessplit.indexOf( rdr(d).gname ) > -1) {return "bold"}})
this is the answer
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.