我要加學位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(`${°}`)
但不作業。如何解決這個問題呢??
uj5u.com熱心網友回復:
嘗試.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>
注意使用轉義字符 ( \\) 來轉義~符號
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/506783.html
標籤:javascript html d3.js
上一篇:有條件地附加一個分離的元素
下一篇:使用節點和邊陣列創建d3層次結構
