1

我尝试使用 d3plus-text。首先我在 svg 元素上附加新的文本元素

node.append("text")
.text(function (d: any) { return d.properties.name; })
.attr("class", "nodeText");

然后我想换行该文本

new d3PlusText.TextBox()
.select(".nodeText")
.fontResize(true)
.width(options.nodeRadius)
.render();

但是我在渲染时遇到错误

    TypeError: Cannot read property 'reduce' of undefined
    TextBox.render
    node_modules/d3plus-text/es/src/TextBox.js:130
130 | var boxes = this._select.selectAll(".d3plus-textBox").data(this._data.reduce(function (arr, d, i) {

我确定有 nodeText 元素。我究竟做错了什么?谢谢

4

0 回答 0