[英]html in d3.js text tag
I have an axis: 我有一个轴:
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis)
.append("text")
.attr("class", "label")
.attr("x", width / 2)
.attr("y", 50)
.style("text-anchor", "center")
.text("pdot [×10<sup>-15</sup> ss<sup>-1</sup>]");
but apparently the label is rendered 'as is'. 但显然标签是“按原样”呈现的。 Changing the last line to 将最后一行更改为
.html("pdot [×10<sup>-15</sup> ss<sup>-1</sup>]");
still does not produce what I want. 仍然没有产生我想要的。 How to make text
tag display processed html? 如何使text
标签显示经过处理的HTML? I'm looking for general solution that will allow me to put any html code into the label. 我正在寻找将使我可以将任何html代码放入标签的常规解决方案。 However, the best would be the way to use LaTeX. 但是,最好的方法是使用LaTeX。 Is it possible? 可能吗? How? 怎么样?
您可以foreignObject
使用foreignObject
对象,请参见例如http://bl.ocks.org/mbostock/1424037 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.