简体   繁体   English

树使用 D3 树 v4 。 内部节点和叶节点需要不同的形状

[英]tree using D3 tree v4 . Need different shapes for inner node and leaf node

I am creating "network tree" where we need to find in a network which node has any issue.我正在创建“网络树”,我们需要在网络中找到哪个节点有问题。 we need to track that node.我们需要跟踪那个节点。 As some of the tree node will have max 100 of children i dont want to show textbox for leaf node as it will not look tidy, instead i want to show a small compact circle with color code red/green.由于某些树节点将有最多 100 个子节点,因此我不想显示叶节点的文本框,因为它看起来不整洁,相反,我想显示一个带有红色/绿色代码的小型紧凑圆圈。 Other nodes which are not leaf nodes will be represented using TextBox.其他不是叶节点的节点将使用 TextBox 表示。 I am using append("rect") but i want to check if the node is inner node it will append "rect" else it will append "circle".我正在使用 append("rect") 但我想检查节点是否是内部节点,它将附加“rect”,否则它将附加“circle”。

I am referring this example https://bl.ocks.org/swayvil/b86f8d4941bdfcbfff8f69619cd2f460我指的是这个例子https://bl.ocks.org/swayvil/b86f8d4941bdfcbfff8f69619cd2f460

I need something like this at the leaf node.我在叶节点需要这样的东西。 As in my data there can be 100 of children ,i want to combine that into one group that is big rectangle inside it small rectangle for each children.因为在我的数据中可以有 100 个孩子,我想将它组合成一个组,每个孩子的小矩形里面有一个大矩形。

在此处输入图片说明

Probably this will help you in the below link.可能这会在下面的链接中为您提供帮助。https://bl.ocks.org/swayvil/b86f8d4941bdfcbfff8f69619cd2f460 Update width property according to your requirement, in reactNode object.https://bl.ocks.org/swayvil/b86f8d4941bdfcbfff8f69619cd2f460根据您的要求在 reactNode 对象中更新宽度属性。

var rectNode = {
                    width: 45, // 120
                    height: 45,
                    textMargin: 5
                },

update rx & ry value to achieve circular radius.更新 rx 和 ry 值以实现圆半径。 ie IE

nodeEnter.append('g').append('rect')
                    .attr('rx', 20)
                    .attr('ry', 20)
                    .attr('width', rectNode.width)
                    .attr('height', rectNode.height)
                    .attr('class', 'node-rect')
                    .attr('fill', function (d) {
                        return d.color;
                    })
                    .attr('filter', 'url(#drop-shadow)');

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

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