简体   繁体   English

以线性格式显示D3树布局

[英]Display D3 Tree Layout in Linear Format

I am following the D3 Collapsible Tree Layout guide and am trying to change the layout of the tree from 我正在遵循D3可折叠树布局指南,并尝试从以下位置更改树的布局

在此处输入图片说明

To a linear format, where the 'root' node is the left-most node on the tree 为线性格式,其中“根”节点是树上最左侧的节点 在此处输入图片说明

I don't know much about D3 just yet but I assume the d3.diagonal() function along with the nodes x & y parameters control the lines and node position. 我对D3并不太了解,但是我假设d3.diagonal()函数以及节点x&y参数控制着线和节点的位置。 Any input or guides on this that would point me in the right direction? 任何有关此方面的意见或指导会为我指明正确的方向吗?

do this 做这个

self.diagonal = d3.svg.line().interpolate('step')
    .x(function (d) { return d.x; })
    .y(function (d) { return d.y; });

And then use the generator like this: 然后像这样使用生成器:

link.enter().append('svg:path', 'g')
    .duration(self.duration)
    .attr('d', function (d) {
        return self.diagonal([{
            y: d.source.x,
            x: d.source.y
        }, {
            y: d.target.x,
            x: d.target.y
        }]);
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM