将变量放入 p.text 函数时加粗



所以我有这个p.text函数,它向我显示文本,一个国家的名称(d.properties.name(和这个国家拥有的值(d.properties.value( 例如,如何使国家/地区名称以粗体显示?

var countryHeight = d.properties.value;
var countryName = d.properties.name;
p.text(function(countryHeight){return "The Average Height of Men in " +  d.properties.name + " = " + d.properties.value})
.style("color", "red")
.style("font-size", "150%")

如果要将其注入HTML页面(网页(,则可以在文本函数中包含标记。

var countryHeight = d.properties.value;
var countryName = d.properties.name;
p.text(function(countryHeight){return "The Average Height of Men in <b>" +  d.properties.name + "</b> = " + d.properties.value})
.style("color", "red")
.style("font-size", "150%");

最新更新