0
有沒有一種方法可以編程方式將nvd3 IndentedTree展開爲http://nvd3.org/examples/indentedtree.html中的特定元素,並向該元素添加「active」類?將IndentedTree展開到特定元素
謝謝!
有沒有一種方法可以編程方式將nvd3 IndentedTree展開爲http://nvd3.org/examples/indentedtree.html中的特定元素,並向該元素添加「active」類?將IndentedTree展開到特定元素
謝謝!
找到它。
NVD3使用樹節點的「values」屬性標記展開的元素,「_values」表示摺疊的元素。
所以,如果你想展開/摺疊一棵樹或其一部分,你將內容從_values移動到值,反之亦然。之後,調用chart.update()來重繪。
此外,要爲包含樹節點的元素添加一個「活動」類,我使用了列數組的「類」回調。回調錶數據元素的子元素上運行:
classes: function(d) {
if (d.isSelected) {
d3.select(this.parentNode).attr("class", "active");
}
}
「isSelected」是我添加到當前節點的屬性。