每个图节点上的链接动画/过渡 - 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
同时转换,即同时增大尺寸(半径)。 然而,我希望它们转换,即一次一个地增大尺寸(半径)。 我再说一遍,我希望能够控制:
- 每个
node
的转换和之间的delay
- 经历转换的
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:
- the
delay
between the transition of eachnode
and- 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
最满意答案
将按钮直接添加到表视图单元格的内容视图中,不要将它们添加到集合视图中。 这样他们就会保持原状。 如果你看不到它们,那么它们可能位于集合视图下面并且被遮挡了。 通过在文档大纲中拖放来更改界面构建器中视图的顺序。 这会改变哪个视图位于顶部。
文档大纲是您在问题中发布的截图视图,从“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):
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.
相关问答
更多-
当性能需要时,UICollection将杀死不在屏幕外的单元格。 在您的情况下,您可以创建一个NSMutableArray来记录所有移动历史记录的单元格。 如果一个单元格已经移动,则将YES设置为相应的数组索引。 在为按钮设置动画之前,只需检查数组以查找它是否已被移动。 The UICollection will kill the cells not offscreen when needed for the performance. In your situation, you may create an ...
-
如何重新加载tableviewcell内的collectionview(how to reload a collectionview that is inside a tableviewcell)[2022-02-28]
我发现了怎么样! 在我的tableViewCell类中,我只需要将collectionView链接为一个插座,所以在我的tableViewCell的cellForRowAtIndexPath我只需要调用cell.collectionView.reloadData() I found out how! In my tableViewCell class I just need to link the collectionView as an outlet so in my tableViewCell's ce ... -
最有可能的是,您遇到了重用UITableViewCell的问题。 发生的事情是,您最初为频道A出列一个新单元格,并且onceOnly设置并正确显示,其中包括仅设置为true 。 然后,这个单元格被tableview重用,并被出列用于通道B.但是在这种情况下, onceOnly和counterIndexPath仍然设置了A的信息。 您已经在实施prepareForReuse 。 您只需要重置其中的附加信息即可获得所需的信息。 override func prepareForReuse() { cha ...
-
重用collectionView(Reusing collectionView)[2021-05-28]
您应该将所有这些逻辑放入一个单独的VC并重用VC,您不仅仅是尝试重用集合视图。 因此,无论您何时需要此集合视图的“副本”,您实际上都会添加子VC并将VC中的视图添加为子视图。 You should put all of this logic into a separate VC and reuse the VC, you aren't just trying to reuse the collection view. So, wherever you need a 'copy' of this collec ... -
在将JSON序列化为Array之后,您需要对数据进行排序 您的阵列数据 let array = [ [ "SCREENTIME": "15:00", "FORMAT": "2D" ], [ "SCREENTIME": "17:00", "FORMAT": "2D" ], [ "SCREENTIME": "21:00", ...
-
在tableviewcell上覆盖按钮与里面的collectionview(Overlaying buttons on tableviewcell with collectionview inside)[2023-05-16]
将按钮直接添加到表视图单元格的内容视图中,不要将它们添加到集合视图中。 这样他们就会保持原状。 如果你看不到它们,那么它们可能位于集合视图下面并且被遮挡了。 通过在文档大纲中拖放来更改界面构建器中视图的顺序。 这会改变哪个视图位于顶部。 文档大纲是您在问题中发布的截图视图,从“brandsCollectionTableViewCell”开始。 大纲包含单元格的子视图。 具有相同父视图的视图(如当前在大纲中显示的图像视图,标签和按钮)将按照它们在列表中的位置在彼此“顶部”排序。 因此,您拖动该列表中的项目以更 ... -
TableViewCell中的CollectionView滚动在swift3中不流畅(CollectionView in TableViewCell scroll isn't smooth in swift3)[2024-01-18]
在collectionView: UICollectionView, cellForItemAt indexPath: IndexPath下载图像URL数据collectionView: UICollectionView, cellForItemAt indexPath: IndexPath委托 - ASYNCHRONOUSLY 创建一个类 首先根据关键图像URL缓存图像数据 为什么我们需要缓存数据? 因为 - 滚动时我们不需要每次都下载图像,因此缓存已下载的图像数据并返回缓存数据 我创建了一个类名: As ... -
从collectionView中的自定义tableView以编程方式进行查看(Segue programatically from custom tableView inside collectionView)[2023-06-03]
这是因为您的类eventsCustomCollectionCell是UICollectionViewCell子类而不是UIViewController子类。 func performSegue(withIdentifier identifier: String, sender: Any?) 是UIViewController中可用的方法。 因此,对于解决方案,您可以在eventsCustomCollectionCell中创建一个可以有方法的协议 func cellClicked(cell: eventsC ... -
集合视图委托方法不知道其集合视图的上下文。 您应该根据collectionView实例计算onlineNews索引,而不是使用indexPath.row,这是内部收集视图索引路径。 编辑:更好的选择(避免滚动和布局问题)是使用单个集合视图,其中单元格按行分组。 如果您不想创建布局管理器,则可以通过在节之间添加小但非常宽的分隔符视图来实现此类布局 EDIT2: cell.contentType.text = categoryResults[indexPath.row]["ContentType"].strin ...
-
在你的TableViewCell.h文件中添加。 @property (nonatomic, assign) UICollectionView *yourCollectionView; 在您的TableViewCell.m文件中添加。 @synthesize yourCollectionView; 在init方法中的alloc collection视图和set delegate&datasource。 yourCollectionView = [UICollectionView alloc] initW ...