- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
关于这个例子(d3.j radial tree node links different sizes),我想知道是否可以在 d3.js 中混合径向树和直线树。
对于我的 jsFiddle
示例:https://jsfiddle.net/j0kaso/fow6xbdL/我想让父级(level0)与第一个子级(level1)有一条直线,然后是径向弯曲的树(就像现在一样)。
这可能吗?
我找不到与之相关的任何内容,但由于我对 d3.js/JS 比较陌生,所以我可能只是错过了正确的关键字。希望有人有一个可行的例子或者可以指出我正确的方向 - 无论如何我很感激任何提示和评论!
最佳答案
如果链接的源深度为 0,则可以从链接的源和目标的 x 和 y 生成 SVG 路径,类似于使用三 Angular 函数计算节点位置的方式,其中 x 是旋转 Angular ,y 是半径.
//create the linkRadial function for use later in the 'd' generation
const radialPath = d3.linkRadial()
.angle(l => l.x)
.radius(l => l.y)
const link = svg.append("g")
.attr("fill", "none")
.attr("stroke-opacity", 0.4)
.attr("stroke-width", 1.5)
.selectAll("path")
.data(root.links())
.enter()
.append("path")
link.attr("d", function(d){
let adjust = 1.5708 //90 degrees in radians
// calculate the start and end points of the path, using trig
let sourceX = (d.source.y * Math.cos(d.source.x - adjust));
let sourceY = (d.source.y * Math.sin(d.source.x - adjust));
let targetX = (d.target.y * Math.cos(d.target.x - adjust));
let targetY = (d.target.y * Math.sin(d.target.x -adjust));
// if the source node is at the centre, depth = 0, then create a straight path using the L (lineto) SVG path. Else, use the radial path
if (d.source.depth==0){
return "M" + sourceX + " " + sourceY + " "
+ "L" + targetX + " " + targetY
} else {
return radialPath(d)
}
})
关于javascript - d3.j 将径向树与链接(直)树混合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58100069/
我正在尝试快速创建一个径向 CAGradientLayer。普通 CAGradientLayers(默认类型 axial)没有问题。它们在模拟器中的快照和运行时呈现良好。 当我拍摄我创建的 UIVie
我想用 CSS 制作一个径向进度指示器,它的中间圆圈是透明的。看这里:http://codepen.io/geedmo/pen/InFfd – 这是我想要做的事情的完美示例,但中间 (.overlay
我已经编写了用于生成网络图的 UI、服务器和 global.r。它适用于一种布局(layout.fruchterman.reingold)。我想要一个用于列出布局的单选按钮(径向、对角线网络和 den
我正在使用 jqwidgets。在那些小部件中,我使用的是径向量规。对于那个径向仪表,我想给出径向背景色。我有一个类似这样的代码,用于更改径向仪表中的背景颜色。 $('#gauge').jqxGaug
有谁知道我可以用来为 iOS 应用程序创建饼图(径向)菜单的库(开源或其他)? 看来现在应该有人想到了这一点,如果没有必要,我不愿意自己动手。 最佳答案 我不久前发现的一个。 http://www
我正在使用 this code为我的数据获取径向 TreeMap 。但是,我想修改它以避免弯曲链接。相反,我对线性直接连接感兴趣。弯曲的链接使插图不那么复杂,特别是当我们的子节点数量较少时。例如,您可
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 8 年前。 Improve this qu
我正在使用 chrome 18.0.1025.162 并尝试进行径向渐变 -webkit-radial-gradient(circle, rgba(100, 100, 100, 0.2), rgba(
我想呈现漂亮的径向树布局,但有点被弯曲的边缘绊倒了。问题是源点和目标点之间的角度不同,边缘的绘制方式也不同。提供的图片来自单个图表,因此您可以看到它们在不同边缘方向上有何不同。我认为关键在于 beiz
我希望我的工具栏使用 Material 设计径向 react 编排指南改变颜色 我想将其实现为 Angular 2 过渡,但我不知 Prop 体该怎么做: 看起来像这样.. @Component({
我目前正在使用以下代码绘制形状; GLfloat vertex = // vertex points glLineWidth(2); glEnableClientState(GL_VERTEX_ARR
我是一名优秀的程序员,十分优秀!