d3可折叠搜索树-在每次搜索中删除旧的stokes

d3 collapsible search tree - remove old stokes on each search

本文关键字:删除 stokes 搜索 搜索树 可折叠 d3      更新时间:2023-09-26

我使用的是可折叠搜索树。我需要在每次新的搜索中删除节点之间链接的彩色stokes。

如何删除以前搜索的链接的彩色stokes?

我试图删除我们在新搜索的openPaths(paths)函数中设置的path.link.class。但它不起作用。

您需要添加它来清除每个圆圈上的红色类,如下所示。

$("#search").on("select2-selecting", function(e) {
        var paths = searchTree(root,e.object.text,[]);
        if(typeof(paths) !== "undefined"){
          d3.selectAll("circle").style("fill", function(d) {
            d.class="";//clear the class of all circles.
            });
            openPaths(paths);
        }
        else{
            alert(e.object.text+" not found!");
        }
    })

此处为工作代码

希望这能有所帮助!