d3中的泡泡树?

Leg*_*end 24 javascript jquery svg raphael d3.js

D3中是否有相应的Bubble Tree实现?在我提供的链接中,Bubble Tree是在RaphaelJS和jQuery中实现的.

在此输入图像描述

T14*_*145 1

你的问题的直接答案是否定的。

使用https://github.com/okfn/bubbletree/tree/master/build上的资源、您已知的信息、http://d3js.org/上提供的信息以及 GitHub 上的 D3 文档,您应该能够为 D3 召唤出你自己的泡泡树!

这是我很久以前用来可视化二叉树数据的一段 JavaScript:

var updateVisual;

updateVisual = function() {
    var drawTree, out;
    drawTree = function(out, node) {
        var col, gray, i, line, lineElt, lines, sub, _results, _results1;
        if (node.lines) {
            out.appendChild(document.createElement("div")).innerHTML = "<b>leaf</b>: " + node.lines.length + " lines, " + Math.round(node.height) + " px";
            lines = out.appendChild(document.createElement("div"));
            lines.style.lineHeight = "6px";
            lines.style.marginLeft = "10px";
            i = 0;
            _results = [];
            while (i < node.lines.length) {
                line = node.lines[i];
                lineElt = lines.appendChild(document.createElement("div"));
                lineElt.className = "lineblock";
                gray = Math.min(line.text.length * 3, 230);
                col = gray.toString(16);
                if (col.length === 1) col = "0" + col;
                lineElt.style.background = "#" + col + col + col;
                console.log(line.height, line);
                lineElt.style.width = Math.max(Math.round(line.height / 3), 1) + "px";
                _results.push(i++);
            }
            return _results;
        } else {
            out.appendChild(document.createElement("div")).innerHTML = "<b>node</b>: " + node.size + " lines, " + Math.round(node.height) + " px";
            sub = out.appendChild(document.createElement("div"));
            sub.style.paddingLeft = "20px";
            i = 0;
            _results1 = [];
            while (i < node.children.length) {
                drawTree(sub, node.children[i]);
                _results1.push(++i);
            }
            return _results1;
        }
    };
    out = document.getElementById("btree-view");
    out.innerHTML = "";
    return drawTree(out, editor.getDoc());
};
Run Code Online (Sandbox Code Playgroud)

只需插入一些圆形元素并对其进行一些操作以形成圆形庄园的样式,您就应该拥有一个好的程序集!