d3.js带直链的缩进树

编程入门 行业动态 更新时间:2024-10-10 07:32:11
本文介绍了d3.js带直链的缩进树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的代码基于 D3.js缩进树示例。

我想要直接链接,而不是父/子对象之间的弯曲链接。

I want straight links instead of the curved links between parent/child-objects.

我理解这与下面的代码,但是,我找不到一个解决方案。我想要的链接是直线与90度转弯。

I understand this has something to do with the following code, however, I can't find a solution. I want the links to be straight with a 90-degree turn.

var diagonal = d3.svg.diagonal() .projection(function(d) { return [d.y, d.x]; });

推荐答案

问题是提取x和y点链接。一种方法是:

The problem is to extract the x and y points from the links. One way of doing this is:

链接生成器:

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 }]); });

更多推荐

d3.js带直链的缩进树

本文发布于:2023-11-26 02:11:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1632229.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:直链   js

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!