我想把html附加到D3中的矩形上,给我一个多行工具提示。底部是如何添加一个矩形,这可能是问题的一部分。最上面是应该在我的世界里工作的代码。newRect.().html(" Test " + "" + "Test2 ");
这会将文本字段插入SVG,但它只是不显示:
html:
Test Test2
我有一个鼠标移过函数,它运行以下内容:newRect = svg.append("rect")
.attr("x", xCor)
.attr("y", yCor)
.attr("width", 130)
.attr("height", 160)
.attr("fill", "red")
.attr("id", "rectLabel");
我想我应该这么做,但这不起作用。它只是删除了我试图追加到的g.node。newRect = $(this).enter().append("rect")
.attr("x", xCor)
.attr("y", yCor)
.attr("width", 130)
.attr("height", 160)
.attr("fill", "red")
.attr("id", "rectLabel");
问题:为什么我的文字没有出现?我试过.html,.textarea。我想要一个多行标签,所以我不认为。文本将工作正确?另外,我应该如何添加矩形呢?