我想添加度数html代码°
const degreeNum = d3
.select(`#windBox${order}`)
.append("text")
.attr("x", 250)
.attr("y", 130)
.style("font", "bold 50px sans-serif")
.style("fill", "url(#lgTextDegree)")
.text(`${degree}`); // here i want to add html code
我尝试像这个这样的模板文字
.text(`${°}`)
但不起作用。如何解决这个问题??
尝试.text(String.fromCharCode(176))
d3.select("#my\~div_chart").on("click", function(){
d3.select(this).text(String.fromCharCode(176))
});
<script src="https://d3js.org/d3.v4.min.js"></script>
<div id="my~div_chart">Click Me</div>
注意使用转义符(\
(来转义~
符号