简体   繁体   中英

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?

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.

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%");

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.

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