Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript d3.js文本标记中的html_Javascript_Html_D3.js_Text - Fatal编程技术网

Javascript d3.js文本标记中的html

Javascript d3.js文本标记中的html,javascript,html,d3.js,text,Javascript,Html,D3.js,Text,我有一个轴: 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"

我有一个轴:

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 [&times;10<sup>-15</sup> ss<sup>-1</sup>]");
svg.append(“g”)
.attr(“类”、“x轴”)
.attr(“变换”、“平移(0)”、“高度+”)
.呼叫(xAxis)
.append(“文本”)
.attr(“类别”、“标签”)
.attr(“x”,宽度/2)
.attr(“y”,50)
.style(“文本锚定”、“中心”)
.文本(“pdot[×;10-15 ss-1]”;
但显然,标签是“按原样”呈现的。将最后一行更改为

.html("pdot [&times;10<sup>-15</sup> ss<sup>-1</sup>]");
.html(“pdot[×;10-15 ss-1]”;

仍然不能生产我想要的。如何使
文本
标记显示已处理的html?我正在寻找一个通用的解决方案,它允许我将任何html代码放入标签中。然而,最好的方法是使用乳胶。可能吗?如何使用?

您可以使用
外来对象来实现这一点,请参见,例如:

您是否有一个简单的JSF来了解您正在尝试做什么?使用
外来对象
:不是.html()不起作用,而是标记不起作用。使用Lars提到的foreginObject解决方案。@Larskothoff谢谢,它成功了。工作实例如下:请考虑提交答案。