首页 \ 问答 \ 每个图节点上的链接动画/过渡 - D3.js(Chained animations/transitions over each graph node - D3.js)

每个图节点上的链接动画/过渡 - D3.js(Chained animations/transitions over each graph node - D3.js)

我希望能够使用d3.js更改我创建的图形中每个节点的半径。 但是,我想一次一个地更改每个节点的半径,并且我希望能够控制每个更改之间的延迟以及节点的顺序。

现在这就是我的代码:

var nodes = svg.selectAll(".node");
nodes.each(function() { 
  d3.select(this).
  transition().
  delay(100).
  attr("r", "5") 
});

您只需使用此链接中的代码即可复制此内容: http//bl.ocks.org/mbostock/4062045 。 我上面粘贴的代码只是上述链接中代码的补充。

当我运行它时,我的图形中的所有nodes同时转换,即同时增大尺寸(半径)。 然而,我希望它们转换,即一次一个地增大尺寸(半径)。 我再说一遍,我希望能够控制:

  1. 每个node的转换和之间的delay
  2. 经历转换的nodes的顺序。

任何指针,教程,甚至其他stackoverflow答案都会很棒。 我理想地想要一些代码示例。

我在网上引用方面最接近的是关于d3.js过渡的教程的这一小节: http ://bost.ocks.org/mike/transition/#per-element。 但是,它缺少具体的代码示例。 我是d3.js和javascript的新手,如果没有具体的代码示例,我就无法接受它。


I want to be able to change the radius of each node in my graph that i am creating using d3.js. However, i want to change the radius of each node, one at a time, and i want to able to control the delay between each change along with the sequence of the nodes.

For now this is what i have in terms of code:

var nodes = svg.selectAll(".node");
nodes.each(function() { 
  d3.select(this).
  transition().
  delay(100).
  attr("r", "5") 
});

You can replicate this simply by using the code at this link: http://bl.ocks.org/mbostock/4062045. The code that i have pasted above is simply an addition to the code at the aforementioned link.

When i run this, all the nodes in my graph transition simultaneously, i.e. grow in size (radius) simultaneously. I however want them to transition i.e. grow in size (radius), one at a time. I repeat that i want to be able to control:

  1. the delay between the transition of each node and
  2. the order of nodes that undergo the transitions.

Any pointers, tutorials, or even other stackoverflow answers would be great. I would ideally want some code examples.

The closest i have come to in terms of online references is this subsection of a tutorial on d3.js transitions: http://bost.ocks.org/mike/transition/#per-element. However, it lacks a concrete code example. I, being new to d3.js and javascript in general, am not able to pick it up without concrete code examples.


原文:https://stackoverflow.com/questions/15319501
更新时间:2022-08-09 18:08

最满意答案

将按钮直接添加到表视图单元格的内容视图中,不要将它们添加到集合视图中。 这样他们就会保持原状。 如果你看不到它们,那么它们可能位于集合视图下面并且被遮挡了。 通过在文档大纲中拖放来更改界面构建器中视图的顺序。 这会改变哪个视图位于顶部。

文档大纲是您在问题中发布的截图视图,从“brandsCollectionTableViewCell”开始。 大纲包含单元格的子视图。 具有相同父视图的视图(如当前在大纲中显示的图像视图,标签和按钮)将按照它们在列表中的位置在彼此“顶部”排序。 因此,您拖动该列表中的项目以更改顺序,或选择按钮,然后转到编辑器 - > 排列 - > 发送XX以调整位置。

使用Xcode视图层次结构调试器来帮助您了解正在发生的事情(调试工具栏上的这个按钮):

在此处输入图像描述

3D视图将让您看到“缺失”按钮的位置。

如果您确实希望在集合视图中包含按钮,则​​需要使用实现浮动视图的自定义集合视图布局。 这不是一项简单的任务,但我在这里写了一些关于它的文章。


Add the buttons directly to the content view of the table view cell, don't add them to the collection view. That way they will stay in position. If you can't see them it's possible that they were underneath the collection view and were obscured. Change the order of the views in interface builder by dragging and dropping in the document outline. This changes which view is on top.

The document outline is the view you have posted as a screenshot in your question, starting at "brandsCollectionTableViewCell". The outline contains the subviews of the cell. Views with the same parent, like the image view, label and buttons currently shown in the outline, will be ordered "on top" of each other by their position in the list. So you drag the items in that list to change the order, or select the buttons then go to Editor -> Arrange -> Send XX to adjust the position.

Use the Xcode view hierarchy debugger to help you understand what is happening (that's this button on the debugging toolbar):

enter image description here

The 3D view will let you see where your "missing" buttons are.

If you really want to include the buttons in the collection view, then you need to use a custom collection view layout implementing floating views. That's not a straightforward task, but I've written something about it here.

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。