简体   繁体   English

放入p.text函数时使变量变为粗体

[英]Making a variable bold when put in p.text function

So i have this p.text function that shows me The text, The name of a country (d.properties.name) and The value this country hold (d.properties.value) How do i for instance make the country name appear in bold? 所以我有这个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%")

If you are injecting this into an HTML page (webpage), then you can include markup inside the text function. 如果要将其注入到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%");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM